OSDN Git Service

* gcc.dg/builtins-43.c: Use gimple dump instead of generic.
[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_tree_profile);
331   NEXT_PASS (pass_init_datastructures);
332   NEXT_PASS (pass_all_optimizations);
333   NEXT_PASS (pass_warn_function_return);
334   NEXT_PASS (pass_mudflap_2);
335   NEXT_PASS (pass_free_datastructures);
336   NEXT_PASS (pass_expand);
337   NEXT_PASS (pass_rest_of_compilation);
338   *p = NULL;
339
340   p = &pass_all_optimizations.sub;
341   NEXT_PASS (pass_referenced_vars);
342   NEXT_PASS (pass_create_structure_vars);
343   NEXT_PASS (pass_build_ssa);
344   NEXT_PASS (pass_may_alias);
345   NEXT_PASS (pass_rename_ssa_copies);
346   NEXT_PASS (pass_early_warn_uninitialized);
347
348   /* Initial scalar cleanups.  */
349   NEXT_PASS (pass_ccp);
350   NEXT_PASS (pass_fre);
351   NEXT_PASS (pass_dce);
352   NEXT_PASS (pass_forwprop);
353   NEXT_PASS (pass_vrp);
354   NEXT_PASS (pass_copy_prop);
355   NEXT_PASS (pass_dce);
356   NEXT_PASS (pass_dominator);
357
358   NEXT_PASS (pass_merge_phi);
359   NEXT_PASS (pass_phiopt);
360   NEXT_PASS (pass_may_alias);
361   NEXT_PASS (pass_tail_recursion);
362   NEXT_PASS (pass_profile);
363   NEXT_PASS (pass_ch);
364   NEXT_PASS (pass_stdarg);
365   NEXT_PASS (pass_sra);
366   /* FIXME: SRA may generate arbitrary gimple code, exposing new
367      aliased and call-clobbered variables.  As mentioned below,
368      pass_may_alias should be a TODO item.  */
369   NEXT_PASS (pass_may_alias);
370   NEXT_PASS (pass_rename_ssa_copies);
371   NEXT_PASS (pass_dominator);
372   NEXT_PASS (pass_copy_prop);
373   NEXT_PASS (pass_dce);
374   NEXT_PASS (pass_dse);
375   NEXT_PASS (pass_may_alias);
376   NEXT_PASS (pass_forwprop);
377   NEXT_PASS (pass_phiopt);
378   NEXT_PASS (pass_store_ccp);
379   NEXT_PASS (pass_store_copy_prop);
380   NEXT_PASS (pass_fold_builtins);
381   /* FIXME: May alias should a TODO but for 4.0.0,
382      we add may_alias right after fold builtins
383      which can create arbitrary GIMPLE.  */
384   NEXT_PASS (pass_may_alias);
385   NEXT_PASS (pass_split_crit_edges);
386   NEXT_PASS (pass_pre);
387   NEXT_PASS (pass_sink_code);
388   NEXT_PASS (pass_loop);
389   NEXT_PASS (pass_dominator);
390   NEXT_PASS (pass_copy_prop);
391   NEXT_PASS (pass_dce);
392   /* FIXME: If DCE is not run before checking for uninitialized uses,
393      we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
394      However, this also causes us to misdiagnose cases that should be
395      real warnings (e.g., testsuite/gcc.dg/pr18501.c).
396      
397      To fix the false positives in uninit-5.c, we would have to
398      account for the predicates protecting the set and the use of each
399      variable.  Using a representation like Gated Single Assignment
400      may help.  */
401   NEXT_PASS (pass_late_warn_uninitialized);
402   NEXT_PASS (pass_cd_dce);
403   NEXT_PASS (pass_dse);
404   NEXT_PASS (pass_forwprop);
405   NEXT_PASS (pass_phiopt);
406   NEXT_PASS (pass_tail_calls);
407   NEXT_PASS (pass_rename_ssa_copies);
408   NEXT_PASS (pass_uncprop);
409   NEXT_PASS (pass_del_ssa);
410   NEXT_PASS (pass_nrv);
411   NEXT_PASS (pass_remove_useless_vars);
412   NEXT_PASS (pass_mark_used_blocks);
413   NEXT_PASS (pass_cleanup_cfg_post_optimizing);
414   *p = NULL;
415
416   p = &pass_loop.sub;
417   NEXT_PASS (pass_loop_init);
418   NEXT_PASS (pass_copy_prop);
419   NEXT_PASS (pass_lim);
420   NEXT_PASS (pass_unswitch);
421   NEXT_PASS (pass_record_bounds);
422   NEXT_PASS (pass_linear_transform);
423   NEXT_PASS (pass_iv_canon);
424   NEXT_PASS (pass_if_conversion);
425   NEXT_PASS (pass_vectorize);
426   NEXT_PASS (pass_lower_vector_ssa);
427   NEXT_PASS (pass_complete_unroll);
428   NEXT_PASS (pass_iv_optimize);
429   NEXT_PASS (pass_loop_done);
430   *p = NULL;
431
432 #undef NEXT_PASS
433
434   register_dump_files (all_passes, false, PROP_gimple_any
435                                           | PROP_gimple_lcf
436                                           | PROP_gimple_leh
437                                           | PROP_cfg);
438   register_dump_files (all_ipa_passes, true, PROP_gimple_any
439                                              | PROP_gimple_lcf
440                                              | PROP_gimple_leh
441                                              | PROP_cfg);
442 }
443
444 static unsigned int last_verified;
445
446 static void
447 execute_todo (struct tree_opt_pass *pass, unsigned int flags, bool use_required)
448 {
449   int properties 
450     = use_required ? pass->properties_required : pass->properties_provided;
451
452 #if defined ENABLE_CHECKING
453   if (need_ssa_update_p ())
454     gcc_assert (flags & TODO_update_ssa_any);
455 #endif
456
457   if (flags & TODO_update_ssa_any)
458     {
459       unsigned update_flags = flags & TODO_update_ssa_any;
460       update_ssa (update_flags);
461     }
462
463   if (flags & TODO_cleanup_cfg)
464     {
465       if (current_loops)
466         cleanup_tree_cfg_loop ();
467       else
468         cleanup_tree_cfg ();
469     }
470
471   if ((flags & TODO_dump_func)
472       && dump_file && current_function_decl)
473     {
474       if (properties & PROP_trees)
475         dump_function_to_file (current_function_decl,
476                                dump_file, dump_flags);
477       else if (properties & PROP_cfg)
478         print_rtl_with_bb (dump_file, get_insns ());
479       else
480         print_rtl (dump_file, get_insns ());
481
482       /* Flush the file.  If verification fails, we won't be able to
483          close the file before dieing.  */
484       fflush (dump_file);
485     }
486   if ((flags & TODO_dump_cgraph)
487       && dump_file && !current_function_decl)
488     {
489       dump_cgraph (dump_file);
490       /* Flush the file.  If verification fails, we won't be able to
491          close the file before aborting.  */
492       fflush (dump_file);
493     }
494
495   if (flags & TODO_ggc_collect)
496     {
497       ggc_collect ();
498     }
499
500 #if defined ENABLE_CHECKING
501   if ((pass->properties_required & PROP_ssa)
502       && !(pass->properties_destroyed & PROP_ssa))
503     verify_ssa (true);
504   if (flags & TODO_verify_flow)
505     verify_flow_info ();
506   if (flags & TODO_verify_stmts)
507     verify_stmts ();
508   if (flags & TODO_verify_loops)
509     verify_loop_closed_ssa ();
510 #endif
511 }
512
513 static bool
514 execute_one_pass (struct tree_opt_pass *pass)
515 {
516   unsigned int todo; 
517
518   /* See if we're supposed to run this pass.  */
519   if (pass->gate && !pass->gate ())
520     return false;
521
522   /* Note that the folders should only create gimple expressions.
523      This is a hack until the new folder is ready.  */
524   in_gimple_form = (pass->properties_provided & PROP_trees) != 0;
525
526   /* Run pre-pass verification.  */
527   todo = pass->todo_flags_start & ~last_verified;
528   if (todo)
529     execute_todo (pass, todo, true);
530
531   /* If a dump file name is present, open it if enabled.  */
532   if (pass->static_pass_number != -1)
533     {
534       bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
535       dump_file_name = get_dump_file_name (pass->static_pass_number);
536       dump_file = dump_begin (pass->static_pass_number, &dump_flags);
537       if (dump_file && current_function_decl)
538         {
539           const char *dname, *aname;
540           dname = lang_hooks.decl_printable_name (current_function_decl, 2);
541           aname = (IDENTIFIER_POINTER
542                    (DECL_ASSEMBLER_NAME (current_function_decl)));
543           fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname,
544              cfun->function_frequency == FUNCTION_FREQUENCY_HOT
545              ? " (hot)"
546              : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
547              ? " (unlikely executed)"
548              : "");
549         }
550
551       if (initializing_dump
552           && graph_dump_format != no_graph
553           && (pass->properties_provided & (PROP_cfg | PROP_rtl))
554               == (PROP_cfg | PROP_rtl))
555         clean_graph_dump_file (dump_file_name);
556     }
557
558   /* If a timevar is present, start it.  */
559   if (pass->tv_id)
560     timevar_push (pass->tv_id);
561
562   /* Do it!  */
563   if (pass->execute)
564     pass->execute ();
565
566   /* Stop timevar.  */
567   if (pass->tv_id)
568     timevar_pop (pass->tv_id);
569
570   if (dump_file
571       && (pass->properties_provided & (PROP_cfg | PROP_rtl))
572           == (PROP_cfg | PROP_rtl))
573     print_rtl_with_bb (dump_file, get_insns ());
574
575   /* Run post-pass cleanup and verification.  */
576   todo = pass->todo_flags_finish;
577   last_verified = todo & TODO_verify_all;
578   if (todo)
579     execute_todo (pass, todo, false);
580
581   /* Flush and close dump file.  */
582   if (dump_file_name)
583     {
584       free ((char *) dump_file_name);
585       dump_file_name = NULL;
586     }
587   if (dump_file)
588     {
589       dump_end (pass->static_pass_number, dump_file);
590       dump_file = NULL;
591     }
592
593   return true;
594 }
595
596 static void
597 execute_pass_list (struct tree_opt_pass *pass)
598 {
599   do
600     {
601       if (execute_one_pass (pass) && pass->sub)
602         execute_pass_list (pass->sub);
603       pass = pass->next;
604     }
605   while (pass);
606 }
607
608 /* Execute all IPA passes.  */
609 void
610 ipa_passes (void)
611 {
612    execute_pass_list (all_ipa_passes);
613 }
614 \f
615
616 /* Update recursively all inlined_to pointers of functions
617    inlined into NODE to INLINED_TO.  */
618 static void
619 update_inlined_to_pointers (struct cgraph_node *node,
620                             struct cgraph_node *inlined_to)
621 {
622   struct cgraph_edge *e;
623   for (e = node->callees; e; e = e->next_callee)
624     {
625       if (e->callee->global.inlined_to)
626         {
627           e->callee->global.inlined_to = inlined_to;
628           update_inlined_to_pointers (e->callee, inlined_to);
629         }
630     }
631 }
632
633 \f
634 /* For functions-as-trees languages, this performs all optimization and
635    compilation for FNDECL.  */
636
637 void
638 tree_rest_of_compilation (tree fndecl)
639 {
640   location_t saved_loc;
641   struct cgraph_node *saved_node = NULL, *node;
642
643   timevar_push (TV_EXPAND);
644
645   gcc_assert (!flag_unit_at_a_time || cgraph_global_info_ready);
646
647   /* Initialize the RTL code for the function.  */
648   current_function_decl = fndecl;
649   saved_loc = input_location;
650   input_location = DECL_SOURCE_LOCATION (fndecl);
651   init_function_start (fndecl);
652
653   /* Even though we're inside a function body, we still don't want to
654      call expand_expr to calculate the size of a variable-sized array.
655      We haven't necessarily assigned RTL to all variables yet, so it's
656      not safe to try to expand expressions involving them.  */
657   cfun->x_dont_save_pending_sizes_p = 1;
658   cfun->after_inlining = true;
659
660   node = cgraph_node (fndecl);
661
662   /* We might need the body of this function so that we can expand
663      it inline somewhere else.  This means not lowering some constructs
664      such as exception handling.  */
665   if (cgraph_preserve_function_body_p (fndecl))
666     {
667       if (!flag_unit_at_a_time)
668         {
669           struct cgraph_edge *e;
670
671           saved_node = cgraph_clone_node (node);
672           for (e = saved_node->callees; e; e = e->next_callee)
673             if (!e->inline_failed)
674               cgraph_clone_inlined_nodes (e, true);
675         }
676       cfun->saved_static_chain_decl = cfun->static_chain_decl;
677       cfun->saved_tree = save_body (fndecl, &cfun->saved_args,
678                                     &cfun->saved_static_chain_decl);
679     }
680
681   if (flag_inline_trees)
682     {
683       struct cgraph_edge *e;
684       for (e = node->callees; e; e = e->next_callee)
685         if (!e->inline_failed || warn_inline)
686           break;
687       if (e)
688         {
689           timevar_push (TV_INTEGRATION);
690           optimize_inline_calls (fndecl);
691           timevar_pop (TV_INTEGRATION);
692         }
693     }
694   /* We are not going to maintain the cgraph edges up to date.
695      Kill it so it won't confuse us.  */
696   while (node->callees)
697     {
698       /* In non-unit-at-a-time we must mark all referenced functions as needed.
699          */
700       if (node->callees->callee->analyzed && !flag_unit_at_a_time)
701         cgraph_mark_needed_node (node->callees->callee);
702       cgraph_remove_edge (node->callees);
703     }
704
705   /* We are not going to maintain the cgraph edges up to date.
706      Kill it so it won't confuse us.  */
707   cgraph_node_remove_callees (node);
708
709
710   /* Initialize the default bitmap obstack.  */
711   bitmap_obstack_initialize (NULL);
712   bitmap_obstack_initialize (&reg_obstack); /* FIXME, only at RTL generation*/
713   
714   /* Perform all tree transforms and optimizations.  */
715   execute_pass_list (all_passes);
716   
717   bitmap_obstack_release (&reg_obstack);
718
719   /* Release the default bitmap obstack.  */
720   bitmap_obstack_release (NULL);
721   
722   /* Restore original body if still needed.  */
723   if (cfun->saved_tree)
724     {
725       DECL_SAVED_TREE (fndecl) = cfun->saved_tree;
726       DECL_ARGUMENTS (fndecl) = cfun->saved_args;
727       cfun->static_chain_decl = cfun->saved_static_chain_decl;
728
729       /* When not in unit-at-a-time mode, we must preserve out of line copy
730          representing node before inlining.  Restore original outgoing edges
731          using clone we created earlier.  */
732       if (!flag_unit_at_a_time)
733         {
734           struct cgraph_edge *e;
735
736           cgraph_node_remove_callees (node);
737           node->callees = saved_node->callees;
738           saved_node->callees = NULL;
739           update_inlined_to_pointers (node, node);
740           for (e = node->callees; e; e = e->next_callee)
741             e->caller = node;
742           cgraph_remove_node (saved_node);
743         }
744     }
745   else
746     DECL_SAVED_TREE (fndecl) = NULL;
747   cfun = 0;
748
749   /* If requested, warn about function definitions where the function will
750      return a value (usually of some struct or union type) which itself will
751      take up a lot of stack space.  */
752   if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl))
753     {
754       tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
755
756       if (ret_type && TYPE_SIZE_UNIT (ret_type)
757           && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
758           && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
759                                    larger_than_size))
760         {
761           unsigned int size_as_int
762             = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type));
763
764           if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0)
765             warning (0, "%Jsize of return value of %qD is %u bytes",
766                      fndecl, fndecl, size_as_int);
767           else
768             warning (0, "%Jsize of return value of %qD is larger than %wd bytes",
769                      fndecl, fndecl, larger_than_size);
770         }
771     }
772
773   if (!flag_inline_trees)
774     {
775       DECL_SAVED_TREE (fndecl) = NULL;
776       if (DECL_STRUCT_FUNCTION (fndecl) == 0
777           && !cgraph_node (fndecl)->origin)
778         {
779           /* Stop pointing to the local nodes about to be freed.
780              But DECL_INITIAL must remain nonzero so we know this
781              was an actual function definition.
782              For a nested function, this is done in c_pop_function_context.
783              If rest_of_compilation set this to 0, leave it 0.  */
784           if (DECL_INITIAL (fndecl) != 0)
785             DECL_INITIAL (fndecl) = error_mark_node;
786         }
787     }
788
789   input_location = saved_loc;
790
791   ggc_collect ();
792   timevar_pop (TV_EXPAND);
793 }