OSDN Git Service

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