OSDN Git Service

gcc:
[pf3gnuchains/gcc-fork.git] / gcc / tree-optimize.c
1 /* Top-level control of tree optimizations.
2    Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3    Contributed by Diego Novillo <dnovillo@redhat.com>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "rtl.h"
28 #include "tm_p.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
31 #include "output.h"
32 #include "expr.h"
33 #include "diagnostic.h"
34 #include "basic-block.h"
35 #include "flags.h"
36 #include "tree-flow.h"
37 #include "tree-dump.h"
38 #include "timevar.h"
39 #include "function.h"
40 #include "langhooks.h"
41 #include "toplev.h"
42 #include "flags.h"
43 #include "cgraph.h"
44 #include "tree-inline.h"
45 #include "tree-mudflap.h"
46 #include "tree-pass.h"
47 #include "ggc.h"
48 #include "cgraph.h"
49 #include "graph.h"
50 #include "cfgloop.h"
51
52
53 /* Global variables used to communicate with passes.  */
54 int dump_flags;
55 bool in_gimple_form;
56
57 /* The root of the compilation pass tree, once constructed.  */
58 static struct tree_opt_pass *all_passes, *all_ipa_passes;
59
60 /* Gate: execute, or not, all of the non-trivial optimizations.  */
61
62 static bool
63 gate_all_optimizations (void)
64 {
65   return (optimize >= 1
66           /* Don't bother doing anything if the program has errors.  */
67           && !(errorcount || sorrycount));
68 }
69
70 static struct tree_opt_pass pass_all_optimizations =
71 {
72   NULL,                                 /* name */
73   gate_all_optimizations,               /* gate */
74   NULL,                                 /* execute */
75   NULL,                                 /* sub */
76   NULL,                                 /* next */
77   0,                                    /* static_pass_number */
78   0,                                    /* tv_id */
79   0,                                    /* properties_required */
80   0,                                    /* properties_provided */
81   0,                                    /* properties_destroyed */
82   0,                                    /* todo_flags_start */
83   0,                                    /* todo_flags_finish */
84   0                                     /* letter */
85 };
86
87 /* Pass: cleanup the CFG just before expanding trees to RTL.
88    This is just a round of label cleanups and case node grouping
89    because after the tree optimizers have run such cleanups may
90    be necessary.  */
91
92 static void 
93 execute_cleanup_cfg_post_optimizing (void)
94 {
95   cleanup_tree_cfg ();
96   cleanup_dead_labels ();
97   group_case_labels ();
98 }
99
100 static struct tree_opt_pass pass_cleanup_cfg_post_optimizing =
101 {
102   "final_cleanup",                      /* name */
103   NULL,                                 /* gate */
104   execute_cleanup_cfg_post_optimizing,  /* execute */
105   NULL,                                 /* sub */
106   NULL,                                 /* next */
107   0,                                    /* static_pass_number */
108   0,                                    /* tv_id */
109   PROP_cfg,                             /* properties_required */
110   0,                                    /* properties_provided */
111   0,                                    /* properties_destroyed */
112   0,                                    /* todo_flags_start */
113   TODO_dump_func,                                       /* todo_flags_finish */
114   0                                     /* letter */
115 };
116
117 /* Pass: do the actions required to finish with tree-ssa optimization
118    passes.  */
119
120 static void
121 execute_free_datastructures (void)
122 {
123   tree *chain;
124
125   /* ??? This isn't the right place for this.  Worse, it got computed
126      more or less at random in various passes.  */
127   free_dominance_info (CDI_DOMINATORS);
128
129   /* Emit gotos for implicit jumps.  */
130   disband_implicit_edges ();
131
132   /* Remove the ssa structures.  Do it here since this includes statement
133      annotations that need to be intact during disband_implicit_edges.  */
134   delete_tree_ssa ();
135
136   /* Re-chain the statements from the blocks.  */
137   chain = &DECL_SAVED_TREE (current_function_decl);
138   *chain = alloc_stmt_list ();
139
140   /* And get rid of annotations we no longer need.  */
141   delete_tree_cfg_annotations ();
142 }
143
144 static struct tree_opt_pass pass_free_datastructures =
145 {
146   NULL,                                 /* name */
147   NULL,                                 /* gate */
148   execute_free_datastructures,                  /* execute */
149   NULL,                                 /* sub */
150   NULL,                                 /* next */
151   0,                                    /* static_pass_number */
152   0,                                    /* tv_id */
153   PROP_cfg,                             /* properties_required */
154   0,                                    /* properties_provided */
155   0,                                    /* properties_destroyed */
156   0,                                    /* todo_flags_start */
157   0,                                    /* todo_flags_finish */
158   0                                     /* letter */
159 };
160
161
162 /* Do the actions required to initialize internal data structures used
163    in tree-ssa optimization passes.  */
164
165 static void
166 execute_init_datastructures (void)
167 {
168   /* Allocate hash tables, arrays and other structures.  */
169   init_tree_ssa ();
170 }
171
172 static struct tree_opt_pass pass_init_datastructures =
173 {
174   NULL,                                 /* name */
175   NULL,                                 /* gate */
176   execute_init_datastructures,          /* execute */
177   NULL,                                 /* sub */
178   NULL,                                 /* next */
179   0,                                    /* static_pass_number */
180   0,                                    /* tv_id */
181   PROP_cfg,                             /* properties_required */
182   0,                                    /* properties_provided */
183   0,                                    /* properties_destroyed */
184   0,                                    /* todo_flags_start */
185   0,                                    /* todo_flags_finish */
186   0                                     /* letter */
187 };
188
189 /* Iterate over the pass tree allocating dump file numbers.  We want
190    to do this depth first, and independent of whether the pass is
191    enabled or not.  */
192
193 static void
194 register_one_dump_file (struct tree_opt_pass *pass, bool ipa, int n)
195 {
196   char *dot_name, *flag_name, *glob_name;
197   char num[10];
198
199   /* See below in next_pass_1.  */
200   num[0] = '\0';
201   if (pass->static_pass_number != -1)
202     sprintf (num, "%d", ((int) pass->static_pass_number < 0
203                          ? 1 : pass->static_pass_number));
204
205   dot_name = concat (".", pass->name, num, NULL);
206   if (ipa)
207     {
208       flag_name = concat ("ipa-", pass->name, num, NULL);
209       glob_name = concat ("ipa-", pass->name, NULL);
210       /* First IPA dump is cgraph that is dumped via separate channels.  */
211       pass->static_pass_number = dump_register (dot_name, flag_name, glob_name,
212                                                 TDF_IPA, n + 1, 0);
213     }
214   else if (pass->properties_provided & PROP_trees)
215     {
216       flag_name = concat ("tree-", pass->name, num, NULL);
217       glob_name = concat ("tree-", pass->name, NULL);
218       pass->static_pass_number = dump_register (dot_name, flag_name, glob_name,
219                                                 TDF_TREE, n + TDI_tree_all, 0);
220     }
221   else
222     {
223       flag_name = concat ("rtl-", pass->name, num, NULL);
224       glob_name = concat ("rtl-", pass->name, NULL);
225       pass->static_pass_number = dump_register (dot_name, flag_name, glob_name,
226                                                 TDF_RTL, n, pass->letter);
227     }
228 }
229
230 static int 
231 register_dump_files (struct tree_opt_pass *pass, bool ipa, int properties)
232 {
233   static int n = 0;
234   do
235     {
236       int new_properties;
237       int pass_number;
238
239       pass->properties_required = properties;
240       new_properties =
241         (properties | pass->properties_provided) & ~pass->properties_destroyed;
242
243       /* Reset the counter when we reach RTL-based passes.  */
244       if ((pass->properties_provided ^ pass->properties_required) & PROP_rtl)
245         n = 0;
246
247       pass_number = n;
248       if (pass->name)
249         n++;
250
251       if (pass->sub)
252         new_properties = register_dump_files (pass->sub, ipa, new_properties);
253
254       /* If we have a gate, combine the properties that we could have with
255          and without the pass being examined.  */
256       if (pass->gate)
257         properties &= new_properties;
258       else
259         properties = new_properties;
260
261       pass->properties_provided = properties;
262       if (pass->name)
263         register_one_dump_file (pass, ipa, pass_number);
264
265       pass = pass->next;
266     }
267   while (pass);
268
269   return properties;
270 }
271
272 /* Add a pass to the pass list. Duplicate the pass if it's already
273    in the list.  */
274
275 static struct tree_opt_pass **
276 next_pass_1 (struct tree_opt_pass **list, struct tree_opt_pass *pass)
277 {
278
279   /* A nonzero static_pass_number indicates that the
280      pass is already in the list.  */
281   if (pass->static_pass_number)
282     {
283       struct tree_opt_pass *new;
284
285       new = xmalloc (sizeof (*new));
286       memcpy (new, pass, sizeof (*new));
287
288       /* Indicate to register_dump_files that this pass has duplicates,
289          and so it should rename the dump file.  The first instance will
290          be -1, and be number of duplicates = -static_pass_number - 1.
291          Subsequent instances will be > 0 and just the duplicate number.  */
292       if (pass->name)
293         {
294           pass->static_pass_number -= 1;
295           new->static_pass_number = -pass->static_pass_number;
296         }
297       
298       *list = new;
299     }
300   else
301     {
302       pass->static_pass_number = -1;
303       *list = pass;
304     }  
305   
306   return &(*list)->next;
307           
308 }
309
310 /* Construct the pass tree.  */
311
312 void
313 init_tree_optimization_passes (void)
314 {
315   struct tree_opt_pass **p;
316
317 #define NEXT_PASS(PASS)  (p = next_pass_1 (p, &PASS))
318   /* Intraprocedural optimization passes.  */
319   p = &all_ipa_passes;
320   NEXT_PASS (pass_ipa_inline);
321   *p = NULL;
322
323   p = &all_passes;
324   NEXT_PASS (pass_remove_useless_stmts);
325   NEXT_PASS (pass_mudflap_1);
326   NEXT_PASS (pass_lower_cf);
327   NEXT_PASS (pass_lower_eh);
328   NEXT_PASS (pass_build_cfg);
329   NEXT_PASS (pass_pre_expand);
330   NEXT_PASS (pass_warn_function_return);
331   NEXT_PASS (pass_tree_profile);
332   NEXT_PASS (pass_init_datastructures);
333   NEXT_PASS (pass_all_optimizations);
334   NEXT_PASS (pass_warn_function_noreturn);
335   NEXT_PASS (pass_mudflap_2);
336   NEXT_PASS (pass_free_datastructures);
337   NEXT_PASS (pass_expand);
338   NEXT_PASS (pass_rest_of_compilation);
339   *p = NULL;
340
341   p = &pass_all_optimizations.sub;
342   NEXT_PASS (pass_referenced_vars);
343   NEXT_PASS (pass_create_structure_vars);
344   NEXT_PASS (pass_build_ssa);
345   NEXT_PASS (pass_may_alias);
346   NEXT_PASS (pass_rename_ssa_copies);
347   NEXT_PASS (pass_early_warn_uninitialized);
348
349   /* Initial scalar cleanups.  */
350   NEXT_PASS (pass_ccp);
351   NEXT_PASS (pass_fre);
352   NEXT_PASS (pass_dce);
353   NEXT_PASS (pass_forwprop);
354   NEXT_PASS (pass_vrp);
355   NEXT_PASS (pass_copy_prop);
356   NEXT_PASS (pass_dce);
357   NEXT_PASS (pass_merge_phi);
358   NEXT_PASS (pass_dominator);
359
360   NEXT_PASS (pass_phiopt);
361   NEXT_PASS (pass_may_alias);
362   NEXT_PASS (pass_tail_recursion);
363   NEXT_PASS (pass_profile);
364   NEXT_PASS (pass_ch);
365   NEXT_PASS (pass_stdarg);
366   NEXT_PASS (pass_sra);
367   /* FIXME: SRA may generate arbitrary gimple code, exposing new
368      aliased and call-clobbered variables.  As mentioned below,
369      pass_may_alias should be a TODO item.  */
370   NEXT_PASS (pass_may_alias);
371   NEXT_PASS (pass_rename_ssa_copies);
372   NEXT_PASS (pass_dominator);
373   NEXT_PASS (pass_copy_prop);
374   NEXT_PASS (pass_dce);
375   NEXT_PASS (pass_dse);
376   NEXT_PASS (pass_may_alias);
377   NEXT_PASS (pass_forwprop);
378   NEXT_PASS (pass_phiopt);
379   NEXT_PASS (pass_store_ccp);
380   NEXT_PASS (pass_store_copy_prop);
381   NEXT_PASS (pass_fold_builtins);
382   /* FIXME: May alias should a TODO but for 4.0.0,
383      we add may_alias right after fold builtins
384      which can create arbitrary GIMPLE.  */
385   NEXT_PASS (pass_may_alias);
386   NEXT_PASS (pass_cse_reciprocals);
387   NEXT_PASS (pass_split_crit_edges);
388   NEXT_PASS (pass_pre);
389   NEXT_PASS (pass_sink_code);
390   NEXT_PASS (pass_loop);
391   NEXT_PASS (pass_dominator);
392   NEXT_PASS (pass_copy_prop);
393   NEXT_PASS (pass_cd_dce);
394   /* FIXME: If DCE is not run before checking for uninitialized uses,
395      we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
396      However, this also causes us to misdiagnose cases that should be
397      real warnings (e.g., testsuite/gcc.dg/pr18501.c).
398      
399      To fix the false positives in uninit-5.c, we would have to
400      account for the predicates protecting the set and the use of each
401      variable.  Using a representation like Gated Single Assignment
402      may help.  */
403   NEXT_PASS (pass_late_warn_uninitialized);
404   NEXT_PASS (pass_dse);
405   NEXT_PASS (pass_forwprop);
406   NEXT_PASS (pass_phiopt);
407   NEXT_PASS (pass_tail_calls);
408   NEXT_PASS (pass_rename_ssa_copies);
409   NEXT_PASS (pass_uncprop);
410   NEXT_PASS (pass_del_ssa);
411   NEXT_PASS (pass_nrv);
412   NEXT_PASS (pass_remove_useless_vars);
413   NEXT_PASS (pass_mark_used_blocks);
414   NEXT_PASS (pass_cleanup_cfg_post_optimizing);
415   *p = NULL;
416
417   p = &pass_loop.sub;
418   NEXT_PASS (pass_loop_init);
419   NEXT_PASS (pass_copy_prop);
420   NEXT_PASS (pass_lim);
421   NEXT_PASS (pass_unswitch);
422   NEXT_PASS (pass_record_bounds);
423   NEXT_PASS (pass_linear_transform);
424   NEXT_PASS (pass_iv_canon);
425   NEXT_PASS (pass_if_conversion);
426   NEXT_PASS (pass_vectorize);
427   NEXT_PASS (pass_lower_vector_ssa);
428   NEXT_PASS (pass_complete_unroll);
429   NEXT_PASS (pass_iv_optimize);
430   NEXT_PASS (pass_loop_done);
431   *p = NULL;
432
433 #undef NEXT_PASS
434
435   register_dump_files (all_passes, false, PROP_gimple_any
436                                           | PROP_gimple_lcf
437                                           | PROP_gimple_leh
438                                           | PROP_cfg);
439   register_dump_files (all_ipa_passes, true, PROP_gimple_any
440                                              | PROP_gimple_lcf
441                                              | PROP_gimple_leh
442                                              | PROP_cfg);
443 }
444
445 static unsigned int last_verified;
446
447 static void
448 execute_todo (struct tree_opt_pass *pass, unsigned int flags, bool use_required)
449 {
450   int properties 
451     = use_required ? pass->properties_required : pass->properties_provided;
452
453 #if defined ENABLE_CHECKING
454   if (need_ssa_update_p ())
455     gcc_assert (flags & TODO_update_ssa_any);
456 #endif
457
458   if (flags & TODO_update_ssa_any)
459     {
460       unsigned update_flags = flags & TODO_update_ssa_any;
461       update_ssa (update_flags);
462     }
463
464   if (flags & TODO_cleanup_cfg)
465     {
466       if (current_loops)
467         cleanup_tree_cfg_loop ();
468       else
469         cleanup_tree_cfg ();
470     }
471
472   if ((flags & TODO_dump_func)
473       && dump_file && current_function_decl)
474     {
475       if (properties & PROP_trees)
476         dump_function_to_file (current_function_decl,
477                                dump_file, dump_flags);
478       else if (properties & PROP_cfg)
479         print_rtl_with_bb (dump_file, get_insns ());
480       else
481         print_rtl (dump_file, get_insns ());
482
483       /* Flush the file.  If verification fails, we won't be able to
484          close the file before dieing.  */
485       fflush (dump_file);
486     }
487   if ((flags & TODO_dump_cgraph)
488       && dump_file && !current_function_decl)
489     {
490       dump_cgraph (dump_file);
491       /* Flush the file.  If verification fails, we won't be able to
492          close the file before aborting.  */
493       fflush (dump_file);
494     }
495
496   if (flags & TODO_ggc_collect)
497     {
498       ggc_collect ();
499     }
500
501 #if defined ENABLE_CHECKING
502   if ((pass->properties_required & PROP_ssa)
503       && !(pass->properties_destroyed & PROP_ssa))
504     verify_ssa (true);
505   if (flags & TODO_verify_flow)
506     verify_flow_info ();
507   if (flags & TODO_verify_stmts)
508     verify_stmts ();
509   if (flags & TODO_verify_loops)
510     verify_loop_closed_ssa ();
511 #endif
512 }
513
514 static bool
515 execute_one_pass (struct tree_opt_pass *pass)
516 {
517   unsigned int todo; 
518
519   /* See if we're supposed to run this pass.  */
520   if (pass->gate && !pass->gate ())
521     return false;
522
523   /* Note that the folders should only create gimple expressions.
524      This is a hack until the new folder is ready.  */
525   in_gimple_form = (pass->properties_provided & PROP_trees) != 0;
526
527   /* Run pre-pass verification.  */
528   todo = pass->todo_flags_start & ~last_verified;
529   if (todo)
530     execute_todo (pass, todo, true);
531
532   /* If a dump file name is present, open it if enabled.  */
533   if (pass->static_pass_number != -1)
534     {
535       bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
536       dump_file_name = get_dump_file_name (pass->static_pass_number);
537       dump_file = dump_begin (pass->static_pass_number, &dump_flags);
538       if (dump_file && current_function_decl)
539         {
540           const char *dname, *aname;
541           dname = lang_hooks.decl_printable_name (current_function_decl, 2);
542           aname = (IDENTIFIER_POINTER
543                    (DECL_ASSEMBLER_NAME (current_function_decl)));
544           fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname,
545              cfun->function_frequency == FUNCTION_FREQUENCY_HOT
546              ? " (hot)"
547              : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
548              ? " (unlikely executed)"
549              : "");
550         }
551
552       if (initializing_dump
553           && graph_dump_format != no_graph
554           && (pass->properties_provided & (PROP_cfg | PROP_rtl))
555               == (PROP_cfg | PROP_rtl))
556         clean_graph_dump_file (dump_file_name);
557     }
558
559   /* If a timevar is present, start it.  */
560   if (pass->tv_id)
561     timevar_push (pass->tv_id);
562
563   /* Do it!  */
564   if (pass->execute)
565     pass->execute ();
566
567   /* Stop timevar.  */
568   if (pass->tv_id)
569     timevar_pop (pass->tv_id);
570
571   if (dump_file
572       && (pass->properties_provided & (PROP_cfg | PROP_rtl))
573           == (PROP_cfg | PROP_rtl))
574     print_rtl_with_bb (dump_file, get_insns ());
575
576   /* Run post-pass cleanup and verification.  */
577   todo = pass->todo_flags_finish;
578   last_verified = todo & TODO_verify_all;
579   if (todo)
580     execute_todo (pass, todo, false);
581
582   /* Flush and close dump file.  */
583   if (dump_file_name)
584     {
585       free ((char *) dump_file_name);
586       dump_file_name = NULL;
587     }
588   if (dump_file)
589     {
590       dump_end (pass->static_pass_number, dump_file);
591       dump_file = NULL;
592     }
593
594   return true;
595 }
596
597 static void
598 execute_pass_list (struct tree_opt_pass *pass)
599 {
600   do
601     {
602       if (execute_one_pass (pass) && pass->sub)
603         execute_pass_list (pass->sub);
604       pass = pass->next;
605     }
606   while (pass);
607 }
608
609 /* Execute all IPA passes.  */
610 void
611 ipa_passes (void)
612 {
613    execute_pass_list (all_ipa_passes);
614 }
615 \f
616
617 /* Update recursively all inlined_to pointers of functions
618    inlined into NODE to INLINED_TO.  */
619 static void
620 update_inlined_to_pointers (struct cgraph_node *node,
621                             struct cgraph_node *inlined_to)
622 {
623   struct cgraph_edge *e;
624   for (e = node->callees; e; e = e->next_callee)
625     {
626       if (e->callee->global.inlined_to)
627         {
628           e->callee->global.inlined_to = inlined_to;
629           update_inlined_to_pointers (e->callee, inlined_to);
630         }
631     }
632 }
633
634 \f
635 /* For functions-as-trees languages, this performs all optimization and
636    compilation for FNDECL.  */
637
638 void
639 tree_rest_of_compilation (tree fndecl)
640 {
641   location_t saved_loc;
642   struct cgraph_node *saved_node = NULL, *node;
643
644   timevar_push (TV_EXPAND);
645
646   gcc_assert (!flag_unit_at_a_time || cgraph_global_info_ready);
647
648   /* Initialize the RTL code for the function.  */
649   current_function_decl = fndecl;
650   saved_loc = input_location;
651   input_location = DECL_SOURCE_LOCATION (fndecl);
652   init_function_start (fndecl);
653
654   /* Even though we're inside a function body, we still don't want to
655      call expand_expr to calculate the size of a variable-sized array.
656      We haven't necessarily assigned RTL to all variables yet, so it's
657      not safe to try to expand expressions involving them.  */
658   cfun->x_dont_save_pending_sizes_p = 1;
659   cfun->after_inlining = true;
660
661   node = cgraph_node (fndecl);
662
663   /* We might need the body of this function so that we can expand
664      it inline somewhere else.  This means not lowering some constructs
665      such as exception handling.  */
666   if (cgraph_preserve_function_body_p (fndecl))
667     {
668       if (!flag_unit_at_a_time)
669         {
670           struct cgraph_edge *e;
671
672           saved_node = cgraph_clone_node (node);
673           for (e = saved_node->callees; e; e = e->next_callee)
674             if (!e->inline_failed)
675               cgraph_clone_inlined_nodes (e, true);
676         }
677       cfun->saved_static_chain_decl = cfun->static_chain_decl;
678       cfun->saved_tree = save_body (fndecl, &cfun->saved_args,
679                                     &cfun->saved_static_chain_decl);
680     }
681
682   if (flag_inline_trees)
683     {
684       struct cgraph_edge *e;
685       for (e = node->callees; e; e = e->next_callee)
686         if (!e->inline_failed || warn_inline)
687           break;
688       if (e)
689         {
690           timevar_push (TV_INTEGRATION);
691           optimize_inline_calls (fndecl);
692           timevar_pop (TV_INTEGRATION);
693         }
694     }
695   /* We are not going to maintain the cgraph edges up to date.
696      Kill it so it won't confuse us.  */
697   while (node->callees)
698     {
699       /* In non-unit-at-a-time we must mark all referenced functions as needed.
700          */
701       if (node->callees->callee->analyzed && !flag_unit_at_a_time)
702         cgraph_mark_needed_node (node->callees->callee);
703       cgraph_remove_edge (node->callees);
704     }
705
706   /* We are not going to maintain the cgraph edges up to date.
707      Kill it so it won't confuse us.  */
708   cgraph_node_remove_callees (node);
709
710
711   /* Initialize the default bitmap obstack.  */
712   bitmap_obstack_initialize (NULL);
713   bitmap_obstack_initialize (&reg_obstack); /* FIXME, only at RTL generation*/
714   
715   /* Perform all tree transforms and optimizations.  */
716   execute_pass_list (all_passes);
717   
718   bitmap_obstack_release (&reg_obstack);
719
720   /* Release the default bitmap obstack.  */
721   bitmap_obstack_release (NULL);
722   
723   /* Restore original body if still needed.  */
724   if (cfun->saved_tree)
725     {
726       DECL_SAVED_TREE (fndecl) = cfun->saved_tree;
727       DECL_ARGUMENTS (fndecl) = cfun->saved_args;
728       cfun->static_chain_decl = cfun->saved_static_chain_decl;
729
730       /* When not in unit-at-a-time mode, we must preserve out of line copy
731          representing node before inlining.  Restore original outgoing edges
732          using clone we created earlier.  */
733       if (!flag_unit_at_a_time)
734         {
735           struct cgraph_edge *e;
736
737           cgraph_node_remove_callees (node);
738           node->callees = saved_node->callees;
739           saved_node->callees = NULL;
740           update_inlined_to_pointers (node, node);
741           for (e = node->callees; e; e = e->next_callee)
742             e->caller = node;
743           cgraph_remove_node (saved_node);
744         }
745     }
746   else
747     DECL_SAVED_TREE (fndecl) = NULL;
748   cfun = 0;
749
750   /* If requested, warn about function definitions where the function will
751      return a value (usually of some struct or union type) which itself will
752      take up a lot of stack space.  */
753   if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl))
754     {
755       tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
756
757       if (ret_type && TYPE_SIZE_UNIT (ret_type)
758           && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
759           && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
760                                    larger_than_size))
761         {
762           unsigned int size_as_int
763             = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type));
764
765           if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0)
766             warning (0, "%Jsize of return value of %qD is %u bytes",
767                      fndecl, fndecl, size_as_int);
768           else
769             warning (0, "%Jsize of return value of %qD is larger than %wd bytes",
770                      fndecl, fndecl, larger_than_size);
771         }
772     }
773
774   if (!flag_inline_trees)
775     {
776       DECL_SAVED_TREE (fndecl) = NULL;
777       if (DECL_STRUCT_FUNCTION (fndecl) == 0
778           && !cgraph_node (fndecl)->origin)
779         {
780           /* Stop pointing to the local nodes about to be freed.
781              But DECL_INITIAL must remain nonzero so we know this
782              was an actual function definition.
783              For a nested function, this is done in c_pop_function_context.
784              If rest_of_compilation set this to 0, leave it 0.  */
785           if (DECL_INITIAL (fndecl) != 0)
786             DECL_INITIAL (fndecl) = error_mark_node;
787         }
788     }
789
790   input_location = saved_loc;
791
792   ggc_collect ();
793   timevar_pop (TV_EXPAND);
794 }