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>
5 This file is part of GCC.
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)
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.
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. */
24 #include "coretypes.h"
29 #include "hard-reg-set.h"
30 #include "basic-block.h"
33 #include "diagnostic.h"
34 #include "basic-block.h"
36 #include "tree-flow.h"
37 #include "tree-dump.h"
40 #include "langhooks.h"
44 #include "tree-inline.h"
45 #include "tree-mudflap.h"
46 #include "tree-pass.h"
54 /* Global variables used to communicate with passes. */
58 /* The root of the compilation pass tree, once constructed. */
59 static struct tree_opt_pass
*all_passes
, *all_ipa_passes
, * all_lowering_passes
;
61 /* Gate: execute, or not, all of the non-trivial optimizations. */
64 gate_all_optimizations (void)
67 /* Don't bother doing anything if the program has errors. */
68 && !(errorcount
|| sorrycount
));
71 static struct tree_opt_pass pass_all_optimizations
=
74 gate_all_optimizations
, /* gate */
78 0, /* static_pass_number */
80 0, /* properties_required */
81 0, /* properties_provided */
82 0, /* properties_destroyed */
83 0, /* todo_flags_start */
84 0, /* todo_flags_finish */
88 /* Pass: cleanup the CFG just before expanding trees to RTL.
89 This is just a round of label cleanups and case node grouping
90 because after the tree optimizers have run such cleanups may
94 execute_cleanup_cfg_post_optimizing (void)
97 cleanup_dead_labels ();
101 static struct tree_opt_pass pass_cleanup_cfg_post_optimizing
=
103 "final_cleanup", /* name */
105 execute_cleanup_cfg_post_optimizing
, /* execute */
108 0, /* static_pass_number */
110 PROP_cfg
, /* properties_required */
111 0, /* properties_provided */
112 0, /* properties_destroyed */
113 0, /* todo_flags_start */
114 TODO_dump_func
, /* todo_flags_finish */
118 /* Pass: do the actions required to finish with tree-ssa optimization
122 execute_free_datastructures (void)
126 /* ??? This isn't the right place for this. Worse, it got computed
127 more or less at random in various passes. */
128 free_dominance_info (CDI_DOMINATORS
);
130 /* Emit gotos for implicit jumps. */
131 disband_implicit_edges ();
133 /* Remove the ssa structures. Do it here since this includes statement
134 annotations that need to be intact during disband_implicit_edges. */
137 /* Re-chain the statements from the blocks. */
138 chain
= &DECL_SAVED_TREE (current_function_decl
);
139 *chain
= alloc_stmt_list ();
141 /* And get rid of annotations we no longer need. */
142 delete_tree_cfg_annotations ();
145 static struct tree_opt_pass pass_free_datastructures
=
149 execute_free_datastructures
, /* execute */
152 0, /* static_pass_number */
154 PROP_cfg
, /* properties_required */
155 0, /* properties_provided */
156 0, /* properties_destroyed */
157 0, /* todo_flags_start */
158 0, /* todo_flags_finish */
162 /* Pass: fixup_cfg - IPA passes or compilation of earlier functions might've
163 changed some properties - such as marked functions nothrow. Remove now
164 redundant edges and basic blocks. */
167 execute_fixup_cfg (void)
170 block_stmt_iterator bsi
;
175 for (bsi
= bsi_start (bb
); !bsi_end_p (bsi
); bsi_next (&bsi
))
177 tree stmt
= bsi_stmt (bsi
);
178 tree call
= get_call_expr_in (stmt
);
180 if (call
&& call_expr_flags (call
) & (ECF_CONST
| ECF_PURE
))
181 TREE_SIDE_EFFECTS (call
) = 0;
182 if (!tree_could_throw_p (stmt
) && lookup_stmt_eh_region (stmt
))
183 remove_stmt_from_eh_region (stmt
);
185 tree_purge_dead_eh_edges (bb
);
191 static struct tree_opt_pass pass_fixup_cfg
=
195 execute_fixup_cfg
, /* execute */
198 0, /* static_pass_number */
200 PROP_cfg
, /* properties_required */
201 0, /* properties_provided */
202 0, /* properties_destroyed */
203 0, /* todo_flags_start */
204 0, /* todo_flags_finish */
208 /* Do the actions required to initialize internal data structures used
209 in tree-ssa optimization passes. */
212 execute_init_datastructures (void)
214 /* Allocate hash tables, arrays and other structures. */
218 static struct tree_opt_pass pass_init_datastructures
=
222 execute_init_datastructures
, /* execute */
225 0, /* static_pass_number */
227 PROP_cfg
, /* properties_required */
228 0, /* properties_provided */
229 0, /* properties_destroyed */
230 0, /* todo_flags_start */
231 0, /* todo_flags_finish */
235 /* Iterate over the pass tree allocating dump file numbers. We want
236 to do this depth first, and independent of whether the pass is
240 register_one_dump_file (struct tree_opt_pass
*pass
, bool ipa
, int n
)
242 char *dot_name
, *flag_name
, *glob_name
;
245 /* See below in next_pass_1. */
247 if (pass
->static_pass_number
!= -1)
248 sprintf (num
, "%d", ((int) pass
->static_pass_number
< 0
249 ? 1 : pass
->static_pass_number
));
251 dot_name
= concat (".", pass
->name
, num
, NULL
);
254 flag_name
= concat ("ipa-", pass
->name
, num
, NULL
);
255 glob_name
= concat ("ipa-", pass
->name
, NULL
);
256 /* First IPA dump is cgraph that is dumped via separate channels. */
257 pass
->static_pass_number
= dump_register (dot_name
, flag_name
, glob_name
,
260 else if (pass
->properties_provided
& PROP_trees
)
262 flag_name
= concat ("tree-", pass
->name
, num
, NULL
);
263 glob_name
= concat ("tree-", pass
->name
, NULL
);
264 pass
->static_pass_number
= dump_register (dot_name
, flag_name
, glob_name
,
265 TDF_TREE
, n
+ TDI_tree_all
, 0);
269 flag_name
= concat ("rtl-", pass
->name
, num
, NULL
);
270 glob_name
= concat ("rtl-", pass
->name
, NULL
);
271 pass
->static_pass_number
= dump_register (dot_name
, flag_name
, glob_name
,
272 TDF_RTL
, n
, pass
->letter
);
277 register_dump_files (struct tree_opt_pass
*pass
, bool ipa
, int properties
)
285 pass
->properties_required
= properties
;
287 (properties
| pass
->properties_provided
) & ~pass
->properties_destroyed
;
289 /* Reset the counter when we reach RTL-based passes. */
290 if ((pass
->properties_provided
^ pass
->properties_required
) & PROP_rtl
)
298 new_properties
= register_dump_files (pass
->sub
, ipa
, new_properties
);
300 /* If we have a gate, combine the properties that we could have with
301 and without the pass being examined. */
303 properties
&= new_properties
;
305 properties
= new_properties
;
307 pass
->properties_provided
= properties
;
309 register_one_dump_file (pass
, ipa
, pass_number
);
318 /* Add a pass to the pass list. Duplicate the pass if it's already
321 static struct tree_opt_pass
**
322 next_pass_1 (struct tree_opt_pass
**list
, struct tree_opt_pass
*pass
)
325 /* A nonzero static_pass_number indicates that the
326 pass is already in the list. */
327 if (pass
->static_pass_number
)
329 struct tree_opt_pass
*new;
331 new = xmalloc (sizeof (*new));
332 memcpy (new, pass
, sizeof (*new));
334 /* Indicate to register_dump_files that this pass has duplicates,
335 and so it should rename the dump file. The first instance will
336 be -1, and be number of duplicates = -static_pass_number - 1.
337 Subsequent instances will be > 0 and just the duplicate number. */
340 pass
->static_pass_number
-= 1;
341 new->static_pass_number
= -pass
->static_pass_number
;
348 pass
->static_pass_number
= -1;
352 return &(*list
)->next
;
356 /* Construct the pass tree. */
359 init_tree_optimization_passes (void)
361 struct tree_opt_pass
**p
;
363 #define NEXT_PASS(PASS) (p = next_pass_1 (p, &PASS))
364 /* Intraprocedural optimization passes. */
366 NEXT_PASS (pass_ipa_inline
);
369 /* All passes needed to lower the function into shape optimizers can operate
370 on. These passes are performed before interprocedural passes, unlike rest
371 of local passes (all_passes). */
372 p
= &all_lowering_passes
;
373 NEXT_PASS (pass_remove_useless_stmts
);
374 NEXT_PASS (pass_mudflap_1
);
375 NEXT_PASS (pass_lower_cf
);
376 NEXT_PASS (pass_lower_eh
);
377 NEXT_PASS (pass_build_cfg
);
378 NEXT_PASS (pass_lower_complex_O0
);
379 NEXT_PASS (pass_lower_vector
);
380 NEXT_PASS (pass_warn_function_return
);
381 NEXT_PASS (pass_tree_profile
);
385 NEXT_PASS (pass_fixup_cfg
);
386 NEXT_PASS (pass_init_datastructures
);
387 NEXT_PASS (pass_all_optimizations
);
388 NEXT_PASS (pass_warn_function_noreturn
);
389 NEXT_PASS (pass_mudflap_2
);
390 NEXT_PASS (pass_free_datastructures
);
391 NEXT_PASS (pass_expand
);
392 NEXT_PASS (pass_rest_of_compilation
);
395 p
= &pass_all_optimizations
.sub
;
396 NEXT_PASS (pass_referenced_vars
);
397 NEXT_PASS (pass_create_structure_vars
);
398 NEXT_PASS (pass_build_ssa
);
399 NEXT_PASS (pass_may_alias
);
400 NEXT_PASS (pass_rename_ssa_copies
);
401 NEXT_PASS (pass_early_warn_uninitialized
);
403 /* Initial scalar cleanups. */
404 NEXT_PASS (pass_ccp
);
405 NEXT_PASS (pass_fre
);
406 NEXT_PASS (pass_dce
);
407 NEXT_PASS (pass_forwprop
);
408 NEXT_PASS (pass_vrp
);
409 NEXT_PASS (pass_copy_prop
);
410 NEXT_PASS (pass_dce
);
411 NEXT_PASS (pass_merge_phi
);
412 NEXT_PASS (pass_dominator
);
414 NEXT_PASS (pass_phiopt
);
415 NEXT_PASS (pass_may_alias
);
416 NEXT_PASS (pass_tail_recursion
);
417 NEXT_PASS (pass_profile
);
419 NEXT_PASS (pass_stdarg
);
420 NEXT_PASS (pass_lower_complex
);
421 NEXT_PASS (pass_sra
);
422 /* FIXME: SRA may generate arbitrary gimple code, exposing new
423 aliased and call-clobbered variables. As mentioned below,
424 pass_may_alias should be a TODO item. */
425 NEXT_PASS (pass_may_alias
);
426 NEXT_PASS (pass_rename_ssa_copies
);
427 NEXT_PASS (pass_dominator
);
428 NEXT_PASS (pass_copy_prop
);
429 NEXT_PASS (pass_dce
);
430 NEXT_PASS (pass_dse
);
431 NEXT_PASS (pass_may_alias
);
432 NEXT_PASS (pass_forwprop
);
433 NEXT_PASS (pass_phiopt
);
434 NEXT_PASS (pass_store_ccp
);
435 NEXT_PASS (pass_store_copy_prop
);
436 NEXT_PASS (pass_fold_builtins
);
437 /* FIXME: May alias should a TODO but for 4.0.0,
438 we add may_alias right after fold builtins
439 which can create arbitrary GIMPLE. */
440 NEXT_PASS (pass_may_alias
);
441 NEXT_PASS (pass_cse_reciprocals
);
442 NEXT_PASS (pass_split_crit_edges
);
443 NEXT_PASS (pass_reassoc
);
444 NEXT_PASS (pass_pre
);
445 NEXT_PASS (pass_sink_code
);
446 NEXT_PASS (pass_loop
);
447 NEXT_PASS (pass_dominator
);
448 NEXT_PASS (pass_copy_prop
);
449 NEXT_PASS (pass_cd_dce
);
450 /* FIXME: If DCE is not run before checking for uninitialized uses,
451 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
452 However, this also causes us to misdiagnose cases that should be
453 real warnings (e.g., testsuite/gcc.dg/pr18501.c).
455 To fix the false positives in uninit-5.c, we would have to
456 account for the predicates protecting the set and the use of each
457 variable. Using a representation like Gated Single Assignment
459 NEXT_PASS (pass_late_warn_uninitialized
);
460 NEXT_PASS (pass_dse
);
461 NEXT_PASS (pass_forwprop
);
462 NEXT_PASS (pass_phiopt
);
463 NEXT_PASS (pass_tail_calls
);
464 NEXT_PASS (pass_rename_ssa_copies
);
465 NEXT_PASS (pass_uncprop
);
466 NEXT_PASS (pass_del_ssa
);
467 NEXT_PASS (pass_nrv
);
468 NEXT_PASS (pass_remove_useless_vars
);
469 NEXT_PASS (pass_mark_used_blocks
);
470 NEXT_PASS (pass_cleanup_cfg_post_optimizing
);
474 NEXT_PASS (pass_loop_init
);
475 NEXT_PASS (pass_copy_prop
);
476 NEXT_PASS (pass_lim
);
477 NEXT_PASS (pass_unswitch
);
478 NEXT_PASS (pass_scev_cprop
);
479 NEXT_PASS (pass_record_bounds
);
480 NEXT_PASS (pass_linear_transform
);
481 NEXT_PASS (pass_iv_canon
);
482 NEXT_PASS (pass_if_conversion
);
483 NEXT_PASS (pass_vectorize
);
484 /* NEXT_PASS (pass_may_alias) cannot be done again because the
485 vectorizer creates alias relations that are not supported by
487 NEXT_PASS (pass_lower_vector_ssa
);
488 NEXT_PASS (pass_complete_unroll
);
489 NEXT_PASS (pass_iv_optimize
);
490 NEXT_PASS (pass_loop_done
);
495 register_dump_files (all_lowering_passes
, false, PROP_gimple_any
);
496 register_dump_files (all_passes
, false, PROP_gimple_any
500 register_dump_files (all_ipa_passes
, true, PROP_gimple_any
506 static unsigned int last_verified
;
509 execute_todo (struct tree_opt_pass
*pass
, unsigned int flags
, bool use_required
)
512 = use_required
? pass
->properties_required
: pass
->properties_provided
;
514 #if defined ENABLE_CHECKING
515 if (need_ssa_update_p ())
516 gcc_assert (flags
& TODO_update_ssa_any
);
519 if (flags
& TODO_update_ssa_any
)
521 unsigned update_flags
= flags
& TODO_update_ssa_any
;
522 update_ssa (update_flags
);
525 if (flags
& TODO_cleanup_cfg
)
528 cleanup_tree_cfg_loop ();
533 if ((flags
& TODO_dump_func
)
534 && dump_file
&& current_function_decl
)
536 if (properties
& PROP_trees
)
537 dump_function_to_file (current_function_decl
,
538 dump_file
, dump_flags
);
539 else if (properties
& PROP_cfg
)
540 print_rtl_with_bb (dump_file
, get_insns ());
542 print_rtl (dump_file
, get_insns ());
544 /* Flush the file. If verification fails, we won't be able to
545 close the file before dieing. */
548 if ((flags
& TODO_dump_cgraph
)
549 && dump_file
&& !current_function_decl
)
551 dump_cgraph (dump_file
);
552 /* Flush the file. If verification fails, we won't be able to
553 close the file before aborting. */
557 if (flags
& TODO_ggc_collect
)
562 #if defined ENABLE_CHECKING
563 if ((pass
->properties_required
& PROP_ssa
)
564 && !(pass
->properties_destroyed
& PROP_ssa
))
566 if (flags
& TODO_verify_flow
)
568 if (flags
& TODO_verify_stmts
)
570 if (flags
& TODO_verify_loops
)
571 verify_loop_closed_ssa ();
576 execute_one_pass (struct tree_opt_pass
*pass
)
580 /* See if we're supposed to run this pass. */
581 if (pass
->gate
&& !pass
->gate ())
584 /* Note that the folders should only create gimple expressions.
585 This is a hack until the new folder is ready. */
586 in_gimple_form
= (pass
->properties_provided
& PROP_trees
) != 0;
588 /* Run pre-pass verification. */
589 todo
= pass
->todo_flags_start
& ~last_verified
;
591 execute_todo (pass
, todo
, true);
593 /* If a dump file name is present, open it if enabled. */
594 if (pass
->static_pass_number
!= -1)
596 bool initializing_dump
= !dump_initialized_p (pass
->static_pass_number
);
597 dump_file_name
= get_dump_file_name (pass
->static_pass_number
);
598 dump_file
= dump_begin (pass
->static_pass_number
, &dump_flags
);
599 if (dump_file
&& current_function_decl
)
601 const char *dname
, *aname
;
602 dname
= lang_hooks
.decl_printable_name (current_function_decl
, 2);
603 aname
= (IDENTIFIER_POINTER
604 (DECL_ASSEMBLER_NAME (current_function_decl
)));
605 fprintf (dump_file
, "\n;; Function %s (%s)%s\n\n", dname
, aname
,
606 cfun
->function_frequency
== FUNCTION_FREQUENCY_HOT
608 : cfun
->function_frequency
== FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
609 ? " (unlikely executed)"
613 if (initializing_dump
614 && graph_dump_format
!= no_graph
615 && (pass
->properties_provided
& (PROP_cfg
| PROP_rtl
))
616 == (PROP_cfg
| PROP_rtl
))
617 clean_graph_dump_file (dump_file_name
);
620 /* If a timevar is present, start it. */
622 timevar_push (pass
->tv_id
);
630 timevar_pop (pass
->tv_id
);
633 && (pass
->properties_provided
& (PROP_cfg
| PROP_rtl
))
634 == (PROP_cfg
| PROP_rtl
))
635 print_rtl_with_bb (dump_file
, get_insns ());
637 /* Run post-pass cleanup and verification. */
638 todo
= pass
->todo_flags_finish
;
639 last_verified
= todo
& TODO_verify_all
;
641 execute_todo (pass
, todo
, false);
643 /* Flush and close dump file. */
646 free ((char *) dump_file_name
);
647 dump_file_name
= NULL
;
651 dump_end (pass
->static_pass_number
, dump_file
);
659 execute_pass_list (struct tree_opt_pass
*pass
)
663 if (execute_one_pass (pass
) && pass
->sub
)
664 execute_pass_list (pass
->sub
);
671 tree_lowering_passes (tree fn
)
673 tree saved_current_function_decl
= current_function_decl
;
675 current_function_decl
= fn
;
676 push_cfun (DECL_STRUCT_FUNCTION (fn
));
677 tree_register_cfg_hooks ();
678 bitmap_obstack_initialize (NULL
);
679 execute_pass_list (all_lowering_passes
);
680 free_dominance_info (CDI_POST_DOMINATORS
);
682 current_function_decl
= saved_current_function_decl
;
683 bitmap_obstack_release (NULL
);
687 /* Execute all IPA passes. */
691 bitmap_obstack_initialize (NULL
);
692 execute_pass_list (all_ipa_passes
);
693 bitmap_obstack_release (NULL
);
697 /* Update recursively all inlined_to pointers of functions
698 inlined into NODE to INLINED_TO. */
700 update_inlined_to_pointers (struct cgraph_node
*node
,
701 struct cgraph_node
*inlined_to
)
703 struct cgraph_edge
*e
;
704 for (e
= node
->callees
; e
; e
= e
->next_callee
)
706 if (e
->callee
->global
.inlined_to
)
708 e
->callee
->global
.inlined_to
= inlined_to
;
709 update_inlined_to_pointers (e
->callee
, inlined_to
);
715 /* For functions-as-trees languages, this performs all optimization and
716 compilation for FNDECL. */
719 tree_rest_of_compilation (tree fndecl
)
721 location_t saved_loc
;
722 struct cgraph_node
*saved_node
= NULL
, *node
;
724 timevar_push (TV_EXPAND
);
726 gcc_assert (!flag_unit_at_a_time
|| cgraph_global_info_ready
);
728 /* Initialize the RTL code for the function. */
729 current_function_decl
= fndecl
;
730 saved_loc
= input_location
;
731 input_location
= DECL_SOURCE_LOCATION (fndecl
);
732 init_function_start (fndecl
);
734 /* Even though we're inside a function body, we still don't want to
735 call expand_expr to calculate the size of a variable-sized array.
736 We haven't necessarily assigned RTL to all variables yet, so it's
737 not safe to try to expand expressions involving them. */
738 cfun
->x_dont_save_pending_sizes_p
= 1;
739 cfun
->after_inlining
= true;
741 node
= cgraph_node (fndecl
);
743 /* We might need the body of this function so that we can expand
744 it inline somewhere else. This means not lowering some constructs
745 such as exception handling. */
746 if (cgraph_preserve_function_body_p (fndecl
))
748 if (!flag_unit_at_a_time
)
750 struct cgraph_edge
*e
;
752 saved_node
= cgraph_clone_node (node
, node
->count
, 1);
753 for (e
= saved_node
->callees
; e
; e
= e
->next_callee
)
754 if (!e
->inline_failed
)
755 cgraph_clone_inlined_nodes (e
, true);
757 cfun
->saved_static_chain_decl
= cfun
->static_chain_decl
;
758 save_body (fndecl
, &cfun
->saved_args
, &cfun
->saved_static_chain_decl
);
761 if (flag_inline_trees
)
763 struct cgraph_edge
*e
;
764 for (e
= node
->callees
; e
; e
= e
->next_callee
)
765 if (!e
->inline_failed
|| warn_inline
)
769 timevar_push (TV_INTEGRATION
);
770 optimize_inline_calls (fndecl
);
771 timevar_pop (TV_INTEGRATION
);
774 /* We are not going to maintain the cgraph edges up to date.
775 Kill it so it won't confuse us. */
776 while (node
->callees
)
778 /* In non-unit-at-a-time we must mark all referenced functions as needed.
780 if (node
->callees
->callee
->analyzed
&& !flag_unit_at_a_time
)
781 cgraph_mark_needed_node (node
->callees
->callee
);
782 cgraph_remove_edge (node
->callees
);
785 /* We are not going to maintain the cgraph edges up to date.
786 Kill it so it won't confuse us. */
787 cgraph_node_remove_callees (node
);
790 /* Initialize the default bitmap obstack. */
791 bitmap_obstack_initialize (NULL
);
792 bitmap_obstack_initialize (®_obstack
); /* FIXME, only at RTL generation*/
794 tree_register_cfg_hooks ();
795 /* Perform all tree transforms and optimizations. */
796 execute_pass_list (all_passes
);
798 bitmap_obstack_release (®_obstack
);
800 /* Release the default bitmap obstack. */
801 bitmap_obstack_release (NULL
);
803 /* Restore original body if still needed. */
806 DECL_ARGUMENTS (fndecl
) = cfun
->saved_args
;
807 cfun
->cfg
= cfun
->saved_cfg
;
808 cfun
->eh
= cfun
->saved_eh
;
809 cfun
->saved_cfg
= NULL
;
810 cfun
->saved_eh
= NULL
;
811 cfun
->saved_args
= NULL_TREE
;
812 cfun
->static_chain_decl
= cfun
->saved_static_chain_decl
;
813 cfun
->saved_static_chain_decl
= NULL
;
814 /* When not in unit-at-a-time mode, we must preserve out of line copy
815 representing node before inlining. Restore original outgoing edges
816 using clone we created earlier. */
817 if (!flag_unit_at_a_time
)
819 struct cgraph_edge
*e
;
821 node
= cgraph_node (current_function_decl
);
822 cgraph_node_remove_callees (node
);
823 node
->callees
= saved_node
->callees
;
824 saved_node
->callees
= NULL
;
825 update_inlined_to_pointers (node
, node
);
826 for (e
= node
->callees
; e
; e
= e
->next_callee
)
828 cgraph_remove_node (saved_node
);
832 DECL_SAVED_TREE (fndecl
) = NULL
;
835 /* If requested, warn about function definitions where the function will
836 return a value (usually of some struct or union type) which itself will
837 take up a lot of stack space. */
838 if (warn_larger_than
&& !DECL_EXTERNAL (fndecl
) && TREE_TYPE (fndecl
))
840 tree ret_type
= TREE_TYPE (TREE_TYPE (fndecl
));
842 if (ret_type
&& TYPE_SIZE_UNIT (ret_type
)
843 && TREE_CODE (TYPE_SIZE_UNIT (ret_type
)) == INTEGER_CST
844 && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type
),
847 unsigned int size_as_int
848 = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type
));
850 if (compare_tree_int (TYPE_SIZE_UNIT (ret_type
), size_as_int
) == 0)
851 warning (0, "%Jsize of return value of %qD is %u bytes",
852 fndecl
, fndecl
, size_as_int
);
854 warning (0, "%Jsize of return value of %qD is larger than %wd bytes",
855 fndecl
, fndecl
, larger_than_size
);
859 if (!flag_inline_trees
)
861 DECL_SAVED_TREE (fndecl
) = NULL
;
862 if (DECL_STRUCT_FUNCTION (fndecl
) == 0
863 && !cgraph_node (fndecl
)->origin
)
865 /* Stop pointing to the local nodes about to be freed.
866 But DECL_INITIAL must remain nonzero so we know this
867 was an actual function definition.
868 For a nested function, this is done in c_pop_function_context.
869 If rest_of_compilation set this to 0, leave it 0. */
870 if (DECL_INITIAL (fndecl
) != 0)
871 DECL_INITIAL (fndecl
) = error_mark_node
;
875 input_location
= saved_loc
;
878 timevar_pop (TV_EXPAND
);