1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* This is the top level of cc1/c++.
21 It parses command args, opens files, invokes the various passes
22 in the proper order, and counts the time used by each.
23 Error messages and low-level interface to malloc also handled here. */
27 #include "coretypes.h"
36 #include "insn-attr.h"
37 #include "insn-config.h"
38 #include "insn-flags.h"
39 #include "hard-reg-set.h"
46 #include "basic-block.h"
50 #include "diagnostic-core.h"
55 #include "langhooks.h"
57 #include "hosthooks.h"
60 #include "value-prof.h"
61 #include "tree-inline.h"
62 #include "tree-ssa-alias.h"
63 #include "internal-fn.h"
64 #include "gimple-expr.h"
67 #include "gimple-ssa.h"
69 #include "stringpool.h"
70 #include "tree-ssanames.h"
71 #include "tree-ssa-loop-manip.h"
72 #include "tree-into-ssa.h"
75 #include "tree-pass.h"
76 #include "tree-dump.h"
79 #include "lto-streamer.h"
81 #include "ipa-utils.h"
82 #include "tree-pretty-print.h" /* for dump_function_header */
84 #include "pass_manager.h"
85 #include "tree-ssa-live.h" /* For remove_unused_locals. */
86 #include "tree-cfgcleanup.h"
90 /* This is used for debugging. It allows the current pass to printed
91 from anywhere in compilation.
92 The variable current_pass is also used for statistics and plugins. */
93 opt_pass
*current_pass
;
95 static void register_pass_name (opt_pass
*, const char *);
97 /* Most passes are single-instance (within their context) and thus don't
98 need to implement cloning, but passes that support multiple instances
99 *must* provide their own implementation of the clone method.
101 Handle this by providing a default implemenation, but make it a fatal
107 internal_error ("pass %s does not support cloning", name
);
111 opt_pass::gate (function
*)
122 opt_pass::opt_pass (const pass_data
&data
, context
*ctxt
)
126 static_pass_number (0),
133 pass_manager::execute_early_local_passes ()
135 execute_pass_list (pass_early_local_passes_1
->sub
);
139 pass_manager::execute_pass_mode_switching ()
141 return pass_mode_switching_1
->execute ();
145 /* Call from anywhere to find out what pass this is. Useful for
146 printing out debugging information deep inside an service
149 print_current_pass (FILE *file
)
152 fprintf (file
, "current pass = %s (%d)\n",
153 current_pass
->name
, current_pass
->static_pass_number
);
155 fprintf (file
, "no current pass.\n");
159 /* Call from the debugger to get the current pass name. */
163 print_current_pass (stderr
);
168 /* Global variables used to communicate with passes. */
170 bool first_pass_instance
;
173 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
176 This does nothing for local (non-static) variables, unless the
177 variable is a register variable with DECL_ASSEMBLER_NAME set. In
178 that case, or if the variable is not an automatic, it sets up the
179 RTL and outputs any assembler code (label definition, storage
180 allocation and initialization).
182 DECL is the declaration. TOP_LEVEL is nonzero
183 if this declaration is not within a function. */
186 rest_of_decl_compilation (tree decl
,
190 bool finalize
= true;
192 /* We deferred calling assemble_alias so that we could collect
193 other attributes such as visibility. Emit the alias now. */
197 alias
= lookup_attribute ("alias", DECL_ATTRIBUTES (decl
));
200 alias
= TREE_VALUE (TREE_VALUE (alias
));
201 alias
= get_identifier (TREE_STRING_POINTER (alias
));
202 /* A quirk of the initial implementation of aliases required that the
203 user add "extern" to all of them. Which is silly, but now
204 historical. Do note that the symbol is in fact locally defined. */
205 DECL_EXTERNAL (decl
) = 0;
206 TREE_STATIC (decl
) = 1;
207 assemble_alias (decl
, alias
);
212 /* Can't defer this, because it needs to happen before any
213 later function definitions are processed. */
214 if (DECL_ASSEMBLER_NAME_SET_P (decl
) && DECL_REGISTER (decl
))
215 make_decl_rtl (decl
);
217 /* Forward declarations for nested functions are not "external",
218 but we need to treat them as if they were. */
219 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
220 || TREE_CODE (decl
) == FUNCTION_DECL
)
222 timevar_push (TV_VARCONST
);
224 /* Don't output anything when a tentative file-scope definition
225 is seen. But at end of compilation, do output code for them.
227 We do output all variables and rely on
228 callgraph code to defer them except for forward declarations
229 (see gcc.c-torture/compile/920624-1.c) */
231 || !DECL_DEFER_OUTPUT (decl
)
232 || DECL_INITIAL (decl
))
233 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_HAS_VALUE_EXPR_P (decl
))
234 && !DECL_EXTERNAL (decl
))
236 /* When reading LTO unit, we also read varpool, so do not
238 if (in_lto_p
&& !at_end
)
240 else if (finalize
&& TREE_CODE (decl
) != FUNCTION_DECL
)
241 varpool_finalize_decl (decl
);
244 #ifdef ASM_FINISH_DECLARE_OBJECT
245 if (decl
== last_assemble_variable_decl
)
247 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
252 timevar_pop (TV_VARCONST
);
254 else if (TREE_CODE (decl
) == TYPE_DECL
255 /* Like in rest_of_type_compilation, avoid confusing the debug
256 information machinery when there are errors. */
259 timevar_push (TV_SYMOUT
);
260 debug_hooks
->type_decl (decl
, !top_level
);
261 timevar_pop (TV_SYMOUT
);
264 /* Let cgraph know about the existence of variables. */
265 if (in_lto_p
&& !at_end
)
267 else if (TREE_CODE (decl
) == VAR_DECL
&& !DECL_EXTERNAL (decl
)
268 && TREE_STATIC (decl
))
269 varpool_node_for_decl (decl
);
272 /* Called after finishing a record, union or enumeral type. */
275 rest_of_type_compilation (tree type
, int toplev
)
277 /* Avoid confusing the debug information machinery when there are
282 timevar_push (TV_SYMOUT
);
283 debug_hooks
->type_decl (TYPE_STUB_DECL (type
), !toplev
);
284 timevar_pop (TV_SYMOUT
);
291 finish_optimization_passes (void)
294 struct dump_file_info
*dfi
;
296 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
298 timevar_push (TV_DUMP
);
299 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
301 dumps
->dump_start (pass_profile_1
->static_pass_number
, NULL
);
303 dumps
->dump_finish (pass_profile_1
->static_pass_number
);
308 dumps
->dump_start (pass_profile_1
->static_pass_number
, NULL
);
309 print_combine_total_stats ();
310 dumps
->dump_finish (pass_profile_1
->static_pass_number
);
313 /* Do whatever is necessary to finish printing the graphs. */
314 for (i
= TDI_end
; (dfi
= dumps
->get_dump_file_info (i
)) != NULL
; ++i
)
315 if (dumps
->dump_initialized_p (i
)
316 && (dfi
->pflags
& TDF_GRAPH
) != 0
317 && (name
= dumps
->get_dump_file_name (i
)) != NULL
)
319 finish_graph_dump_file (name
);
323 timevar_pop (TV_DUMP
);
327 execute_all_early_local_passes (void)
329 /* Once this pass (and its sub-passes) are complete, all functions
330 will be in SSA form. Technically this state change is happening
331 a tad early, since the sub-passes have not yet run, but since
332 none of the sub-passes are IPA passes and do not create new
333 functions, this is ok. We're setting this value for the benefit
334 of IPA passes that follow. */
335 if (cgraph_state
< CGRAPH_STATE_IPA_SSA
)
336 cgraph_state
= CGRAPH_STATE_IPA_SSA
;
342 const pass_data pass_data_early_local_passes
=
344 SIMPLE_IPA_PASS
, /* type */
345 "early_local_cleanups", /* name */
346 OPTGROUP_NONE
, /* optinfo_flags */
347 true, /* has_execute */
348 TV_EARLY_LOCAL
, /* tv_id */
349 0, /* properties_required */
350 0, /* properties_provided */
351 0, /* properties_destroyed */
352 0, /* todo_flags_start */
353 TODO_remove_functions
, /* todo_flags_finish */
356 class pass_early_local_passes
: public simple_ipa_opt_pass
359 pass_early_local_passes (gcc::context
*ctxt
)
360 : simple_ipa_opt_pass (pass_data_early_local_passes
, ctxt
)
363 /* opt_pass methods: */
364 virtual bool gate (function
*)
366 /* Don't bother doing anything if the program has errors. */
367 return (!seen_error () && !in_lto_p
);
370 unsigned int execute () { return execute_all_early_local_passes (); }
372 }; // class pass_early_local_passes
376 simple_ipa_opt_pass
*
377 make_pass_early_local_passes (gcc::context
*ctxt
)
379 return new pass_early_local_passes (ctxt
);
384 const pass_data pass_data_all_early_optimizations
=
386 GIMPLE_PASS
, /* type */
387 "early_optimizations", /* name */
388 OPTGROUP_NONE
, /* optinfo_flags */
389 false, /* has_execute */
391 0, /* properties_required */
392 0, /* properties_provided */
393 0, /* properties_destroyed */
394 0, /* todo_flags_start */
395 0, /* todo_flags_finish */
398 class pass_all_early_optimizations
: public gimple_opt_pass
401 pass_all_early_optimizations (gcc::context
*ctxt
)
402 : gimple_opt_pass (pass_data_all_early_optimizations
, ctxt
)
405 /* opt_pass methods: */
406 virtual bool gate (function
*)
408 return (optimize
>= 1
409 /* Don't bother doing anything if the program has errors. */
413 }; // class pass_all_early_optimizations
417 static gimple_opt_pass
*
418 make_pass_all_early_optimizations (gcc::context
*ctxt
)
420 return new pass_all_early_optimizations (ctxt
);
425 const pass_data pass_data_all_optimizations
=
427 GIMPLE_PASS
, /* type */
428 "*all_optimizations", /* name */
429 OPTGROUP_NONE
, /* optinfo_flags */
430 false, /* has_execute */
431 TV_OPTIMIZE
, /* tv_id */
432 0, /* properties_required */
433 0, /* properties_provided */
434 0, /* properties_destroyed */
435 0, /* todo_flags_start */
436 0, /* todo_flags_finish */
439 class pass_all_optimizations
: public gimple_opt_pass
442 pass_all_optimizations (gcc::context
*ctxt
)
443 : gimple_opt_pass (pass_data_all_optimizations
, ctxt
)
446 /* opt_pass methods: */
447 virtual bool gate (function
*) { return optimize
>= 1 && !optimize_debug
; }
449 }; // class pass_all_optimizations
453 static gimple_opt_pass
*
454 make_pass_all_optimizations (gcc::context
*ctxt
)
456 return new pass_all_optimizations (ctxt
);
461 const pass_data pass_data_all_optimizations_g
=
463 GIMPLE_PASS
, /* type */
464 "*all_optimizations_g", /* name */
465 OPTGROUP_NONE
, /* optinfo_flags */
466 false, /* has_execute */
467 TV_OPTIMIZE
, /* tv_id */
468 0, /* properties_required */
469 0, /* properties_provided */
470 0, /* properties_destroyed */
471 0, /* todo_flags_start */
472 0, /* todo_flags_finish */
475 class pass_all_optimizations_g
: public gimple_opt_pass
478 pass_all_optimizations_g (gcc::context
*ctxt
)
479 : gimple_opt_pass (pass_data_all_optimizations_g
, ctxt
)
482 /* opt_pass methods: */
483 virtual bool gate (function
*) { return optimize
>= 1 && optimize_debug
; }
485 }; // class pass_all_optimizations_g
489 static gimple_opt_pass
*
490 make_pass_all_optimizations_g (gcc::context
*ctxt
)
492 return new pass_all_optimizations_g (ctxt
);
497 const pass_data pass_data_rest_of_compilation
=
500 "*rest_of_compilation", /* name */
501 OPTGROUP_NONE
, /* optinfo_flags */
502 false, /* has_execute */
503 TV_REST_OF_COMPILATION
, /* tv_id */
504 PROP_rtl
, /* properties_required */
505 0, /* properties_provided */
506 0, /* properties_destroyed */
507 0, /* todo_flags_start */
508 0, /* todo_flags_finish */
511 class pass_rest_of_compilation
: public rtl_opt_pass
514 pass_rest_of_compilation (gcc::context
*ctxt
)
515 : rtl_opt_pass (pass_data_rest_of_compilation
, ctxt
)
518 /* opt_pass methods: */
519 virtual bool gate (function
*)
521 /* Early return if there were errors. We can run afoul of our
522 consistency checks, and there's not really much point in fixing them. */
523 return !(rtl_dump_and_exit
|| flag_syntax_only
|| seen_error ());
526 }; // class pass_rest_of_compilation
530 static rtl_opt_pass
*
531 make_pass_rest_of_compilation (gcc::context
*ctxt
)
533 return new pass_rest_of_compilation (ctxt
);
538 const pass_data pass_data_postreload
=
541 "*all-postreload", /* name */
542 OPTGROUP_NONE
, /* optinfo_flags */
543 false, /* has_execute */
544 TV_POSTRELOAD
, /* tv_id */
545 PROP_rtl
, /* properties_required */
546 0, /* properties_provided */
547 0, /* properties_destroyed */
548 0, /* todo_flags_start */
549 TODO_verify_rtl_sharing
, /* todo_flags_finish */
552 class pass_postreload
: public rtl_opt_pass
555 pass_postreload (gcc::context
*ctxt
)
556 : rtl_opt_pass (pass_data_postreload
, ctxt
)
559 /* opt_pass methods: */
560 virtual bool gate (function
*) { return reload_completed
; }
562 }; // class pass_postreload
566 static rtl_opt_pass
*
567 make_pass_postreload (gcc::context
*ctxt
)
569 return new pass_postreload (ctxt
);
574 /* Set the static pass number of pass PASS to ID and record that
575 in the mapping from static pass number to pass. */
579 set_pass_for_id (int id
, opt_pass
*pass
)
581 pass
->static_pass_number
= id
;
582 if (passes_by_id_size
<= id
)
584 passes_by_id
= XRESIZEVEC (opt_pass
*, passes_by_id
, id
+ 1);
585 memset (passes_by_id
+ passes_by_id_size
, 0,
586 (id
+ 1 - passes_by_id_size
) * sizeof (void *));
587 passes_by_id_size
= id
+ 1;
589 passes_by_id
[id
] = pass
;
592 /* Return the pass with the static pass number ID. */
595 pass_manager::get_pass_for_id (int id
) const
597 if (id
>= passes_by_id_size
)
599 return passes_by_id
[id
];
602 /* Iterate over the pass tree allocating dump file numbers. We want
603 to do this depth first, and independent of whether the pass is
607 register_one_dump_file (opt_pass
*pass
)
609 g
->get_passes ()->register_one_dump_file (pass
);
613 pass_manager::register_one_dump_file (opt_pass
*pass
)
615 char *dot_name
, *flag_name
, *glob_name
;
616 const char *name
, *full_name
, *prefix
;
619 int optgroup_flags
= OPTGROUP_NONE
;
620 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
622 /* See below in next_pass_1. */
624 if (pass
->static_pass_number
!= -1)
625 sprintf (num
, "%d", ((int) pass
->static_pass_number
< 0
626 ? 1 : pass
->static_pass_number
));
628 /* The name is both used to identify the pass for the purposes of plugins,
629 and to specify dump file name and option.
630 The latter two might want something short which is not quite unique; for
631 that reason, we may have a disambiguating prefix, followed by a space
632 to mark the start of the following dump file name / option string. */
633 name
= strchr (pass
->name
, ' ');
634 name
= name
? name
+ 1 : pass
->name
;
635 dot_name
= concat (".", name
, num
, NULL
);
636 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
640 optgroup_flags
|= OPTGROUP_IPA
;
642 else if (pass
->type
== GIMPLE_PASS
)
653 flag_name
= concat (prefix
, name
, num
, NULL
);
654 glob_name
= concat (prefix
, name
, NULL
);
655 optgroup_flags
|= pass
->optinfo_flags
;
656 /* For any passes that do not have an optgroup set, and which are not
657 IPA passes setup above, set the optgroup to OPTGROUP_OTHER so that
658 any dump messages are emitted properly under -fopt-info(-optall). */
659 if (optgroup_flags
== OPTGROUP_NONE
)
660 optgroup_flags
= OPTGROUP_OTHER
;
661 id
= dumps
->dump_register (dot_name
, flag_name
, glob_name
, flags
,
663 set_pass_for_id (id
, pass
);
664 full_name
= concat (prefix
, pass
->name
, num
, NULL
);
665 register_pass_name (pass
, full_name
);
666 free (CONST_CAST (char *, full_name
));
669 /* Register the dump files for the pass_manager starting at PASS. */
672 pass_manager::register_dump_files (opt_pass
*pass
)
676 if (pass
->name
&& pass
->name
[0] != '*')
677 register_one_dump_file (pass
);
680 register_dump_files (pass
->sub
);
689 const char* unique_name
;
693 /* Helper for pass_registry hash table. */
695 struct pass_registry_hasher
: typed_noop_remove
<pass_registry
>
697 typedef pass_registry value_type
;
698 typedef pass_registry compare_type
;
699 static inline hashval_t
hash (const value_type
*);
700 static inline bool equal (const value_type
*, const compare_type
*);
703 /* Pass registry hash function. */
706 pass_registry_hasher::hash (const value_type
*s
)
708 return htab_hash_string (s
->unique_name
);
711 /* Hash equal function */
714 pass_registry_hasher::equal (const value_type
*s1
, const compare_type
*s2
)
716 return !strcmp (s1
->unique_name
, s2
->unique_name
);
719 static hash_table
<pass_registry_hasher
> name_to_pass_map
;
721 /* Register PASS with NAME. */
724 register_pass_name (opt_pass
*pass
, const char *name
)
726 struct pass_registry
**slot
;
727 struct pass_registry pr
;
729 if (!name_to_pass_map
.is_created ())
730 name_to_pass_map
.create (256);
732 pr
.unique_name
= name
;
733 slot
= name_to_pass_map
.find_slot (&pr
, INSERT
);
736 struct pass_registry
*new_pr
;
738 new_pr
= XCNEW (struct pass_registry
);
739 new_pr
->unique_name
= xstrdup (name
);
744 return; /* Ignore plugin passes. */
747 /* Map from pass id to canonicalized pass name. */
749 typedef const char *char_ptr
;
750 static vec
<char_ptr
> pass_tab
= vNULL
;
752 /* Callback function for traversing NAME_TO_PASS_MAP. */
755 passes_pass_traverse (pass_registry
**p
, void *data ATTRIBUTE_UNUSED
)
757 opt_pass
*pass
= (*p
)->pass
;
759 gcc_assert (pass
->static_pass_number
> 0);
760 gcc_assert (pass_tab
.exists ());
762 pass_tab
[pass
->static_pass_number
] = (*p
)->unique_name
;
767 /* The function traverses NAME_TO_PASS_MAP and creates a pass info
768 table for dumping purpose. */
771 create_pass_tab (void)
773 if (!flag_dump_passes
)
776 pass_tab
.safe_grow_cleared (g
->get_passes ()->passes_by_id_size
+ 1);
777 name_to_pass_map
.traverse
<void *, passes_pass_traverse
> (NULL
);
780 static bool override_gate_status (opt_pass
*, tree
, bool);
782 /* Dump the instantiated name for PASS. IS_ON indicates if PASS
783 is turned on or not. */
786 dump_one_pass (opt_pass
*pass
, int pass_indent
)
788 int indent
= 3 * pass_indent
;
790 bool is_on
, is_really_on
;
792 is_on
= pass
->gate (cfun
);
793 is_really_on
= override_gate_status (pass
, current_function_decl
, is_on
);
795 if (pass
->static_pass_number
<= 0)
798 pn
= pass_tab
[pass
->static_pass_number
];
800 fprintf (stderr
, "%*s%-40s%*s:%s%s\n", indent
, " ", pn
,
801 (15 - indent
< 0 ? 0 : 15 - indent
), " ",
802 is_on
? " ON" : " OFF",
803 ((!is_on
) == (!is_really_on
) ? ""
804 : (is_really_on
? " (FORCED_ON)" : " (FORCED_OFF)")));
807 /* Dump pass list PASS with indentation INDENT. */
810 dump_pass_list (opt_pass
*pass
, int indent
)
814 dump_one_pass (pass
, indent
);
816 dump_pass_list (pass
->sub
, indent
+ 1);
822 /* Dump all optimization passes. */
827 g
->get_passes ()->dump_passes ();
831 pass_manager::dump_passes () const
833 struct cgraph_node
*n
, *node
= NULL
;
837 FOR_EACH_FUNCTION (n
)
838 if (DECL_STRUCT_FUNCTION (n
->decl
))
847 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
849 dump_pass_list (all_lowering_passes
, 1);
850 dump_pass_list (all_small_ipa_passes
, 1);
851 dump_pass_list (all_regular_ipa_passes
, 1);
852 dump_pass_list (all_late_ipa_passes
, 1);
853 dump_pass_list (all_passes
, 1);
859 /* Returns the pass with NAME. */
862 get_pass_by_name (const char *name
)
864 struct pass_registry
**slot
, pr
;
866 pr
.unique_name
= name
;
867 slot
= name_to_pass_map
.find_slot (&pr
, NO_INSERT
);
872 return (*slot
)->pass
;
876 /* Range [start, last]. */
882 const char *assem_name
;
883 struct uid_range
*next
;
886 typedef struct uid_range
*uid_range_p
;
889 static vec
<uid_range_p
>
890 enabled_pass_uid_range_tab
= vNULL
;
891 static vec
<uid_range_p
>
892 disabled_pass_uid_range_tab
= vNULL
;
895 /* Parse option string for -fdisable- and -fenable-
896 The syntax of the options:
899 -fdisable-<pass_name>
901 -fenable-<pass_name>=s1:e1,s2:e2,...
902 -fdisable-<pass_name>=s1:e1,s2:e2,...
906 enable_disable_pass (const char *arg
, bool is_enable
)
909 char *range_str
, *phase_name
;
910 char *argstr
= xstrdup (arg
);
911 vec
<uid_range_p
> *tab
= 0;
913 range_str
= strchr (argstr
,'=');
924 error ("unrecognized option -fenable");
926 error ("unrecognized option -fdisable");
930 pass
= get_pass_by_name (phase_name
);
931 if (!pass
|| pass
->static_pass_number
== -1)
934 error ("unknown pass %s specified in -fenable", phase_name
);
936 error ("unknown pass %s specified in -fdisable", phase_name
);
942 tab
= &enabled_pass_uid_range_tab
;
944 tab
= &disabled_pass_uid_range_tab
;
946 if ((unsigned) pass
->static_pass_number
>= tab
->length ())
947 tab
->safe_grow_cleared (pass
->static_pass_number
+ 1);
952 uid_range_p new_range
= XCNEW (struct uid_range
);
954 new_range
->start
= 0;
955 new_range
->last
= (unsigned)-1;
957 slot
= (*tab
)[pass
->static_pass_number
];
958 new_range
->next
= slot
;
959 (*tab
)[pass
->static_pass_number
] = new_range
;
961 inform (UNKNOWN_LOCATION
, "enable pass %s for functions in the range "
962 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
964 inform (UNKNOWN_LOCATION
, "disable pass %s for functions in the range "
965 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
969 char *next_range
= NULL
;
970 char *one_range
= range_str
;
971 char *end_val
= NULL
;
976 uid_range_p new_range
;
977 char *invalid
= NULL
;
979 char *func_name
= NULL
;
981 next_range
= strchr (one_range
, ',');
988 end_val
= strchr (one_range
, ':');
994 start
= strtol (one_range
, &invalid
, 10);
995 if (*invalid
|| start
< 0)
997 if (end_val
|| (one_range
[0] >= '0'
998 && one_range
[0] <= '9'))
1000 error ("Invalid range %s in option %s",
1002 is_enable
? "-fenable" : "-fdisable");
1006 func_name
= one_range
;
1010 new_range
= XCNEW (struct uid_range
);
1013 new_range
->start
= (unsigned) start
;
1014 new_range
->last
= (unsigned) start
;
1018 new_range
->start
= (unsigned) -1;
1019 new_range
->last
= (unsigned) -1;
1020 new_range
->assem_name
= xstrdup (func_name
);
1025 long last
= strtol (end_val
, &invalid
, 10);
1026 if (*invalid
|| last
< start
)
1028 error ("Invalid range %s in option %s",
1030 is_enable
? "-fenable" : "-fdisable");
1034 new_range
= XCNEW (struct uid_range
);
1035 new_range
->start
= (unsigned) start
;
1036 new_range
->last
= (unsigned) last
;
1039 slot
= (*tab
)[pass
->static_pass_number
];
1040 new_range
->next
= slot
;
1041 (*tab
)[pass
->static_pass_number
] = new_range
;
1044 if (new_range
->assem_name
)
1045 inform (UNKNOWN_LOCATION
,
1046 "enable pass %s for function %s",
1047 phase_name
, new_range
->assem_name
);
1049 inform (UNKNOWN_LOCATION
,
1050 "enable pass %s for functions in the range of [%u, %u]",
1051 phase_name
, new_range
->start
, new_range
->last
);
1055 if (new_range
->assem_name
)
1056 inform (UNKNOWN_LOCATION
,
1057 "disable pass %s for function %s",
1058 phase_name
, new_range
->assem_name
);
1060 inform (UNKNOWN_LOCATION
,
1061 "disable pass %s for functions in the range of [%u, %u]",
1062 phase_name
, new_range
->start
, new_range
->last
);
1065 one_range
= next_range
;
1066 } while (next_range
);
1072 /* Enable pass specified by ARG. */
1075 enable_pass (const char *arg
)
1077 enable_disable_pass (arg
, true);
1080 /* Disable pass specified by ARG. */
1083 disable_pass (const char *arg
)
1085 enable_disable_pass (arg
, false);
1088 /* Returns true if PASS is explicitly enabled/disabled for FUNC. */
1091 is_pass_explicitly_enabled_or_disabled (opt_pass
*pass
,
1093 vec
<uid_range_p
> tab
)
1095 uid_range_p slot
, range
;
1097 const char *aname
= NULL
;
1100 || (unsigned) pass
->static_pass_number
>= tab
.length ()
1101 || pass
->static_pass_number
== -1)
1104 slot
= tab
[pass
->static_pass_number
];
1108 cgraph_uid
= func
? cgraph_get_node (func
)->uid
: 0;
1109 if (func
&& DECL_ASSEMBLER_NAME_SET_P (func
))
1110 aname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func
));
1115 if ((unsigned) cgraph_uid
>= range
->start
1116 && (unsigned) cgraph_uid
<= range
->last
)
1118 if (range
->assem_name
&& aname
1119 && !strcmp (range
->assem_name
, aname
))
1121 range
= range
->next
;
1128 /* Update static_pass_number for passes (and the flag
1129 TODO_mark_first_instance).
1131 Passes are constructed with static_pass_number preinitialized to 0
1133 This field is used in two different ways: initially as instance numbers
1134 of their kind, and then as ids within the entire pass manager.
1136 Within pass_manager::pass_manager:
1138 * In add_pass_instance(), as called by next_pass_1 in
1139 NEXT_PASS in init_optimization_passes
1141 * When the initial instance of a pass within a pass manager is seen,
1142 it is flagged, and its static_pass_number is set to -1
1144 * On subsequent times that it is seen, the static pass number
1145 is decremented each time, so that if there are e.g. 4 dups,
1146 they have static_pass_number -4, 2, 3, 4 respectively (note
1147 how the initial one is negative and gives the count); these
1148 can be thought of as instance numbers of the specific pass
1150 * Within the register_dump_files () traversal, set_pass_for_id()
1151 is called on each pass, using these instance numbers to create
1152 dumpfile switches, and then overwriting them with a pass id,
1153 which are global to the whole pass manager (based on
1154 (TDI_end + current value of extra_dump_files_in_use) ) */
1157 add_pass_instance (opt_pass
*new_pass
, bool track_duplicates
,
1158 opt_pass
*initial_pass
)
1160 /* Are we dealing with the first pass of its kind, or a clone? */
1161 if (new_pass
!= initial_pass
)
1163 /* We're dealing with a clone. */
1164 new_pass
->todo_flags_start
&= ~TODO_mark_first_instance
;
1166 /* Indicate to register_dump_files that this pass has duplicates,
1167 and so it should rename the dump file. The first instance will
1168 be -1, and be number of duplicates = -static_pass_number - 1.
1169 Subsequent instances will be > 0 and just the duplicate number. */
1170 if ((new_pass
->name
&& new_pass
->name
[0] != '*') || track_duplicates
)
1172 initial_pass
->static_pass_number
-= 1;
1173 new_pass
->static_pass_number
= -initial_pass
->static_pass_number
;
1178 /* We're dealing with the first pass of its kind. */
1179 new_pass
->todo_flags_start
|= TODO_mark_first_instance
;
1180 new_pass
->static_pass_number
= -1;
1182 invoke_plugin_callbacks (PLUGIN_NEW_PASS
, new_pass
);
1186 /* Add a pass to the pass list. Duplicate the pass if it's already
1190 next_pass_1 (opt_pass
**list
, opt_pass
*pass
, opt_pass
*initial_pass
)
1192 /* Every pass should have a name so that plugins can refer to them. */
1193 gcc_assert (pass
->name
!= NULL
);
1195 add_pass_instance (pass
, false, initial_pass
);
1198 return &(*list
)->next
;
1201 /* List node for an inserted pass instance. We need to keep track of all
1202 the newly-added pass instances (with 'added_pass_nodes' defined below)
1203 so that we can register their dump files after pass-positioning is finished.
1204 Registering dumping files needs to be post-processed or the
1205 static_pass_number of the opt_pass object would be modified and mess up
1206 the dump file names of future pass instances to be added. */
1208 struct pass_list_node
1211 struct pass_list_node
*next
;
1214 static struct pass_list_node
*added_pass_nodes
= NULL
;
1215 static struct pass_list_node
*prev_added_pass_node
;
1217 /* Insert the pass at the proper position. Return true if the pass
1218 is successfully added.
1220 NEW_PASS_INFO - new pass to be inserted
1221 PASS_LIST - root of the pass list to insert the new pass to */
1224 position_pass (struct register_pass_info
*new_pass_info
, opt_pass
**pass_list
)
1226 opt_pass
*pass
= *pass_list
, *prev_pass
= NULL
;
1227 bool success
= false;
1229 for ( ; pass
; prev_pass
= pass
, pass
= pass
->next
)
1231 /* Check if the current pass is of the same type as the new pass and
1232 matches the name and the instance number of the reference pass. */
1233 if (pass
->type
== new_pass_info
->pass
->type
1235 && !strcmp (pass
->name
, new_pass_info
->reference_pass_name
)
1236 && ((new_pass_info
->ref_pass_instance_number
== 0)
1237 || (new_pass_info
->ref_pass_instance_number
==
1238 pass
->static_pass_number
)
1239 || (new_pass_info
->ref_pass_instance_number
== 1
1240 && pass
->todo_flags_start
& TODO_mark_first_instance
)))
1243 struct pass_list_node
*new_pass_node
;
1245 if (new_pass_info
->ref_pass_instance_number
== 0)
1247 new_pass
= new_pass_info
->pass
->clone ();
1248 add_pass_instance (new_pass
, true, new_pass_info
->pass
);
1252 new_pass
= new_pass_info
->pass
;
1253 add_pass_instance (new_pass
, true, new_pass
);
1256 /* Insert the new pass instance based on the positioning op. */
1257 switch (new_pass_info
->pos_op
)
1259 case PASS_POS_INSERT_AFTER
:
1260 new_pass
->next
= pass
->next
;
1261 pass
->next
= new_pass
;
1263 /* Skip newly inserted pass to avoid repeated
1264 insertions in the case where the new pass and the
1265 existing one have the same name. */
1268 case PASS_POS_INSERT_BEFORE
:
1269 new_pass
->next
= pass
;
1271 prev_pass
->next
= new_pass
;
1273 *pass_list
= new_pass
;
1275 case PASS_POS_REPLACE
:
1276 new_pass
->next
= pass
->next
;
1278 prev_pass
->next
= new_pass
;
1280 *pass_list
= new_pass
;
1281 new_pass
->sub
= pass
->sub
;
1282 new_pass
->tv_id
= pass
->tv_id
;
1286 error ("invalid pass positioning operation");
1290 /* Save the newly added pass (instance) in the added_pass_nodes
1291 list so that we can register its dump file later. Note that
1292 we cannot register the dump file now because doing so will modify
1293 the static_pass_number of the opt_pass object and therefore
1294 mess up the dump file name of future instances. */
1295 new_pass_node
= XCNEW (struct pass_list_node
);
1296 new_pass_node
->pass
= new_pass
;
1297 if (!added_pass_nodes
)
1298 added_pass_nodes
= new_pass_node
;
1300 prev_added_pass_node
->next
= new_pass_node
;
1301 prev_added_pass_node
= new_pass_node
;
1306 if (pass
->sub
&& position_pass (new_pass_info
, &pass
->sub
))
1313 /* Hooks a new pass into the pass lists.
1315 PASS_INFO - pass information that specifies the opt_pass object,
1316 reference pass, instance number, and how to position
1320 register_pass (struct register_pass_info
*pass_info
)
1322 g
->get_passes ()->register_pass (pass_info
);
1326 register_pass (opt_pass
* pass
, pass_positioning_ops pos
,
1327 const char* ref_pass_name
, int ref_pass_inst_number
)
1329 register_pass_info i
;
1331 i
.reference_pass_name
= ref_pass_name
;
1332 i
.ref_pass_instance_number
= ref_pass_inst_number
;
1335 g
->get_passes ()->register_pass (&i
);
1339 pass_manager::register_pass (struct register_pass_info
*pass_info
)
1341 bool all_instances
, success
;
1342 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
1344 /* The checks below could fail in buggy plugins. Existing GCC
1345 passes should never fail these checks, so we mention plugin in
1347 if (!pass_info
->pass
)
1348 fatal_error ("plugin cannot register a missing pass");
1350 if (!pass_info
->pass
->name
)
1351 fatal_error ("plugin cannot register an unnamed pass");
1353 if (!pass_info
->reference_pass_name
)
1355 ("plugin cannot register pass %qs without reference pass name",
1356 pass_info
->pass
->name
);
1358 /* Try to insert the new pass to the pass lists. We need to check
1359 all five lists as the reference pass could be in one (or all) of
1361 all_instances
= pass_info
->ref_pass_instance_number
== 0;
1362 success
= position_pass (pass_info
, &all_lowering_passes
);
1363 if (!success
|| all_instances
)
1364 success
|= position_pass (pass_info
, &all_small_ipa_passes
);
1365 if (!success
|| all_instances
)
1366 success
|= position_pass (pass_info
, &all_regular_ipa_passes
);
1367 if (!success
|| all_instances
)
1368 success
|= position_pass (pass_info
, &all_late_ipa_passes
);
1369 if (!success
|| all_instances
)
1370 success
|= position_pass (pass_info
, &all_passes
);
1373 ("pass %qs not found but is referenced by new pass %qs",
1374 pass_info
->reference_pass_name
, pass_info
->pass
->name
);
1376 /* OK, we have successfully inserted the new pass. We need to register
1377 the dump files for the newly added pass and its duplicates (if any).
1378 Because the registration of plugin/backend passes happens after the
1379 command-line options are parsed, the options that specify single
1380 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
1381 passes. Therefore we currently can only enable dumping of
1382 new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
1383 are specified. While doing so, we also delete the pass_list_node
1384 objects created during pass positioning. */
1385 while (added_pass_nodes
)
1387 struct pass_list_node
*next_node
= added_pass_nodes
->next
;
1388 enum tree_dump_index tdi
;
1389 register_one_dump_file (added_pass_nodes
->pass
);
1390 if (added_pass_nodes
->pass
->type
== SIMPLE_IPA_PASS
1391 || added_pass_nodes
->pass
->type
== IPA_PASS
)
1393 else if (added_pass_nodes
->pass
->type
== GIMPLE_PASS
)
1397 /* Check if dump-all flag is specified. */
1398 if (dumps
->get_dump_file_info (tdi
)->pstate
)
1399 dumps
->get_dump_file_info (added_pass_nodes
->pass
->static_pass_number
)
1400 ->pstate
= dumps
->get_dump_file_info (tdi
)->pstate
;
1401 XDELETE (added_pass_nodes
);
1402 added_pass_nodes
= next_node
;
1406 /* Construct the pass tree. The sequencing of passes is driven by
1407 the cgraph routines:
1409 finalize_compilation_unit ()
1410 for each node N in the cgraph
1411 cgraph_analyze_function (N)
1412 cgraph_lower_function (N) -> all_lowering_passes
1414 If we are optimizing, compile is then invoked:
1417 ipa_passes () -> all_small_ipa_passes
1418 -> Analysis of all_regular_ipa_passes
1419 * possible LTO streaming at copmilation time *
1420 -> Execution of all_regular_ipa_passes
1421 * possible LTO streaming at link time *
1422 -> all_late_ipa_passes
1423 expand_all_functions ()
1424 for each node N in the cgraph
1425 expand_function (N) -> Transformation of all_regular_ipa_passes
1430 pass_manager::operator new (size_t sz
)
1432 /* Ensure that all fields of the pass manager are zero-initialized. */
1433 return xcalloc (1, sz
);
1436 pass_manager::pass_manager (context
*ctxt
)
1437 : all_passes (NULL
), all_small_ipa_passes (NULL
), all_lowering_passes (NULL
),
1438 all_regular_ipa_passes (NULL
),
1439 all_late_ipa_passes (NULL
), passes_by_id (NULL
), passes_by_id_size (0),
1444 /* Initialize the pass_lists array. */
1445 #define DEF_PASS_LIST(LIST) pass_lists[PASS_LIST_NO_##LIST] = &LIST;
1447 #undef DEF_PASS_LIST
1449 /* Build the tree of passes. */
1451 #define INSERT_PASSES_AFTER(PASS) \
1454 #define PUSH_INSERT_PASSES_WITHIN(PASS) \
1456 opt_pass **p = &(PASS ## _1)->sub;
1458 #define POP_INSERT_PASSES() \
1461 #define NEXT_PASS(PASS, NUM) \
1463 gcc_assert (NULL == PASS ## _ ## NUM); \
1465 PASS ## _1 = make_##PASS (m_ctxt); \
1468 gcc_assert (PASS ## _1); \
1469 PASS ## _ ## NUM = PASS ## _1->clone (); \
1471 p = next_pass_1 (p, PASS ## _ ## NUM, PASS ## _1); \
1474 #define TERMINATE_PASS_LIST() \
1477 #include "pass-instances.def"
1479 #undef INSERT_PASSES_AFTER
1480 #undef PUSH_INSERT_PASSES_WITHIN
1481 #undef POP_INSERT_PASSES
1483 #undef TERMINATE_PASS_LIST
1485 /* Register the passes with the tree dump code. */
1486 register_dump_files (all_lowering_passes
);
1487 register_dump_files (all_small_ipa_passes
);
1488 register_dump_files (all_regular_ipa_passes
);
1489 register_dump_files (all_late_ipa_passes
);
1490 register_dump_files (all_passes
);
1493 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1494 function CALLBACK for every function in the call graph. Otherwise,
1495 call CALLBACK on the current function. */
1498 do_per_function (void (*callback
) (void *data
), void *data
)
1500 if (current_function_decl
)
1504 struct cgraph_node
*node
;
1505 FOR_EACH_DEFINED_FUNCTION (node
)
1506 if (node
->analyzed
&& gimple_has_body_p (node
->decl
)
1507 && (!node
->clone_of
|| node
->decl
!= node
->clone_of
->decl
))
1509 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
1513 free_dominance_info (CDI_DOMINATORS
);
1514 free_dominance_info (CDI_POST_DOMINATORS
);
1522 /* Because inlining might remove no-longer reachable nodes, we need to
1523 keep the array visible to garbage collector to avoid reading collected
1526 static GTY ((length ("nnodes"))) cgraph_node_ptr
*order
;
1528 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1529 function CALLBACK for every function in the call graph. Otherwise,
1530 call CALLBACK on the current function.
1531 This function is global so that plugins can use it. */
1533 do_per_function_toporder (void (*callback
) (void *data
), void *data
)
1537 if (current_function_decl
)
1541 gcc_assert (!order
);
1542 order
= ggc_alloc_vec_cgraph_node_ptr (cgraph_n_nodes
);
1543 nnodes
= ipa_reverse_postorder (order
);
1544 for (i
= nnodes
- 1; i
>= 0; i
--)
1545 order
[i
]->process
= 1;
1546 for (i
= nnodes
- 1; i
>= 0; i
--)
1548 struct cgraph_node
*node
= order
[i
];
1550 /* Allow possibly removed nodes to be garbage collected. */
1553 if (cgraph_function_with_gimple_body_p (node
))
1555 cgraph_get_body (node
);
1556 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
1558 free_dominance_info (CDI_DOMINATORS
);
1559 free_dominance_info (CDI_POST_DOMINATORS
);
1570 /* Helper function to perform function body dump. */
1573 execute_function_dump (void *data
)
1575 opt_pass
*pass
= (opt_pass
*)data
;
1577 if (dump_file
&& current_function_decl
)
1579 if (cfun
->curr_properties
& PROP_trees
)
1580 dump_function_to_file (current_function_decl
, dump_file
, dump_flags
);
1582 print_rtl_with_bb (dump_file
, get_insns (), dump_flags
);
1584 /* Flush the file. If verification fails, we won't be able to
1585 close the file before aborting. */
1588 if ((cfun
->curr_properties
& PROP_cfg
)
1589 && (dump_flags
& TDF_GRAPH
))
1591 if (!pass
->graph_dump_initialized
)
1593 clean_graph_dump_file (dump_file_name
);
1594 pass
->graph_dump_initialized
= true;
1596 print_graph_cfg (dump_file_name
, cfun
);
1601 static struct profile_record
*profile_record
;
1603 /* Do profile consistency book-keeping for the pass with static number INDEX.
1604 If SUBPASS is zero, we run _before_ the pass, and if SUBPASS is one, then
1605 we run _after_ the pass. RUN is true if the pass really runs, or FALSE
1606 if we are only book-keeping on passes that may have selectively disabled
1607 themselves on a given function. */
1609 check_profile_consistency (int index
, int subpass
, bool run
)
1611 pass_manager
*passes
= g
->get_passes ();
1614 if (!profile_record
)
1615 profile_record
= XCNEWVEC (struct profile_record
,
1616 passes
->passes_by_id_size
);
1617 gcc_assert (index
< passes
->passes_by_id_size
&& index
>= 0);
1618 gcc_assert (subpass
< 2);
1619 profile_record
[index
].run
|= run
;
1620 account_profile_record (&profile_record
[index
], subpass
);
1623 /* Output profile consistency. */
1626 dump_profile_report (void)
1628 g
->get_passes ()->dump_profile_report ();
1632 pass_manager::dump_profile_report () const
1635 int last_freq_in
= 0, last_count_in
= 0, last_freq_out
= 0, last_count_out
= 0;
1636 gcov_type last_time
= 0, last_size
= 0;
1637 double rel_time_change
, rel_size_change
;
1638 int last_reported
= 0;
1640 if (!profile_record
)
1642 fprintf (stderr
, "\nProfile consistency report:\n\n");
1643 fprintf (stderr
, "Pass name |mismatch in |mismated out|Overall\n");
1644 fprintf (stderr
, " |freq count |freq count |size time\n");
1646 for (i
= 0; i
< passes_by_id_size
; i
++)
1647 for (j
= 0 ; j
< 2; j
++)
1648 if (profile_record
[i
].run
)
1651 rel_time_change
= (profile_record
[i
].time
[j
]
1652 - (double)last_time
) * 100 / (double)last_time
;
1654 rel_time_change
= 0;
1656 rel_size_change
= (profile_record
[i
].size
[j
]
1657 - (double)last_size
) * 100 / (double)last_size
;
1659 rel_size_change
= 0;
1661 if (profile_record
[i
].num_mismatched_freq_in
[j
] != last_freq_in
1662 || profile_record
[i
].num_mismatched_freq_out
[j
] != last_freq_out
1663 || profile_record
[i
].num_mismatched_count_in
[j
] != last_count_in
1664 || profile_record
[i
].num_mismatched_count_out
[j
] != last_count_out
1665 || rel_time_change
|| rel_size_change
)
1668 fprintf (stderr
, "%-20s %s",
1669 passes_by_id
[i
]->name
,
1670 j
? "(after TODO)" : " ");
1671 if (profile_record
[i
].num_mismatched_freq_in
[j
] != last_freq_in
)
1672 fprintf (stderr
, "| %+5i",
1673 profile_record
[i
].num_mismatched_freq_in
[j
]
1676 fprintf (stderr
, "| ");
1677 if (profile_record
[i
].num_mismatched_count_in
[j
] != last_count_in
)
1678 fprintf (stderr
, " %+5i",
1679 profile_record
[i
].num_mismatched_count_in
[j
]
1682 fprintf (stderr
, " ");
1683 if (profile_record
[i
].num_mismatched_freq_out
[j
] != last_freq_out
)
1684 fprintf (stderr
, "| %+5i",
1685 profile_record
[i
].num_mismatched_freq_out
[j
]
1688 fprintf (stderr
, "| ");
1689 if (profile_record
[i
].num_mismatched_count_out
[j
] != last_count_out
)
1690 fprintf (stderr
, " %+5i",
1691 profile_record
[i
].num_mismatched_count_out
[j
]
1694 fprintf (stderr
, " ");
1696 /* Size/time units change across gimple and RTL. */
1697 if (i
== pass_expand_1
->static_pass_number
)
1698 fprintf (stderr
, "|----------");
1701 if (rel_size_change
)
1702 fprintf (stderr
, "| %+8.4f%%", rel_size_change
);
1704 fprintf (stderr
, "| ");
1705 if (rel_time_change
)
1706 fprintf (stderr
, " %+8.4f%%", rel_time_change
);
1708 fprintf (stderr
, "\n");
1709 last_freq_in
= profile_record
[i
].num_mismatched_freq_in
[j
];
1710 last_freq_out
= profile_record
[i
].num_mismatched_freq_out
[j
];
1711 last_count_in
= profile_record
[i
].num_mismatched_count_in
[j
];
1712 last_count_out
= profile_record
[i
].num_mismatched_count_out
[j
];
1714 else if (j
&& last_reported
!= i
)
1717 fprintf (stderr
, "%-20s ------------| | |\n",
1718 passes_by_id
[i
]->name
);
1720 last_time
= profile_record
[i
].time
[j
];
1721 last_size
= profile_record
[i
].size
[j
];
1725 /* Perform all TODO actions that ought to be done on each function. */
1728 execute_function_todo (void *data
)
1730 unsigned int flags
= (size_t)data
;
1731 flags
&= ~cfun
->last_verified
;
1735 /* Always cleanup the CFG before trying to update SSA. */
1736 if (flags
& TODO_cleanup_cfg
)
1738 cleanup_tree_cfg ();
1740 /* When cleanup_tree_cfg merges consecutive blocks, it may
1741 perform some simplistic propagation when removing single
1742 valued PHI nodes. This propagation may, in turn, cause the
1743 SSA form to become out-of-date (see PR 22037). So, even
1744 if the parent pass had not scheduled an SSA update, we may
1745 still need to do one. */
1746 if (!(flags
& TODO_update_ssa_any
) && need_ssa_update_p (cfun
))
1747 flags
|= TODO_update_ssa
;
1750 if (flags
& TODO_update_ssa_any
)
1752 unsigned update_flags
= flags
& TODO_update_ssa_any
;
1753 update_ssa (update_flags
);
1754 cfun
->last_verified
&= ~TODO_verify_ssa
;
1757 if (flag_tree_pta
&& (flags
& TODO_rebuild_alias
))
1758 compute_may_aliases ();
1760 if (optimize
&& (flags
& TODO_update_address_taken
))
1761 execute_update_addresses_taken ();
1763 if (flags
& TODO_remove_unused_locals
)
1764 remove_unused_locals ();
1766 if (flags
& TODO_rebuild_frequencies
)
1767 rebuild_frequencies ();
1769 if (flags
& TODO_rebuild_cgraph_edges
)
1770 rebuild_cgraph_edges ();
1772 /* If we've seen errors do not bother running any verifiers. */
1776 #if defined ENABLE_CHECKING
1777 if (flags
& TODO_verify_ssa
1778 || (current_loops
&& loops_state_satisfies_p (LOOP_CLOSED_SSA
)))
1780 verify_gimple_in_cfg (cfun
);
1783 else if (flags
& TODO_verify_stmts
)
1784 verify_gimple_in_cfg (cfun
);
1785 if (flags
& TODO_verify_flow
)
1786 verify_flow_info ();
1787 if (current_loops
&& loops_state_satisfies_p (LOOP_CLOSED_SSA
))
1788 verify_loop_closed_ssa (false);
1789 if (flags
& TODO_verify_rtl_sharing
)
1790 verify_rtl_sharing ();
1793 cfun
->last_verified
= flags
& TODO_verify_all
;
1796 /* Perform all TODO actions. */
1798 execute_todo (unsigned int flags
)
1800 #if defined ENABLE_CHECKING
1802 && need_ssa_update_p (cfun
))
1803 gcc_assert (flags
& TODO_update_ssa_any
);
1806 timevar_push (TV_TODO
);
1808 /* Inform the pass whether it is the first time it is run. */
1809 first_pass_instance
= (flags
& TODO_mark_first_instance
) != 0;
1811 statistics_fini_pass ();
1814 do_per_function (execute_function_todo
, (void *)(size_t) flags
);
1816 /* Always remove functions just as before inlining: IPA passes might be
1817 interested to see bodies of extern inline functions that are not inlined
1818 to analyze side effects. The full removal is done just at the end
1819 of IPA pass queue. */
1820 if (flags
& TODO_remove_functions
)
1823 symtab_remove_unreachable_nodes (true, dump_file
);
1826 if ((flags
& TODO_dump_symtab
) && dump_file
&& !current_function_decl
)
1829 dump_symtab (dump_file
);
1830 /* Flush the file. If verification fails, we won't be able to
1831 close the file before aborting. */
1835 /* Now that the dumping has been done, we can get rid of the optional
1837 if (flags
& TODO_df_finish
)
1838 df_finish_pass ((flags
& TODO_df_verify
) != 0);
1840 timevar_pop (TV_TODO
);
1843 /* Verify invariants that should hold between passes. This is a place
1844 to put simple sanity checks. */
1847 verify_interpass_invariants (void)
1849 gcc_checking_assert (!fold_deferring_overflow_warnings_p ());
1852 /* Clear the last verified flag. */
1855 clear_last_verified (void *data ATTRIBUTE_UNUSED
)
1857 cfun
->last_verified
= 0;
1860 /* Helper function. Verify that the properties has been turn into the
1861 properties expected by the pass. */
1863 #ifdef ENABLE_CHECKING
1865 verify_curr_properties (void *data
)
1867 unsigned int props
= (size_t)data
;
1868 gcc_assert ((cfun
->curr_properties
& props
) == props
);
1872 /* Initialize pass dump file. */
1873 /* This is non-static so that the plugins can use it. */
1876 pass_init_dump_file (opt_pass
*pass
)
1878 pass
->graph_dump_initialized
= false;
1879 /* If a dump file name is present, open it if enabled. */
1880 if (pass
->static_pass_number
!= -1)
1882 timevar_push (TV_DUMP
);
1883 gcc::dump_manager
*dumps
= g
->get_dumps ();
1884 bool initializing_dump
=
1885 !dumps
->dump_initialized_p (pass
->static_pass_number
);
1886 dump_file_name
= dumps
->get_dump_file_name (pass
->static_pass_number
);
1887 dumps
->dump_start (pass
->static_pass_number
, &dump_flags
);
1888 if (dump_file
&& current_function_decl
)
1889 dump_function_header (dump_file
, current_function_decl
, dump_flags
);
1890 if (initializing_dump
1891 && dump_file
&& (dump_flags
& TDF_GRAPH
)
1892 && cfun
&& (cfun
->curr_properties
& PROP_cfg
))
1894 clean_graph_dump_file (dump_file_name
);
1895 pass
->graph_dump_initialized
= true;
1897 timevar_pop (TV_DUMP
);
1898 return initializing_dump
;
1904 /* Flush PASS dump file. */
1905 /* This is non-static so that plugins can use it. */
1908 pass_fini_dump_file (opt_pass
*pass
)
1910 timevar_push (TV_DUMP
);
1912 /* Flush and close dump file. */
1915 free (CONST_CAST (char *, dump_file_name
));
1916 dump_file_name
= NULL
;
1919 g
->get_dumps ()->dump_finish (pass
->static_pass_number
);
1920 timevar_pop (TV_DUMP
);
1923 /* After executing the pass, apply expected changes to the function
1927 update_properties_after_pass (void *data
)
1929 opt_pass
*pass
= (opt_pass
*) data
;
1930 cfun
->curr_properties
= (cfun
->curr_properties
| pass
->properties_provided
)
1931 & ~pass
->properties_destroyed
;
1934 /* Execute summary generation for all of the passes in IPA_PASS. */
1937 execute_ipa_summary_passes (ipa_opt_pass_d
*ipa_pass
)
1941 opt_pass
*pass
= ipa_pass
;
1943 /* Execute all of the IPA_PASSes in the list. */
1944 if (ipa_pass
->type
== IPA_PASS
1945 && pass
->gate (cfun
)
1946 && ipa_pass
->generate_summary
)
1948 pass_init_dump_file (pass
);
1950 /* If a timevar is present, start it. */
1952 timevar_push (pass
->tv_id
);
1954 ipa_pass
->generate_summary ();
1958 timevar_pop (pass
->tv_id
);
1960 pass_fini_dump_file (pass
);
1962 ipa_pass
= (ipa_opt_pass_d
*)ipa_pass
->next
;
1966 /* Execute IPA_PASS function transform on NODE. */
1969 execute_one_ipa_transform_pass (struct cgraph_node
*node
,
1970 ipa_opt_pass_d
*ipa_pass
)
1972 opt_pass
*pass
= ipa_pass
;
1973 unsigned int todo_after
= 0;
1975 current_pass
= pass
;
1976 if (!ipa_pass
->function_transform
)
1979 /* Note that the folders should only create gimple expressions.
1980 This is a hack until the new folder is ready. */
1981 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
1983 pass_init_dump_file (pass
);
1985 /* Run pre-pass verification. */
1986 execute_todo (ipa_pass
->function_transform_todo_flags_start
);
1988 /* If a timevar is present, start it. */
1989 if (pass
->tv_id
!= TV_NONE
)
1990 timevar_push (pass
->tv_id
);
1993 todo_after
= ipa_pass
->function_transform (node
);
1996 if (pass
->tv_id
!= TV_NONE
)
1997 timevar_pop (pass
->tv_id
);
1999 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2000 check_profile_consistency (pass
->static_pass_number
, 0, true);
2002 /* Run post-pass cleanup and verification. */
2003 execute_todo (todo_after
);
2004 verify_interpass_invariants ();
2005 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2006 check_profile_consistency (pass
->static_pass_number
, 1, true);
2009 do_per_function (execute_function_dump
, NULL
);
2010 pass_fini_dump_file (pass
);
2012 current_pass
= NULL
;
2014 /* Signal this is a suitable GC collection point. */
2015 if (!(todo_after
& TODO_do_not_ggc_collect
))
2019 /* For the current function, execute all ipa transforms. */
2022 execute_all_ipa_transforms (void)
2024 struct cgraph_node
*node
;
2027 node
= cgraph_get_node (current_function_decl
);
2029 if (node
->ipa_transforms_to_apply
.exists ())
2033 for (i
= 0; i
< node
->ipa_transforms_to_apply
.length (); i
++)
2034 execute_one_ipa_transform_pass (node
, node
->ipa_transforms_to_apply
[i
]);
2035 node
->ipa_transforms_to_apply
.release ();
2039 /* Callback for do_per_function to apply all IPA transforms. */
2042 apply_ipa_transforms (void *data
)
2044 struct cgraph_node
*node
= cgraph_get_node (current_function_decl
);
2045 if (!node
->global
.inlined_to
&& node
->ipa_transforms_to_apply
.exists ())
2047 *(bool *)data
= true;
2048 execute_all_ipa_transforms ();
2049 rebuild_cgraph_edges ();
2053 /* Check if PASS is explicitly disabled or enabled and return
2054 the gate status. FUNC is the function to be processed, and
2055 GATE_STATUS is the gate status determined by pass manager by
2059 override_gate_status (opt_pass
*pass
, tree func
, bool gate_status
)
2061 bool explicitly_enabled
= false;
2062 bool explicitly_disabled
= false;
2065 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
2066 enabled_pass_uid_range_tab
);
2068 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
2069 disabled_pass_uid_range_tab
);
2071 gate_status
= !explicitly_disabled
&& (gate_status
|| explicitly_enabled
);
2080 execute_one_pass (opt_pass
*pass
)
2082 unsigned int todo_after
= 0;
2086 /* IPA passes are executed on whole program, so cfun should be NULL.
2087 Other passes need function context set. */
2088 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
2089 gcc_assert (!cfun
&& !current_function_decl
);
2091 gcc_assert (cfun
&& current_function_decl
);
2093 current_pass
= pass
;
2095 /* Check whether gate check should be avoided.
2096 User controls the value of the gate through the parameter "gate_status". */
2097 gate_status
= pass
->gate (cfun
);
2098 gate_status
= override_gate_status (pass
, current_function_decl
, gate_status
);
2100 /* Override gate with plugin. */
2101 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE
, &gate_status
);
2105 /* Run so passes selectively disabling themselves on a given function
2106 are not miscounted. */
2107 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2109 check_profile_consistency (pass
->static_pass_number
, 0, false);
2110 check_profile_consistency (pass
->static_pass_number
, 1, false);
2112 current_pass
= NULL
;
2116 /* Pass execution event trigger: useful to identify passes being
2118 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION
, pass
);
2120 /* SIPLE IPA passes do not handle callgraphs with IPA transforms in it.
2121 Apply all trnasforms first. */
2122 if (pass
->type
== SIMPLE_IPA_PASS
)
2124 bool applied
= false;
2125 do_per_function (apply_ipa_transforms
, (void *)&applied
);
2127 symtab_remove_unreachable_nodes (true, dump_file
);
2128 /* Restore current_pass. */
2129 current_pass
= pass
;
2132 if (!quiet_flag
&& !cfun
)
2133 fprintf (stderr
, " <%s>", pass
->name
? pass
->name
: "");
2135 /* Note that the folders should only create gimple expressions.
2136 This is a hack until the new folder is ready. */
2137 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
2139 pass_init_dump_file (pass
);
2141 /* Run pre-pass verification. */
2142 execute_todo (pass
->todo_flags_start
);
2144 #ifdef ENABLE_CHECKING
2145 do_per_function (verify_curr_properties
,
2146 (void *)(size_t)pass
->properties_required
);
2149 /* If a timevar is present, start it. */
2150 if (pass
->tv_id
!= TV_NONE
)
2151 timevar_push (pass
->tv_id
);
2154 if (pass
->has_execute
)
2156 todo_after
= pass
->execute ();
2157 do_per_function (clear_last_verified
, NULL
);
2161 if (pass
->tv_id
!= TV_NONE
)
2162 timevar_pop (pass
->tv_id
);
2164 do_per_function (update_properties_after_pass
, pass
);
2166 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2167 check_profile_consistency (pass
->static_pass_number
, 0, true);
2169 /* Run post-pass cleanup and verification. */
2170 execute_todo (todo_after
| pass
->todo_flags_finish
);
2171 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2172 check_profile_consistency (pass
->static_pass_number
, 1, true);
2174 verify_interpass_invariants ();
2176 do_per_function (execute_function_dump
, pass
);
2177 if (pass
->type
== IPA_PASS
)
2179 struct cgraph_node
*node
;
2180 FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node
)
2181 node
->ipa_transforms_to_apply
.safe_push ((ipa_opt_pass_d
*)pass
);
2184 if (!current_function_decl
)
2185 cgraph_process_new_functions ();
2187 pass_fini_dump_file (pass
);
2189 if (pass
->type
!= SIMPLE_IPA_PASS
&& pass
->type
!= IPA_PASS
)
2190 gcc_assert (!(cfun
->curr_properties
& PROP_trees
)
2191 || pass
->type
!= RTL_PASS
);
2193 current_pass
= NULL
;
2195 /* Signal this is a suitable GC collection point. */
2196 if (!((todo_after
| pass
->todo_flags_finish
) & TODO_do_not_ggc_collect
))
2203 execute_pass_list (opt_pass
*pass
)
2207 gcc_assert (pass
->type
== GIMPLE_PASS
2208 || pass
->type
== RTL_PASS
);
2209 if (execute_one_pass (pass
) && pass
->sub
)
2210 execute_pass_list (pass
->sub
);
2216 /* Write out all LTO data. */
2220 timevar_push (TV_IPA_LTO_GIMPLE_OUT
);
2222 timevar_pop (TV_IPA_LTO_GIMPLE_OUT
);
2223 timevar_push (TV_IPA_LTO_DECL_OUT
);
2224 produce_asm_for_decls ();
2225 timevar_pop (TV_IPA_LTO_DECL_OUT
);
2228 /* Same as execute_pass_list but assume that subpasses of IPA passes
2229 are local passes. If SET is not NULL, write out summaries of only
2230 those node in SET. */
2233 ipa_write_summaries_2 (opt_pass
*pass
, struct lto_out_decl_state
*state
)
2237 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*)pass
;
2238 gcc_assert (!current_function_decl
);
2240 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2241 if (pass
->type
== IPA_PASS
2242 && ipa_pass
->write_summary
2243 && pass
->gate (cfun
))
2245 /* If a timevar is present, start it. */
2247 timevar_push (pass
->tv_id
);
2249 pass_init_dump_file (pass
);
2251 ipa_pass
->write_summary ();
2253 pass_fini_dump_file (pass
);
2255 /* If a timevar is present, start it. */
2257 timevar_pop (pass
->tv_id
);
2260 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2261 ipa_write_summaries_2 (pass
->sub
, state
);
2267 /* Helper function of ipa_write_summaries. Creates and destroys the
2268 decl state and calls ipa_write_summaries_2 for all passes that have
2269 summaries. SET is the set of nodes to be written. */
2272 ipa_write_summaries_1 (lto_symtab_encoder_t encoder
)
2274 pass_manager
*passes
= g
->get_passes ();
2275 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2276 state
->symtab_node_encoder
= encoder
;
2278 lto_push_out_decl_state (state
);
2280 gcc_assert (!flag_wpa
);
2281 ipa_write_summaries_2 (passes
->all_regular_ipa_passes
, state
);
2285 gcc_assert (lto_get_out_decl_state () == state
);
2286 lto_pop_out_decl_state ();
2287 lto_delete_out_decl_state (state
);
2290 /* Write out summaries for all the nodes in the callgraph. */
2293 ipa_write_summaries (void)
2295 lto_symtab_encoder_t encoder
;
2297 varpool_node
*vnode
;
2298 struct cgraph_node
*node
;
2299 struct cgraph_node
**order
;
2301 if (!flag_generate_lto
|| seen_error ())
2304 encoder
= lto_symtab_encoder_new (false);
2306 /* Create the callgraph set in the same order used in
2307 cgraph_expand_all_functions. This mostly facilitates debugging,
2308 since it causes the gimple file to be processed in the same order
2309 as the source code. */
2310 order
= XCNEWVEC (struct cgraph_node
*, cgraph_n_nodes
);
2311 order_pos
= ipa_reverse_postorder (order
);
2312 gcc_assert (order_pos
== cgraph_n_nodes
);
2314 for (i
= order_pos
- 1; i
>= 0; i
--)
2316 struct cgraph_node
*node
= order
[i
];
2318 if (cgraph_function_with_gimple_body_p (node
))
2320 /* When streaming out references to statements as part of some IPA
2321 pass summary, the statements need to have uids assigned and the
2322 following does that for all the IPA passes here. Naturally, this
2323 ordering then matches the one IPA-passes get in their stmt_fixup
2326 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2327 renumber_gimple_stmt_uids ();
2330 if (node
->definition
)
2331 lto_set_symtab_encoder_in_partition (encoder
, node
);
2334 FOR_EACH_DEFINED_FUNCTION (node
)
2336 lto_set_symtab_encoder_in_partition (encoder
, node
);
2337 FOR_EACH_DEFINED_VARIABLE (vnode
)
2338 lto_set_symtab_encoder_in_partition (encoder
, vnode
);
2340 ipa_write_summaries_1 (compute_ltrans_boundary (encoder
));
2345 /* Same as execute_pass_list but assume that subpasses of IPA passes
2346 are local passes. If SET is not NULL, write out optimization summaries of
2347 only those node in SET. */
2350 ipa_write_optimization_summaries_1 (opt_pass
*pass
,
2351 struct lto_out_decl_state
*state
)
2355 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*)pass
;
2356 gcc_assert (!current_function_decl
);
2358 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2359 if (pass
->type
== IPA_PASS
2360 && ipa_pass
->write_optimization_summary
2361 && pass
->gate (cfun
))
2363 /* If a timevar is present, start it. */
2365 timevar_push (pass
->tv_id
);
2367 pass_init_dump_file (pass
);
2369 ipa_pass
->write_optimization_summary ();
2371 pass_fini_dump_file (pass
);
2373 /* If a timevar is present, start it. */
2375 timevar_pop (pass
->tv_id
);
2378 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2379 ipa_write_optimization_summaries_1 (pass
->sub
, state
);
2385 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is
2386 NULL, write out all summaries of all nodes. */
2389 ipa_write_optimization_summaries (lto_symtab_encoder_t encoder
)
2391 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2392 lto_symtab_encoder_iterator lsei
;
2393 state
->symtab_node_encoder
= encoder
;
2395 lto_push_out_decl_state (state
);
2396 for (lsei
= lsei_start_function_in_partition (encoder
);
2397 !lsei_end_p (lsei
); lsei_next_function_in_partition (&lsei
))
2399 struct cgraph_node
*node
= lsei_cgraph_node (lsei
);
2400 /* When streaming out references to statements as part of some IPA
2401 pass summary, the statements need to have uids assigned.
2403 For functions newly born at WPA stage we need to initialize
2405 if (node
->definition
2406 && gimple_has_body_p (node
->decl
))
2408 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2409 renumber_gimple_stmt_uids ();
2414 gcc_assert (flag_wpa
);
2415 pass_manager
*passes
= g
->get_passes ();
2416 ipa_write_optimization_summaries_1 (passes
->all_regular_ipa_passes
, state
);
2420 gcc_assert (lto_get_out_decl_state () == state
);
2421 lto_pop_out_decl_state ();
2422 lto_delete_out_decl_state (state
);
2425 /* Same as execute_pass_list but assume that subpasses of IPA passes
2426 are local passes. */
2429 ipa_read_summaries_1 (opt_pass
*pass
)
2433 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2435 gcc_assert (!current_function_decl
);
2437 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2439 if (pass
->gate (cfun
))
2441 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_summary
)
2443 /* If a timevar is present, start it. */
2445 timevar_push (pass
->tv_id
);
2447 pass_init_dump_file (pass
);
2449 ipa_pass
->read_summary ();
2451 pass_fini_dump_file (pass
);
2455 timevar_pop (pass
->tv_id
);
2458 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2459 ipa_read_summaries_1 (pass
->sub
);
2466 /* Read all the summaries for all_regular_ipa_passes. */
2469 ipa_read_summaries (void)
2471 pass_manager
*passes
= g
->get_passes ();
2472 ipa_read_summaries_1 (passes
->all_regular_ipa_passes
);
2475 /* Same as execute_pass_list but assume that subpasses of IPA passes
2476 are local passes. */
2479 ipa_read_optimization_summaries_1 (opt_pass
*pass
)
2483 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2485 gcc_assert (!current_function_decl
);
2487 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2489 if (pass
->gate (cfun
))
2491 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_optimization_summary
)
2493 /* If a timevar is present, start it. */
2495 timevar_push (pass
->tv_id
);
2497 pass_init_dump_file (pass
);
2499 ipa_pass
->read_optimization_summary ();
2501 pass_fini_dump_file (pass
);
2505 timevar_pop (pass
->tv_id
);
2508 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2509 ipa_read_optimization_summaries_1 (pass
->sub
);
2515 /* Read all the summaries for all_regular_ipa_passes. */
2518 ipa_read_optimization_summaries (void)
2520 pass_manager
*passes
= g
->get_passes ();
2521 ipa_read_optimization_summaries_1 (passes
->all_regular_ipa_passes
);
2524 /* Same as execute_pass_list but assume that subpasses of IPA passes
2525 are local passes. */
2527 execute_ipa_pass_list (opt_pass
*pass
)
2531 gcc_assert (!current_function_decl
);
2533 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2534 if (execute_one_pass (pass
) && pass
->sub
)
2536 if (pass
->sub
->type
== GIMPLE_PASS
)
2538 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START
, NULL
);
2539 do_per_function_toporder ((void (*)(void *))execute_pass_list
,
2541 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END
, NULL
);
2543 else if (pass
->sub
->type
== SIMPLE_IPA_PASS
2544 || pass
->sub
->type
== IPA_PASS
)
2545 execute_ipa_pass_list (pass
->sub
);
2549 gcc_assert (!current_function_decl
);
2550 cgraph_process_new_functions ();
2556 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
2559 execute_ipa_stmt_fixups (opt_pass
*pass
,
2560 struct cgraph_node
*node
, gimple
*stmts
)
2564 /* Execute all of the IPA_PASSes in the list. */
2565 if (pass
->type
== IPA_PASS
2566 && pass
->gate (cfun
))
2568 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2570 if (ipa_pass
->stmt_fixup
)
2572 pass_init_dump_file (pass
);
2573 /* If a timevar is present, start it. */
2575 timevar_push (pass
->tv_id
);
2577 ipa_pass
->stmt_fixup (node
, stmts
);
2581 timevar_pop (pass
->tv_id
);
2582 pass_fini_dump_file (pass
);
2585 execute_ipa_stmt_fixups (pass
->sub
, node
, stmts
);
2591 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */
2594 execute_all_ipa_stmt_fixups (struct cgraph_node
*node
, gimple
*stmts
)
2596 pass_manager
*passes
= g
->get_passes ();
2597 execute_ipa_stmt_fixups (passes
->all_regular_ipa_passes
, node
, stmts
);
2601 extern void debug_properties (unsigned int);
2602 extern void dump_properties (FILE *, unsigned int);
2605 dump_properties (FILE *dump
, unsigned int props
)
2607 fprintf (dump
, "Properties:\n");
2608 if (props
& PROP_gimple_any
)
2609 fprintf (dump
, "PROP_gimple_any\n");
2610 if (props
& PROP_gimple_lcf
)
2611 fprintf (dump
, "PROP_gimple_lcf\n");
2612 if (props
& PROP_gimple_leh
)
2613 fprintf (dump
, "PROP_gimple_leh\n");
2614 if (props
& PROP_cfg
)
2615 fprintf (dump
, "PROP_cfg\n");
2616 if (props
& PROP_ssa
)
2617 fprintf (dump
, "PROP_ssa\n");
2618 if (props
& PROP_no_crit_edges
)
2619 fprintf (dump
, "PROP_no_crit_edges\n");
2620 if (props
& PROP_rtl
)
2621 fprintf (dump
, "PROP_rtl\n");
2622 if (props
& PROP_gimple_lomp
)
2623 fprintf (dump
, "PROP_gimple_lomp\n");
2624 if (props
& PROP_gimple_lcx
)
2625 fprintf (dump
, "PROP_gimple_lcx\n");
2626 if (props
& PROP_gimple_lvec
)
2627 fprintf (dump
, "PROP_gimple_lvec\n");
2628 if (props
& PROP_cfglayout
)
2629 fprintf (dump
, "PROP_cfglayout\n");
2633 debug_properties (unsigned int props
)
2635 dump_properties (stderr
, props
);
2638 /* Called by local passes to see if function is called by already processed nodes.
2639 Because we process nodes in topological order, this means that function is
2640 in recursive cycle or we introduced new direct calls. */
2642 function_called_by_processed_nodes_p (void)
2644 struct cgraph_edge
*e
;
2645 for (e
= cgraph_get_node (current_function_decl
)->callers
;
2649 if (e
->caller
->decl
== current_function_decl
)
2651 if (!cgraph_function_with_gimple_body_p (e
->caller
))
2653 if (TREE_ASM_WRITTEN (e
->caller
->decl
))
2655 if (!e
->caller
->process
&& !e
->caller
->global
.inlined_to
)
2660 fprintf (dump_file
, "Already processed call to:\n");
2661 dump_cgraph_node (dump_file
, e
->caller
);
2666 #include "gt-passes.h"