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"
51 #include "basic-block.h"
55 #include "diagnostic-core.h"
60 #include "langhooks.h"
62 #include "hosthooks.h"
65 #include "value-prof.h"
66 #include "tree-inline.h"
67 #include "tree-ssa-alias.h"
68 #include "internal-fn.h"
69 #include "gimple-expr.h"
72 #include "gimple-ssa.h"
74 #include "stringpool.h"
75 #include "tree-ssanames.h"
76 #include "tree-ssa-loop-manip.h"
77 #include "tree-into-ssa.h"
80 #include "tree-pass.h"
81 #include "tree-dump.h"
84 #include "plugin-api.h"
87 #include "lto-streamer.h"
89 #include "ipa-utils.h"
90 #include "tree-pretty-print.h" /* for dump_function_header */
92 #include "pass_manager.h"
93 #include "tree-ssa-live.h" /* For remove_unused_locals. */
94 #include "tree-cfgcleanup.h"
98 /* This is used for debugging. It allows the current pass to printed
99 from anywhere in compilation.
100 The variable current_pass is also used for statistics and plugins. */
101 opt_pass
*current_pass
;
103 static void register_pass_name (opt_pass
*, const char *);
105 /* Most passes are single-instance (within their context) and thus don't
106 need to implement cloning, but passes that support multiple instances
107 *must* provide their own implementation of the clone method.
109 Handle this by providing a default implemenation, but make it a fatal
115 internal_error ("pass %s does not support cloning", name
);
119 opt_pass::gate (function
*)
125 opt_pass::execute (function
*)
130 opt_pass::opt_pass (const pass_data
&data
, context
*ctxt
)
134 static_pass_number (0),
141 pass_manager::execute_early_local_passes ()
143 execute_pass_list (cfun
, pass_early_local_passes_1
->sub
);
147 pass_manager::execute_pass_mode_switching ()
149 return pass_mode_switching_1
->execute (cfun
);
153 /* Call from anywhere to find out what pass this is. Useful for
154 printing out debugging information deep inside an service
157 print_current_pass (FILE *file
)
160 fprintf (file
, "current pass = %s (%d)\n",
161 current_pass
->name
, current_pass
->static_pass_number
);
163 fprintf (file
, "no current pass.\n");
167 /* Call from the debugger to get the current pass name. */
171 print_current_pass (stderr
);
176 /* Global variables used to communicate with passes. */
178 bool first_pass_instance
;
181 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
184 This does nothing for local (non-static) variables, unless the
185 variable is a register variable with DECL_ASSEMBLER_NAME set. In
186 that case, or if the variable is not an automatic, it sets up the
187 RTL and outputs any assembler code (label definition, storage
188 allocation and initialization).
190 DECL is the declaration. TOP_LEVEL is nonzero
191 if this declaration is not within a function. */
194 rest_of_decl_compilation (tree decl
,
198 bool finalize
= true;
200 /* We deferred calling assemble_alias so that we could collect
201 other attributes such as visibility. Emit the alias now. */
205 alias
= lookup_attribute ("alias", DECL_ATTRIBUTES (decl
));
208 alias
= TREE_VALUE (TREE_VALUE (alias
));
209 alias
= get_identifier (TREE_STRING_POINTER (alias
));
210 /* A quirk of the initial implementation of aliases required that the
211 user add "extern" to all of them. Which is silly, but now
212 historical. Do note that the symbol is in fact locally defined. */
213 DECL_EXTERNAL (decl
) = 0;
214 TREE_STATIC (decl
) = 1;
215 assemble_alias (decl
, alias
);
220 /* Can't defer this, because it needs to happen before any
221 later function definitions are processed. */
222 if (DECL_ASSEMBLER_NAME_SET_P (decl
) && DECL_REGISTER (decl
))
223 make_decl_rtl (decl
);
225 /* Forward declarations for nested functions are not "external",
226 but we need to treat them as if they were. */
227 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
228 || TREE_CODE (decl
) == FUNCTION_DECL
)
230 timevar_push (TV_VARCONST
);
232 /* Don't output anything when a tentative file-scope definition
233 is seen. But at end of compilation, do output code for them.
235 We do output all variables and rely on
236 callgraph code to defer them except for forward declarations
237 (see gcc.c-torture/compile/920624-1.c) */
239 || !DECL_DEFER_OUTPUT (decl
)
240 || DECL_INITIAL (decl
))
241 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_HAS_VALUE_EXPR_P (decl
))
242 && !DECL_EXTERNAL (decl
))
244 /* When reading LTO unit, we also read varpool, so do not
246 if (in_lto_p
&& !at_end
)
248 else if (finalize
&& TREE_CODE (decl
) != FUNCTION_DECL
)
249 varpool_node::finalize_decl (decl
);
252 #ifdef ASM_FINISH_DECLARE_OBJECT
253 if (decl
== last_assemble_variable_decl
)
255 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
260 timevar_pop (TV_VARCONST
);
262 else if (TREE_CODE (decl
) == TYPE_DECL
263 /* Like in rest_of_type_compilation, avoid confusing the debug
264 information machinery when there are errors. */
267 timevar_push (TV_SYMOUT
);
268 debug_hooks
->type_decl (decl
, !top_level
);
269 timevar_pop (TV_SYMOUT
);
272 /* Let cgraph know about the existence of variables. */
273 if (in_lto_p
&& !at_end
)
275 else if (TREE_CODE (decl
) == VAR_DECL
&& !DECL_EXTERNAL (decl
)
276 && TREE_STATIC (decl
))
277 varpool_node::get_create (decl
);
280 /* Called after finishing a record, union or enumeral type. */
283 rest_of_type_compilation (tree type
, int toplev
)
285 /* Avoid confusing the debug information machinery when there are
290 timevar_push (TV_SYMOUT
);
291 debug_hooks
->type_decl (TYPE_STUB_DECL (type
), !toplev
);
292 timevar_pop (TV_SYMOUT
);
299 finish_optimization_passes (void)
302 struct dump_file_info
*dfi
;
304 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
306 timevar_push (TV_DUMP
);
307 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
309 dumps
->dump_start (pass_profile_1
->static_pass_number
, NULL
);
311 dumps
->dump_finish (pass_profile_1
->static_pass_number
);
316 dumps
->dump_start (pass_profile_1
->static_pass_number
, NULL
);
317 print_combine_total_stats ();
318 dumps
->dump_finish (pass_profile_1
->static_pass_number
);
321 /* Do whatever is necessary to finish printing the graphs. */
322 for (i
= TDI_end
; (dfi
= dumps
->get_dump_file_info (i
)) != NULL
; ++i
)
323 if (dumps
->dump_initialized_p (i
)
324 && (dfi
->pflags
& TDF_GRAPH
) != 0
325 && (name
= dumps
->get_dump_file_name (i
)) != NULL
)
327 finish_graph_dump_file (name
);
331 timevar_pop (TV_DUMP
);
335 execute_all_early_local_passes (void)
337 /* Once this pass (and its sub-passes) are complete, all functions
338 will be in SSA form. Technically this state change is happening
339 a tad early, since the sub-passes have not yet run, but since
340 none of the sub-passes are IPA passes and do not create new
341 functions, this is ok. We're setting this value for the benefit
342 of IPA passes that follow. */
343 if (symtab
->state
< IPA_SSA
)
344 symtab
->state
= IPA_SSA
;
350 const pass_data pass_data_early_local_passes
=
352 SIMPLE_IPA_PASS
, /* type */
353 "early_local_cleanups", /* name */
354 OPTGROUP_NONE
, /* optinfo_flags */
355 TV_EARLY_LOCAL
, /* tv_id */
356 0, /* properties_required */
357 0, /* properties_provided */
358 0, /* properties_destroyed */
359 0, /* todo_flags_start */
360 /* todo_flags_finish is executed before subpases. For this reason
361 it makes no sense to remove unreachable functions here. */
362 0, /* todo_flags_finish */
365 class pass_early_local_passes
: public simple_ipa_opt_pass
368 pass_early_local_passes (gcc::context
*ctxt
)
369 : simple_ipa_opt_pass (pass_data_early_local_passes
, ctxt
)
372 /* opt_pass methods: */
373 virtual bool gate (function
*)
375 /* Don't bother doing anything if the program has errors. */
376 return (!seen_error () && !in_lto_p
);
379 virtual unsigned int execute (function
*)
381 return execute_all_early_local_passes ();
384 }; // class pass_early_local_passes
388 simple_ipa_opt_pass
*
389 make_pass_early_local_passes (gcc::context
*ctxt
)
391 return new pass_early_local_passes (ctxt
);
396 const pass_data pass_data_all_early_optimizations
=
398 GIMPLE_PASS
, /* type */
399 "early_optimizations", /* name */
400 OPTGROUP_NONE
, /* optinfo_flags */
402 0, /* properties_required */
403 0, /* properties_provided */
404 0, /* properties_destroyed */
405 0, /* todo_flags_start */
406 0, /* todo_flags_finish */
409 class pass_all_early_optimizations
: public gimple_opt_pass
412 pass_all_early_optimizations (gcc::context
*ctxt
)
413 : gimple_opt_pass (pass_data_all_early_optimizations
, ctxt
)
416 /* opt_pass methods: */
417 virtual bool gate (function
*)
419 return (optimize
>= 1
420 /* Don't bother doing anything if the program has errors. */
424 }; // class pass_all_early_optimizations
428 static gimple_opt_pass
*
429 make_pass_all_early_optimizations (gcc::context
*ctxt
)
431 return new pass_all_early_optimizations (ctxt
);
436 const pass_data pass_data_all_optimizations
=
438 GIMPLE_PASS
, /* type */
439 "*all_optimizations", /* name */
440 OPTGROUP_NONE
, /* optinfo_flags */
441 TV_OPTIMIZE
, /* tv_id */
442 0, /* properties_required */
443 0, /* properties_provided */
444 0, /* properties_destroyed */
445 0, /* todo_flags_start */
446 0, /* todo_flags_finish */
449 class pass_all_optimizations
: public gimple_opt_pass
452 pass_all_optimizations (gcc::context
*ctxt
)
453 : gimple_opt_pass (pass_data_all_optimizations
, ctxt
)
456 /* opt_pass methods: */
457 virtual bool gate (function
*) { return optimize
>= 1 && !optimize_debug
; }
459 }; // class pass_all_optimizations
463 static gimple_opt_pass
*
464 make_pass_all_optimizations (gcc::context
*ctxt
)
466 return new pass_all_optimizations (ctxt
);
471 const pass_data pass_data_all_optimizations_g
=
473 GIMPLE_PASS
, /* type */
474 "*all_optimizations_g", /* name */
475 OPTGROUP_NONE
, /* optinfo_flags */
476 TV_OPTIMIZE
, /* tv_id */
477 0, /* properties_required */
478 0, /* properties_provided */
479 0, /* properties_destroyed */
480 0, /* todo_flags_start */
481 0, /* todo_flags_finish */
484 class pass_all_optimizations_g
: public gimple_opt_pass
487 pass_all_optimizations_g (gcc::context
*ctxt
)
488 : gimple_opt_pass (pass_data_all_optimizations_g
, ctxt
)
491 /* opt_pass methods: */
492 virtual bool gate (function
*) { return optimize
>= 1 && optimize_debug
; }
494 }; // class pass_all_optimizations_g
498 static gimple_opt_pass
*
499 make_pass_all_optimizations_g (gcc::context
*ctxt
)
501 return new pass_all_optimizations_g (ctxt
);
506 const pass_data pass_data_rest_of_compilation
=
509 "*rest_of_compilation", /* name */
510 OPTGROUP_NONE
, /* optinfo_flags */
511 TV_REST_OF_COMPILATION
, /* tv_id */
512 PROP_rtl
, /* properties_required */
513 0, /* properties_provided */
514 0, /* properties_destroyed */
515 0, /* todo_flags_start */
516 0, /* todo_flags_finish */
519 class pass_rest_of_compilation
: public rtl_opt_pass
522 pass_rest_of_compilation (gcc::context
*ctxt
)
523 : rtl_opt_pass (pass_data_rest_of_compilation
, ctxt
)
526 /* opt_pass methods: */
527 virtual bool gate (function
*)
529 /* Early return if there were errors. We can run afoul of our
530 consistency checks, and there's not really much point in fixing them. */
531 return !(rtl_dump_and_exit
|| flag_syntax_only
|| seen_error ());
534 }; // class pass_rest_of_compilation
538 static rtl_opt_pass
*
539 make_pass_rest_of_compilation (gcc::context
*ctxt
)
541 return new pass_rest_of_compilation (ctxt
);
546 const pass_data pass_data_postreload
=
549 "*all-postreload", /* name */
550 OPTGROUP_NONE
, /* optinfo_flags */
551 TV_POSTRELOAD
, /* tv_id */
552 PROP_rtl
, /* properties_required */
553 0, /* properties_provided */
554 0, /* properties_destroyed */
555 0, /* todo_flags_start */
556 0, /* todo_flags_finish */
559 class pass_postreload
: public rtl_opt_pass
562 pass_postreload (gcc::context
*ctxt
)
563 : rtl_opt_pass (pass_data_postreload
, ctxt
)
566 /* opt_pass methods: */
567 virtual bool gate (function
*) { return reload_completed
; }
569 }; // class pass_postreload
573 static rtl_opt_pass
*
574 make_pass_postreload (gcc::context
*ctxt
)
576 return new pass_postreload (ctxt
);
581 /* Set the static pass number of pass PASS to ID and record that
582 in the mapping from static pass number to pass. */
586 set_pass_for_id (int id
, opt_pass
*pass
)
588 pass
->static_pass_number
= id
;
589 if (passes_by_id_size
<= id
)
591 passes_by_id
= XRESIZEVEC (opt_pass
*, passes_by_id
, id
+ 1);
592 memset (passes_by_id
+ passes_by_id_size
, 0,
593 (id
+ 1 - passes_by_id_size
) * sizeof (void *));
594 passes_by_id_size
= id
+ 1;
596 passes_by_id
[id
] = pass
;
599 /* Return the pass with the static pass number ID. */
602 pass_manager::get_pass_for_id (int id
) const
604 if (id
>= passes_by_id_size
)
606 return passes_by_id
[id
];
609 /* Iterate over the pass tree allocating dump file numbers. We want
610 to do this depth first, and independent of whether the pass is
614 register_one_dump_file (opt_pass
*pass
)
616 g
->get_passes ()->register_one_dump_file (pass
);
620 pass_manager::register_one_dump_file (opt_pass
*pass
)
622 char *dot_name
, *flag_name
, *glob_name
;
623 const char *name
, *full_name
, *prefix
;
626 int optgroup_flags
= OPTGROUP_NONE
;
627 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
629 /* See below in next_pass_1. */
631 if (pass
->static_pass_number
!= -1)
632 sprintf (num
, "%d", ((int) pass
->static_pass_number
< 0
633 ? 1 : pass
->static_pass_number
));
635 /* The name is both used to identify the pass for the purposes of plugins,
636 and to specify dump file name and option.
637 The latter two might want something short which is not quite unique; for
638 that reason, we may have a disambiguating prefix, followed by a space
639 to mark the start of the following dump file name / option string. */
640 name
= strchr (pass
->name
, ' ');
641 name
= name
? name
+ 1 : pass
->name
;
642 dot_name
= concat (".", name
, num
, NULL
);
643 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
647 optgroup_flags
|= OPTGROUP_IPA
;
649 else if (pass
->type
== GIMPLE_PASS
)
660 flag_name
= concat (prefix
, name
, num
, NULL
);
661 glob_name
= concat (prefix
, name
, NULL
);
662 optgroup_flags
|= pass
->optinfo_flags
;
663 /* For any passes that do not have an optgroup set, and which are not
664 IPA passes setup above, set the optgroup to OPTGROUP_OTHER so that
665 any dump messages are emitted properly under -fopt-info(-optall). */
666 if (optgroup_flags
== OPTGROUP_NONE
)
667 optgroup_flags
= OPTGROUP_OTHER
;
668 id
= dumps
->dump_register (dot_name
, flag_name
, glob_name
, flags
,
670 set_pass_for_id (id
, pass
);
671 full_name
= concat (prefix
, pass
->name
, num
, NULL
);
672 register_pass_name (pass
, full_name
);
673 free (CONST_CAST (char *, full_name
));
676 /* Register the dump files for the pass_manager starting at PASS. */
679 pass_manager::register_dump_files (opt_pass
*pass
)
683 if (pass
->name
&& pass
->name
[0] != '*')
684 register_one_dump_file (pass
);
687 register_dump_files (pass
->sub
);
694 /* Helper for pass_registry hash table. */
696 struct pass_registry_hasher
: default_hashmap_traits
698 static inline hashval_t
hash (const char *);
699 static inline bool equal_keys (const char *, const char *);
702 /* Pass registry hash function. */
705 pass_registry_hasher::hash (const char *name
)
707 return htab_hash_string (name
);
710 /* Hash equal function */
713 pass_registry_hasher::equal_keys (const char *s1
, const char *s2
)
715 return !strcmp (s1
, s2
);
718 static hash_map
<const char *, opt_pass
*, pass_registry_hasher
>
721 /* Register PASS with NAME. */
724 register_pass_name (opt_pass
*pass
, const char *name
)
726 if (!name_to_pass_map
)
728 = new hash_map
<const char *, opt_pass
*, pass_registry_hasher
> (256);
730 if (name_to_pass_map
->get (name
))
731 return; /* Ignore plugin passes. */
733 const char *unique_name
= xstrdup (name
);
734 name_to_pass_map
->put (unique_name
, pass
);
737 /* Map from pass id to canonicalized pass name. */
739 typedef const char *char_ptr
;
740 static vec
<char_ptr
> pass_tab
= vNULL
;
742 /* Callback function for traversing NAME_TO_PASS_MAP. */
745 passes_pass_traverse (const char *const &name
, opt_pass
*const &pass
, void *)
747 gcc_assert (pass
->static_pass_number
> 0);
748 gcc_assert (pass_tab
.exists ());
750 pass_tab
[pass
->static_pass_number
] = name
;
755 /* The function traverses NAME_TO_PASS_MAP and creates a pass info
756 table for dumping purpose. */
759 create_pass_tab (void)
761 if (!flag_dump_passes
)
764 pass_tab
.safe_grow_cleared (g
->get_passes ()->passes_by_id_size
+ 1);
765 name_to_pass_map
->traverse
<void *, passes_pass_traverse
> (NULL
);
768 static bool override_gate_status (opt_pass
*, tree
, bool);
770 /* Dump the instantiated name for PASS. IS_ON indicates if PASS
771 is turned on or not. */
774 dump_one_pass (opt_pass
*pass
, int pass_indent
)
776 int indent
= 3 * pass_indent
;
778 bool is_on
, is_really_on
;
780 is_on
= pass
->gate (cfun
);
781 is_really_on
= override_gate_status (pass
, current_function_decl
, is_on
);
783 if (pass
->static_pass_number
<= 0)
786 pn
= pass_tab
[pass
->static_pass_number
];
788 fprintf (stderr
, "%*s%-40s%*s:%s%s\n", indent
, " ", pn
,
789 (15 - indent
< 0 ? 0 : 15 - indent
), " ",
790 is_on
? " ON" : " OFF",
791 ((!is_on
) == (!is_really_on
) ? ""
792 : (is_really_on
? " (FORCED_ON)" : " (FORCED_OFF)")));
795 /* Dump pass list PASS with indentation INDENT. */
798 dump_pass_list (opt_pass
*pass
, int indent
)
802 dump_one_pass (pass
, indent
);
804 dump_pass_list (pass
->sub
, indent
+ 1);
810 /* Dump all optimization passes. */
815 g
->get_passes ()->dump_passes ();
819 pass_manager::dump_passes () const
821 struct cgraph_node
*n
, *node
= NULL
;
825 FOR_EACH_FUNCTION (n
)
826 if (DECL_STRUCT_FUNCTION (n
->decl
))
835 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
837 dump_pass_list (all_lowering_passes
, 1);
838 dump_pass_list (all_small_ipa_passes
, 1);
839 dump_pass_list (all_regular_ipa_passes
, 1);
840 dump_pass_list (all_late_ipa_passes
, 1);
841 dump_pass_list (all_passes
, 1);
847 /* Returns the pass with NAME. */
850 get_pass_by_name (const char *name
)
852 opt_pass
**p
= name_to_pass_map
->get (name
);
860 /* Range [start, last]. */
866 const char *assem_name
;
867 struct uid_range
*next
;
870 typedef struct uid_range
*uid_range_p
;
873 static vec
<uid_range_p
>
874 enabled_pass_uid_range_tab
= vNULL
;
875 static vec
<uid_range_p
>
876 disabled_pass_uid_range_tab
= vNULL
;
879 /* Parse option string for -fdisable- and -fenable-
880 The syntax of the options:
883 -fdisable-<pass_name>
885 -fenable-<pass_name>=s1:e1,s2:e2,...
886 -fdisable-<pass_name>=s1:e1,s2:e2,...
890 enable_disable_pass (const char *arg
, bool is_enable
)
893 char *range_str
, *phase_name
;
894 char *argstr
= xstrdup (arg
);
895 vec
<uid_range_p
> *tab
= 0;
897 range_str
= strchr (argstr
,'=');
908 error ("unrecognized option -fenable");
910 error ("unrecognized option -fdisable");
914 pass
= get_pass_by_name (phase_name
);
915 if (!pass
|| pass
->static_pass_number
== -1)
918 error ("unknown pass %s specified in -fenable", phase_name
);
920 error ("unknown pass %s specified in -fdisable", phase_name
);
926 tab
= &enabled_pass_uid_range_tab
;
928 tab
= &disabled_pass_uid_range_tab
;
930 if ((unsigned) pass
->static_pass_number
>= tab
->length ())
931 tab
->safe_grow_cleared (pass
->static_pass_number
+ 1);
936 uid_range_p new_range
= XCNEW (struct uid_range
);
938 new_range
->start
= 0;
939 new_range
->last
= (unsigned)-1;
941 slot
= (*tab
)[pass
->static_pass_number
];
942 new_range
->next
= slot
;
943 (*tab
)[pass
->static_pass_number
] = new_range
;
945 inform (UNKNOWN_LOCATION
, "enable pass %s for functions in the range "
946 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
948 inform (UNKNOWN_LOCATION
, "disable pass %s for functions in the range "
949 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
953 char *next_range
= NULL
;
954 char *one_range
= range_str
;
955 char *end_val
= NULL
;
960 uid_range_p new_range
;
961 char *invalid
= NULL
;
963 char *func_name
= NULL
;
965 next_range
= strchr (one_range
, ',');
972 end_val
= strchr (one_range
, ':');
978 start
= strtol (one_range
, &invalid
, 10);
979 if (*invalid
|| start
< 0)
981 if (end_val
|| (one_range
[0] >= '0'
982 && one_range
[0] <= '9'))
984 error ("Invalid range %s in option %s",
986 is_enable
? "-fenable" : "-fdisable");
990 func_name
= one_range
;
994 new_range
= XCNEW (struct uid_range
);
997 new_range
->start
= (unsigned) start
;
998 new_range
->last
= (unsigned) start
;
1002 new_range
->start
= (unsigned) -1;
1003 new_range
->last
= (unsigned) -1;
1004 new_range
->assem_name
= xstrdup (func_name
);
1009 long last
= strtol (end_val
, &invalid
, 10);
1010 if (*invalid
|| last
< start
)
1012 error ("Invalid range %s in option %s",
1014 is_enable
? "-fenable" : "-fdisable");
1018 new_range
= XCNEW (struct uid_range
);
1019 new_range
->start
= (unsigned) start
;
1020 new_range
->last
= (unsigned) last
;
1023 slot
= (*tab
)[pass
->static_pass_number
];
1024 new_range
->next
= slot
;
1025 (*tab
)[pass
->static_pass_number
] = new_range
;
1028 if (new_range
->assem_name
)
1029 inform (UNKNOWN_LOCATION
,
1030 "enable pass %s for function %s",
1031 phase_name
, new_range
->assem_name
);
1033 inform (UNKNOWN_LOCATION
,
1034 "enable pass %s for functions in the range of [%u, %u]",
1035 phase_name
, new_range
->start
, new_range
->last
);
1039 if (new_range
->assem_name
)
1040 inform (UNKNOWN_LOCATION
,
1041 "disable pass %s for function %s",
1042 phase_name
, new_range
->assem_name
);
1044 inform (UNKNOWN_LOCATION
,
1045 "disable pass %s for functions in the range of [%u, %u]",
1046 phase_name
, new_range
->start
, new_range
->last
);
1049 one_range
= next_range
;
1050 } while (next_range
);
1056 /* Enable pass specified by ARG. */
1059 enable_pass (const char *arg
)
1061 enable_disable_pass (arg
, true);
1064 /* Disable pass specified by ARG. */
1067 disable_pass (const char *arg
)
1069 enable_disable_pass (arg
, false);
1072 /* Returns true if PASS is explicitly enabled/disabled for FUNC. */
1075 is_pass_explicitly_enabled_or_disabled (opt_pass
*pass
,
1077 vec
<uid_range_p
> tab
)
1079 uid_range_p slot
, range
;
1081 const char *aname
= NULL
;
1084 || (unsigned) pass
->static_pass_number
>= tab
.length ()
1085 || pass
->static_pass_number
== -1)
1088 slot
= tab
[pass
->static_pass_number
];
1092 cgraph_uid
= func
? cgraph_node::get (func
)->uid
: 0;
1093 if (func
&& DECL_ASSEMBLER_NAME_SET_P (func
))
1094 aname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func
));
1099 if ((unsigned) cgraph_uid
>= range
->start
1100 && (unsigned) cgraph_uid
<= range
->last
)
1102 if (range
->assem_name
&& aname
1103 && !strcmp (range
->assem_name
, aname
))
1105 range
= range
->next
;
1112 /* Update static_pass_number for passes (and the flag
1113 TODO_mark_first_instance).
1115 Passes are constructed with static_pass_number preinitialized to 0
1117 This field is used in two different ways: initially as instance numbers
1118 of their kind, and then as ids within the entire pass manager.
1120 Within pass_manager::pass_manager:
1122 * In add_pass_instance(), as called by next_pass_1 in
1123 NEXT_PASS in init_optimization_passes
1125 * When the initial instance of a pass within a pass manager is seen,
1126 it is flagged, and its static_pass_number is set to -1
1128 * On subsequent times that it is seen, the static pass number
1129 is decremented each time, so that if there are e.g. 4 dups,
1130 they have static_pass_number -4, 2, 3, 4 respectively (note
1131 how the initial one is negative and gives the count); these
1132 can be thought of as instance numbers of the specific pass
1134 * Within the register_dump_files () traversal, set_pass_for_id()
1135 is called on each pass, using these instance numbers to create
1136 dumpfile switches, and then overwriting them with a pass id,
1137 which are global to the whole pass manager (based on
1138 (TDI_end + current value of extra_dump_files_in_use) ) */
1141 add_pass_instance (opt_pass
*new_pass
, bool track_duplicates
,
1142 opt_pass
*initial_pass
)
1144 /* Are we dealing with the first pass of its kind, or a clone? */
1145 if (new_pass
!= initial_pass
)
1147 /* We're dealing with a clone. */
1148 new_pass
->todo_flags_start
&= ~TODO_mark_first_instance
;
1150 /* Indicate to register_dump_files that this pass has duplicates,
1151 and so it should rename the dump file. The first instance will
1152 be -1, and be number of duplicates = -static_pass_number - 1.
1153 Subsequent instances will be > 0 and just the duplicate number. */
1154 if ((new_pass
->name
&& new_pass
->name
[0] != '*') || track_duplicates
)
1156 initial_pass
->static_pass_number
-= 1;
1157 new_pass
->static_pass_number
= -initial_pass
->static_pass_number
;
1162 /* We're dealing with the first pass of its kind. */
1163 new_pass
->todo_flags_start
|= TODO_mark_first_instance
;
1164 new_pass
->static_pass_number
= -1;
1166 invoke_plugin_callbacks (PLUGIN_NEW_PASS
, new_pass
);
1170 /* Add a pass to the pass list. Duplicate the pass if it's already
1174 next_pass_1 (opt_pass
**list
, opt_pass
*pass
, opt_pass
*initial_pass
)
1176 /* Every pass should have a name so that plugins can refer to them. */
1177 gcc_assert (pass
->name
!= NULL
);
1179 add_pass_instance (pass
, false, initial_pass
);
1182 return &(*list
)->next
;
1185 /* List node for an inserted pass instance. We need to keep track of all
1186 the newly-added pass instances (with 'added_pass_nodes' defined below)
1187 so that we can register their dump files after pass-positioning is finished.
1188 Registering dumping files needs to be post-processed or the
1189 static_pass_number of the opt_pass object would be modified and mess up
1190 the dump file names of future pass instances to be added. */
1192 struct pass_list_node
1195 struct pass_list_node
*next
;
1198 static struct pass_list_node
*added_pass_nodes
= NULL
;
1199 static struct pass_list_node
*prev_added_pass_node
;
1201 /* Insert the pass at the proper position. Return true if the pass
1202 is successfully added.
1204 NEW_PASS_INFO - new pass to be inserted
1205 PASS_LIST - root of the pass list to insert the new pass to */
1208 position_pass (struct register_pass_info
*new_pass_info
, opt_pass
**pass_list
)
1210 opt_pass
*pass
= *pass_list
, *prev_pass
= NULL
;
1211 bool success
= false;
1213 for ( ; pass
; prev_pass
= pass
, pass
= pass
->next
)
1215 /* Check if the current pass is of the same type as the new pass and
1216 matches the name and the instance number of the reference pass. */
1217 if (pass
->type
== new_pass_info
->pass
->type
1219 && !strcmp (pass
->name
, new_pass_info
->reference_pass_name
)
1220 && ((new_pass_info
->ref_pass_instance_number
== 0)
1221 || (new_pass_info
->ref_pass_instance_number
==
1222 pass
->static_pass_number
)
1223 || (new_pass_info
->ref_pass_instance_number
== 1
1224 && pass
->todo_flags_start
& TODO_mark_first_instance
)))
1227 struct pass_list_node
*new_pass_node
;
1229 if (new_pass_info
->ref_pass_instance_number
== 0)
1231 new_pass
= new_pass_info
->pass
->clone ();
1232 add_pass_instance (new_pass
, true, new_pass_info
->pass
);
1236 new_pass
= new_pass_info
->pass
;
1237 add_pass_instance (new_pass
, true, new_pass
);
1240 /* Insert the new pass instance based on the positioning op. */
1241 switch (new_pass_info
->pos_op
)
1243 case PASS_POS_INSERT_AFTER
:
1244 new_pass
->next
= pass
->next
;
1245 pass
->next
= new_pass
;
1247 /* Skip newly inserted pass to avoid repeated
1248 insertions in the case where the new pass and the
1249 existing one have the same name. */
1252 case PASS_POS_INSERT_BEFORE
:
1253 new_pass
->next
= pass
;
1255 prev_pass
->next
= new_pass
;
1257 *pass_list
= new_pass
;
1259 case PASS_POS_REPLACE
:
1260 new_pass
->next
= pass
->next
;
1262 prev_pass
->next
= new_pass
;
1264 *pass_list
= new_pass
;
1265 new_pass
->sub
= pass
->sub
;
1266 new_pass
->tv_id
= pass
->tv_id
;
1270 error ("invalid pass positioning operation");
1274 /* Save the newly added pass (instance) in the added_pass_nodes
1275 list so that we can register its dump file later. Note that
1276 we cannot register the dump file now because doing so will modify
1277 the static_pass_number of the opt_pass object and therefore
1278 mess up the dump file name of future instances. */
1279 new_pass_node
= XCNEW (struct pass_list_node
);
1280 new_pass_node
->pass
= new_pass
;
1281 if (!added_pass_nodes
)
1282 added_pass_nodes
= new_pass_node
;
1284 prev_added_pass_node
->next
= new_pass_node
;
1285 prev_added_pass_node
= new_pass_node
;
1290 if (pass
->sub
&& position_pass (new_pass_info
, &pass
->sub
))
1297 /* Hooks a new pass into the pass lists.
1299 PASS_INFO - pass information that specifies the opt_pass object,
1300 reference pass, instance number, and how to position
1304 register_pass (struct register_pass_info
*pass_info
)
1306 g
->get_passes ()->register_pass (pass_info
);
1310 register_pass (opt_pass
* pass
, pass_positioning_ops pos
,
1311 const char* ref_pass_name
, int ref_pass_inst_number
)
1313 register_pass_info i
;
1315 i
.reference_pass_name
= ref_pass_name
;
1316 i
.ref_pass_instance_number
= ref_pass_inst_number
;
1319 g
->get_passes ()->register_pass (&i
);
1323 pass_manager::register_pass (struct register_pass_info
*pass_info
)
1325 bool all_instances
, success
;
1326 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
1328 /* The checks below could fail in buggy plugins. Existing GCC
1329 passes should never fail these checks, so we mention plugin in
1331 if (!pass_info
->pass
)
1332 fatal_error ("plugin cannot register a missing pass");
1334 if (!pass_info
->pass
->name
)
1335 fatal_error ("plugin cannot register an unnamed pass");
1337 if (!pass_info
->reference_pass_name
)
1339 ("plugin cannot register pass %qs without reference pass name",
1340 pass_info
->pass
->name
);
1342 /* Try to insert the new pass to the pass lists. We need to check
1343 all five lists as the reference pass could be in one (or all) of
1345 all_instances
= pass_info
->ref_pass_instance_number
== 0;
1346 success
= position_pass (pass_info
, &all_lowering_passes
);
1347 if (!success
|| all_instances
)
1348 success
|= position_pass (pass_info
, &all_small_ipa_passes
);
1349 if (!success
|| all_instances
)
1350 success
|= position_pass (pass_info
, &all_regular_ipa_passes
);
1351 if (!success
|| all_instances
)
1352 success
|= position_pass (pass_info
, &all_late_ipa_passes
);
1353 if (!success
|| all_instances
)
1354 success
|= position_pass (pass_info
, &all_passes
);
1357 ("pass %qs not found but is referenced by new pass %qs",
1358 pass_info
->reference_pass_name
, pass_info
->pass
->name
);
1360 /* OK, we have successfully inserted the new pass. We need to register
1361 the dump files for the newly added pass and its duplicates (if any).
1362 Because the registration of plugin/backend passes happens after the
1363 command-line options are parsed, the options that specify single
1364 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
1365 passes. Therefore we currently can only enable dumping of
1366 new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
1367 are specified. While doing so, we also delete the pass_list_node
1368 objects created during pass positioning. */
1369 while (added_pass_nodes
)
1371 struct pass_list_node
*next_node
= added_pass_nodes
->next
;
1372 enum tree_dump_index tdi
;
1373 register_one_dump_file (added_pass_nodes
->pass
);
1374 if (added_pass_nodes
->pass
->type
== SIMPLE_IPA_PASS
1375 || added_pass_nodes
->pass
->type
== IPA_PASS
)
1377 else if (added_pass_nodes
->pass
->type
== GIMPLE_PASS
)
1381 /* Check if dump-all flag is specified. */
1382 if (dumps
->get_dump_file_info (tdi
)->pstate
)
1383 dumps
->get_dump_file_info (added_pass_nodes
->pass
->static_pass_number
)
1384 ->pstate
= dumps
->get_dump_file_info (tdi
)->pstate
;
1385 XDELETE (added_pass_nodes
);
1386 added_pass_nodes
= next_node
;
1390 /* Construct the pass tree. The sequencing of passes is driven by
1391 the cgraph routines:
1393 finalize_compilation_unit ()
1394 for each node N in the cgraph
1395 cgraph_analyze_function (N)
1396 cgraph_lower_function (N) -> all_lowering_passes
1398 If we are optimizing, compile is then invoked:
1401 ipa_passes () -> all_small_ipa_passes
1402 -> Analysis of all_regular_ipa_passes
1403 * possible LTO streaming at copmilation time *
1404 -> Execution of all_regular_ipa_passes
1405 * possible LTO streaming at link time *
1406 -> all_late_ipa_passes
1407 expand_all_functions ()
1408 for each node N in the cgraph
1409 expand_function (N) -> Transformation of all_regular_ipa_passes
1414 pass_manager::operator new (size_t sz
)
1416 /* Ensure that all fields of the pass manager are zero-initialized. */
1417 return xcalloc (1, sz
);
1420 pass_manager::pass_manager (context
*ctxt
)
1421 : all_passes (NULL
), all_small_ipa_passes (NULL
), all_lowering_passes (NULL
),
1422 all_regular_ipa_passes (NULL
),
1423 all_late_ipa_passes (NULL
), passes_by_id (NULL
), passes_by_id_size (0),
1428 /* Initialize the pass_lists array. */
1429 #define DEF_PASS_LIST(LIST) pass_lists[PASS_LIST_NO_##LIST] = &LIST;
1431 #undef DEF_PASS_LIST
1433 /* Build the tree of passes. */
1435 #define INSERT_PASSES_AFTER(PASS) \
1438 #define PUSH_INSERT_PASSES_WITHIN(PASS) \
1440 opt_pass **p = &(PASS ## _1)->sub;
1442 #define POP_INSERT_PASSES() \
1445 #define NEXT_PASS(PASS, NUM) \
1447 gcc_assert (NULL == PASS ## _ ## NUM); \
1449 PASS ## _1 = make_##PASS (m_ctxt); \
1452 gcc_assert (PASS ## _1); \
1453 PASS ## _ ## NUM = PASS ## _1->clone (); \
1455 p = next_pass_1 (p, PASS ## _ ## NUM, PASS ## _1); \
1458 #define TERMINATE_PASS_LIST() \
1461 #include "pass-instances.def"
1463 #undef INSERT_PASSES_AFTER
1464 #undef PUSH_INSERT_PASSES_WITHIN
1465 #undef POP_INSERT_PASSES
1467 #undef TERMINATE_PASS_LIST
1469 /* Register the passes with the tree dump code. */
1470 register_dump_files (all_lowering_passes
);
1471 register_dump_files (all_small_ipa_passes
);
1472 register_dump_files (all_regular_ipa_passes
);
1473 register_dump_files (all_late_ipa_passes
);
1474 register_dump_files (all_passes
);
1477 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1478 function CALLBACK for every function in the call graph. Otherwise,
1479 call CALLBACK on the current function. */
1482 do_per_function (void (*callback
) (function
*, void *data
), void *data
)
1484 if (current_function_decl
)
1485 callback (cfun
, data
);
1488 struct cgraph_node
*node
;
1489 FOR_EACH_DEFINED_FUNCTION (node
)
1490 if (node
->analyzed
&& (gimple_has_body_p (node
->decl
) && !in_lto_p
)
1491 && (!node
->clone_of
|| node
->decl
!= node
->clone_of
->decl
))
1492 callback (DECL_STRUCT_FUNCTION (node
->decl
), data
);
1496 /* Because inlining might remove no-longer reachable nodes, we need to
1497 keep the array visible to garbage collector to avoid reading collected
1500 static GTY ((length ("nnodes"))) cgraph_node
**order
;
1502 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1503 function CALLBACK for every function in the call graph. Otherwise,
1504 call CALLBACK on the current function.
1505 This function is global so that plugins can use it. */
1507 do_per_function_toporder (void (*callback
) (function
*, void *data
), void *data
)
1511 if (current_function_decl
)
1512 callback (cfun
, data
);
1515 gcc_assert (!order
);
1516 order
= ggc_vec_alloc
<cgraph_node
*> (symtab
->cgraph_count
);
1517 nnodes
= ipa_reverse_postorder (order
);
1518 for (i
= nnodes
- 1; i
>= 0; i
--)
1519 order
[i
]->process
= 1;
1520 for (i
= nnodes
- 1; i
>= 0; i
--)
1522 struct cgraph_node
*node
= order
[i
];
1524 /* Allow possibly removed nodes to be garbage collected. */
1527 if (node
->has_gimple_body_p ())
1528 callback (DECL_STRUCT_FUNCTION (node
->decl
), data
);
1536 /* Helper function to perform function body dump. */
1539 execute_function_dump (function
*fn
, void *data
)
1541 opt_pass
*pass
= (opt_pass
*)data
;
1547 if (fn
->curr_properties
& PROP_trees
)
1548 dump_function_to_file (fn
->decl
, dump_file
, dump_flags
);
1550 print_rtl_with_bb (dump_file
, get_insns (), dump_flags
);
1552 /* Flush the file. If verification fails, we won't be able to
1553 close the file before aborting. */
1556 if ((fn
->curr_properties
& PROP_cfg
)
1557 && (dump_flags
& TDF_GRAPH
))
1559 if (!pass
->graph_dump_initialized
)
1561 clean_graph_dump_file (dump_file_name
);
1562 pass
->graph_dump_initialized
= true;
1564 print_graph_cfg (dump_file_name
, fn
);
1571 static struct profile_record
*profile_record
;
1573 /* Do profile consistency book-keeping for the pass with static number INDEX.
1574 If SUBPASS is zero, we run _before_ the pass, and if SUBPASS is one, then
1575 we run _after_ the pass. RUN is true if the pass really runs, or FALSE
1576 if we are only book-keeping on passes that may have selectively disabled
1577 themselves on a given function. */
1579 check_profile_consistency (int index
, int subpass
, bool run
)
1581 pass_manager
*passes
= g
->get_passes ();
1584 if (!profile_record
)
1585 profile_record
= XCNEWVEC (struct profile_record
,
1586 passes
->passes_by_id_size
);
1587 gcc_assert (index
< passes
->passes_by_id_size
&& index
>= 0);
1588 gcc_assert (subpass
< 2);
1589 profile_record
[index
].run
|= run
;
1590 account_profile_record (&profile_record
[index
], subpass
);
1593 /* Output profile consistency. */
1596 dump_profile_report (void)
1598 g
->get_passes ()->dump_profile_report ();
1602 pass_manager::dump_profile_report () const
1605 int last_freq_in
= 0, last_count_in
= 0, last_freq_out
= 0, last_count_out
= 0;
1606 gcov_type last_time
= 0, last_size
= 0;
1607 double rel_time_change
, rel_size_change
;
1608 int last_reported
= 0;
1610 if (!profile_record
)
1612 fprintf (stderr
, "\nProfile consistency report:\n\n");
1613 fprintf (stderr
, "Pass name |mismatch in |mismated out|Overall\n");
1614 fprintf (stderr
, " |freq count |freq count |size time\n");
1616 for (i
= 0; i
< passes_by_id_size
; i
++)
1617 for (j
= 0 ; j
< 2; j
++)
1618 if (profile_record
[i
].run
)
1621 rel_time_change
= (profile_record
[i
].time
[j
]
1622 - (double)last_time
) * 100 / (double)last_time
;
1624 rel_time_change
= 0;
1626 rel_size_change
= (profile_record
[i
].size
[j
]
1627 - (double)last_size
) * 100 / (double)last_size
;
1629 rel_size_change
= 0;
1631 if (profile_record
[i
].num_mismatched_freq_in
[j
] != last_freq_in
1632 || profile_record
[i
].num_mismatched_freq_out
[j
] != last_freq_out
1633 || profile_record
[i
].num_mismatched_count_in
[j
] != last_count_in
1634 || profile_record
[i
].num_mismatched_count_out
[j
] != last_count_out
1635 || rel_time_change
|| rel_size_change
)
1638 fprintf (stderr
, "%-20s %s",
1639 passes_by_id
[i
]->name
,
1640 j
? "(after TODO)" : " ");
1641 if (profile_record
[i
].num_mismatched_freq_in
[j
] != last_freq_in
)
1642 fprintf (stderr
, "| %+5i",
1643 profile_record
[i
].num_mismatched_freq_in
[j
]
1646 fprintf (stderr
, "| ");
1647 if (profile_record
[i
].num_mismatched_count_in
[j
] != last_count_in
)
1648 fprintf (stderr
, " %+5i",
1649 profile_record
[i
].num_mismatched_count_in
[j
]
1652 fprintf (stderr
, " ");
1653 if (profile_record
[i
].num_mismatched_freq_out
[j
] != last_freq_out
)
1654 fprintf (stderr
, "| %+5i",
1655 profile_record
[i
].num_mismatched_freq_out
[j
]
1658 fprintf (stderr
, "| ");
1659 if (profile_record
[i
].num_mismatched_count_out
[j
] != last_count_out
)
1660 fprintf (stderr
, " %+5i",
1661 profile_record
[i
].num_mismatched_count_out
[j
]
1664 fprintf (stderr
, " ");
1666 /* Size/time units change across gimple and RTL. */
1667 if (i
== pass_expand_1
->static_pass_number
)
1668 fprintf (stderr
, "|----------");
1671 if (rel_size_change
)
1672 fprintf (stderr
, "| %+8.4f%%", rel_size_change
);
1674 fprintf (stderr
, "| ");
1675 if (rel_time_change
)
1676 fprintf (stderr
, " %+8.4f%%", rel_time_change
);
1678 fprintf (stderr
, "\n");
1679 last_freq_in
= profile_record
[i
].num_mismatched_freq_in
[j
];
1680 last_freq_out
= profile_record
[i
].num_mismatched_freq_out
[j
];
1681 last_count_in
= profile_record
[i
].num_mismatched_count_in
[j
];
1682 last_count_out
= profile_record
[i
].num_mismatched_count_out
[j
];
1684 else if (j
&& last_reported
!= i
)
1687 fprintf (stderr
, "%-20s ------------| | |\n",
1688 passes_by_id
[i
]->name
);
1690 last_time
= profile_record
[i
].time
[j
];
1691 last_size
= profile_record
[i
].size
[j
];
1695 /* Perform all TODO actions that ought to be done on each function. */
1698 execute_function_todo (function
*fn
, void *data
)
1700 bool from_ipa_pass
= (cfun
== NULL
);
1701 unsigned int flags
= (size_t)data
;
1702 flags
&= ~fn
->last_verified
;
1708 /* Always cleanup the CFG before trying to update SSA. */
1709 if (flags
& TODO_cleanup_cfg
)
1711 cleanup_tree_cfg ();
1713 /* When cleanup_tree_cfg merges consecutive blocks, it may
1714 perform some simplistic propagation when removing single
1715 valued PHI nodes. This propagation may, in turn, cause the
1716 SSA form to become out-of-date (see PR 22037). So, even
1717 if the parent pass had not scheduled an SSA update, we may
1718 still need to do one. */
1719 if (!(flags
& TODO_update_ssa_any
) && need_ssa_update_p (cfun
))
1720 flags
|= TODO_update_ssa
;
1723 if (flags
& TODO_update_ssa_any
)
1725 unsigned update_flags
= flags
& TODO_update_ssa_any
;
1726 update_ssa (update_flags
);
1729 if (flag_tree_pta
&& (flags
& TODO_rebuild_alias
))
1730 compute_may_aliases ();
1732 if (optimize
&& (flags
& TODO_update_address_taken
))
1733 execute_update_addresses_taken ();
1735 if (flags
& TODO_remove_unused_locals
)
1736 remove_unused_locals ();
1738 if (flags
& TODO_rebuild_frequencies
)
1739 rebuild_frequencies ();
1741 if (flags
& TODO_rebuild_cgraph_edges
)
1742 cgraph_edge::rebuild_edges ();
1744 /* If we've seen errors do not bother running any verifiers. */
1747 #if defined ENABLE_CHECKING
1748 dom_state pre_verify_state
= dom_info_state (fn
, CDI_DOMINATORS
);
1749 dom_state pre_verify_pstate
= dom_info_state (fn
, CDI_POST_DOMINATORS
);
1751 if (flags
& TODO_verify_il
)
1753 if (cfun
->curr_properties
& PROP_trees
)
1755 if (cfun
->curr_properties
& PROP_cfg
)
1756 /* IPA passes leave stmts to be fixed up, so make sure to
1757 not verify stmts really throw. */
1758 verify_gimple_in_cfg (cfun
, !from_ipa_pass
);
1760 verify_gimple_in_seq (gimple_body (cfun
->decl
));
1762 if (cfun
->curr_properties
& PROP_ssa
)
1763 /* IPA passes leave stmts to be fixed up, so make sure to
1764 not verify SSA operands whose verifier will choke on that. */
1765 verify_ssa (true, !from_ipa_pass
);
1766 /* IPA passes leave basic-blocks unsplit, so make sure to
1767 not trip on that. */
1768 if ((cfun
->curr_properties
& PROP_cfg
)
1770 verify_flow_info ();
1772 && loops_state_satisfies_p (LOOP_CLOSED_SSA
))
1773 verify_loop_closed_ssa (false);
1774 if (cfun
->curr_properties
& PROP_rtl
)
1775 verify_rtl_sharing ();
1778 /* Make sure verifiers don't change dominator state. */
1779 gcc_assert (dom_info_state (fn
, CDI_DOMINATORS
) == pre_verify_state
);
1780 gcc_assert (dom_info_state (fn
, CDI_POST_DOMINATORS
) == pre_verify_pstate
);
1784 fn
->last_verified
= flags
& TODO_verify_all
;
1788 /* For IPA passes make sure to release dominator info, it can be
1789 computed by non-verifying TODOs. */
1792 free_dominance_info (fn
, CDI_DOMINATORS
);
1793 free_dominance_info (fn
, CDI_POST_DOMINATORS
);
1797 /* Perform all TODO actions. */
1799 execute_todo (unsigned int flags
)
1801 #if defined ENABLE_CHECKING
1803 && need_ssa_update_p (cfun
))
1804 gcc_assert (flags
& TODO_update_ssa_any
);
1807 timevar_push (TV_TODO
);
1809 /* Inform the pass whether it is the first time it is run. */
1810 first_pass_instance
= (flags
& TODO_mark_first_instance
) != 0;
1812 statistics_fini_pass ();
1815 do_per_function (execute_function_todo
, (void *)(size_t) flags
);
1817 /* Always remove functions just as before inlining: IPA passes might be
1818 interested to see bodies of extern inline functions that are not inlined
1819 to analyze side effects. The full removal is done just at the end
1820 of IPA pass queue. */
1821 if (flags
& TODO_remove_functions
)
1824 symtab
->remove_unreachable_nodes (true, dump_file
);
1827 if ((flags
& TODO_dump_symtab
) && dump_file
&& !current_function_decl
)
1830 symtab_node::dump_table (dump_file
);
1831 /* Flush the file. If verification fails, we won't be able to
1832 close the file before aborting. */
1836 /* Now that the dumping has been done, we can get rid of the optional
1838 if (flags
& TODO_df_finish
)
1839 df_finish_pass ((flags
& TODO_df_verify
) != 0);
1841 timevar_pop (TV_TODO
);
1844 /* Verify invariants that should hold between passes. This is a place
1845 to put simple sanity checks. */
1848 verify_interpass_invariants (void)
1850 gcc_checking_assert (!fold_deferring_overflow_warnings_p ());
1853 /* Clear the last verified flag. */
1856 clear_last_verified (function
*fn
, void *data ATTRIBUTE_UNUSED
)
1858 fn
->last_verified
= 0;
1861 /* Helper function. Verify that the properties has been turn into the
1862 properties expected by the pass. */
1864 #ifdef ENABLE_CHECKING
1866 verify_curr_properties (function
*fn
, void *data
)
1868 unsigned int props
= (size_t)data
;
1869 gcc_assert ((fn
->curr_properties
& props
) == props
);
1873 /* Initialize pass dump file. */
1874 /* This is non-static so that the plugins can use it. */
1877 pass_init_dump_file (opt_pass
*pass
)
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 (function
*fn
, void *data
)
1929 opt_pass
*pass
= (opt_pass
*) data
;
1930 fn
->curr_properties
= (fn
->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 current_pass
= pass
;
1955 ipa_pass
->generate_summary ();
1959 timevar_pop (pass
->tv_id
);
1961 pass_fini_dump_file (pass
);
1963 ipa_pass
= (ipa_opt_pass_d
*)ipa_pass
->next
;
1967 /* Execute IPA_PASS function transform on NODE. */
1970 execute_one_ipa_transform_pass (struct cgraph_node
*node
,
1971 ipa_opt_pass_d
*ipa_pass
)
1973 opt_pass
*pass
= ipa_pass
;
1974 unsigned int todo_after
= 0;
1976 current_pass
= pass
;
1977 if (!ipa_pass
->function_transform
)
1980 /* Note that the folders should only create gimple expressions.
1981 This is a hack until the new folder is ready. */
1982 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
1984 pass_init_dump_file (pass
);
1986 /* Run pre-pass verification. */
1987 execute_todo (ipa_pass
->function_transform_todo_flags_start
);
1989 /* If a timevar is present, start it. */
1990 if (pass
->tv_id
!= TV_NONE
)
1991 timevar_push (pass
->tv_id
);
1994 todo_after
= ipa_pass
->function_transform (node
);
1997 if (pass
->tv_id
!= TV_NONE
)
1998 timevar_pop (pass
->tv_id
);
2000 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2001 check_profile_consistency (pass
->static_pass_number
, 0, true);
2003 /* Run post-pass cleanup and verification. */
2004 execute_todo (todo_after
);
2005 verify_interpass_invariants ();
2006 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2007 check_profile_consistency (pass
->static_pass_number
, 1, true);
2010 do_per_function (execute_function_dump
, NULL
);
2011 pass_fini_dump_file (pass
);
2013 current_pass
= NULL
;
2015 /* Signal this is a suitable GC collection point. */
2016 if (!(todo_after
& TODO_do_not_ggc_collect
))
2020 /* For the current function, execute all ipa transforms. */
2023 execute_all_ipa_transforms (void)
2025 struct cgraph_node
*node
;
2028 node
= cgraph_node::get (current_function_decl
);
2030 if (node
->ipa_transforms_to_apply
.exists ())
2034 for (i
= 0; i
< node
->ipa_transforms_to_apply
.length (); i
++)
2035 execute_one_ipa_transform_pass (node
, node
->ipa_transforms_to_apply
[i
]);
2036 node
->ipa_transforms_to_apply
.release ();
2040 /* Check if PASS is explicitly disabled or enabled and return
2041 the gate status. FUNC is the function to be processed, and
2042 GATE_STATUS is the gate status determined by pass manager by
2046 override_gate_status (opt_pass
*pass
, tree func
, bool gate_status
)
2048 bool explicitly_enabled
= false;
2049 bool explicitly_disabled
= false;
2052 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
2053 enabled_pass_uid_range_tab
);
2055 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
2056 disabled_pass_uid_range_tab
);
2058 gate_status
= !explicitly_disabled
&& (gate_status
|| explicitly_enabled
);
2067 execute_one_pass (opt_pass
*pass
)
2069 unsigned int todo_after
= 0;
2073 /* IPA passes are executed on whole program, so cfun should be NULL.
2074 Other passes need function context set. */
2075 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
2076 gcc_assert (!cfun
&& !current_function_decl
);
2078 gcc_assert (cfun
&& current_function_decl
);
2080 current_pass
= pass
;
2082 /* Check whether gate check should be avoided.
2083 User controls the value of the gate through the parameter "gate_status". */
2084 gate_status
= pass
->gate (cfun
);
2085 gate_status
= override_gate_status (pass
, current_function_decl
, gate_status
);
2087 /* Override gate with plugin. */
2088 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE
, &gate_status
);
2092 /* Run so passes selectively disabling themselves on a given function
2093 are not miscounted. */
2094 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2096 check_profile_consistency (pass
->static_pass_number
, 0, false);
2097 check_profile_consistency (pass
->static_pass_number
, 1, false);
2099 current_pass
= NULL
;
2103 /* Pass execution event trigger: useful to identify passes being
2105 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION
, pass
);
2107 /* SIPLE IPA passes do not handle callgraphs with IPA transforms in it.
2108 Apply all trnasforms first. */
2109 if (pass
->type
== SIMPLE_IPA_PASS
)
2111 struct cgraph_node
*node
;
2112 bool applied
= false;
2113 FOR_EACH_DEFINED_FUNCTION (node
)
2115 && node
->has_gimple_body_p ()
2116 && (!node
->clone_of
|| node
->decl
!= node
->clone_of
->decl
))
2118 if (!node
->global
.inlined_to
2119 && node
->ipa_transforms_to_apply
.exists ())
2122 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2123 execute_all_ipa_transforms ();
2124 cgraph_edge::rebuild_edges ();
2125 free_dominance_info (CDI_DOMINATORS
);
2126 free_dominance_info (CDI_POST_DOMINATORS
);
2132 symtab
->remove_unreachable_nodes (false, dump_file
);
2133 /* Restore current_pass. */
2134 current_pass
= pass
;
2137 if (!quiet_flag
&& !cfun
)
2138 fprintf (stderr
, " <%s>", pass
->name
? pass
->name
: "");
2140 /* Note that the folders should only create gimple expressions.
2141 This is a hack until the new folder is ready. */
2142 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
2144 pass_init_dump_file (pass
);
2146 /* Run pre-pass verification. */
2147 execute_todo (pass
->todo_flags_start
);
2149 #ifdef ENABLE_CHECKING
2150 do_per_function (verify_curr_properties
,
2151 (void *)(size_t)pass
->properties_required
);
2154 /* If a timevar is present, start it. */
2155 if (pass
->tv_id
!= TV_NONE
)
2156 timevar_push (pass
->tv_id
);
2159 todo_after
= pass
->execute (cfun
);
2160 do_per_function (clear_last_verified
, NULL
);
2163 if (pass
->tv_id
!= TV_NONE
)
2164 timevar_pop (pass
->tv_id
);
2166 do_per_function (update_properties_after_pass
, pass
);
2168 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2169 check_profile_consistency (pass
->static_pass_number
, 0, true);
2171 /* Run post-pass cleanup and verification. */
2172 execute_todo (todo_after
| pass
->todo_flags_finish
| TODO_verify_il
);
2173 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2174 check_profile_consistency (pass
->static_pass_number
, 1, true);
2176 verify_interpass_invariants ();
2178 do_per_function (execute_function_dump
, pass
);
2179 if (pass
->type
== IPA_PASS
)
2181 struct cgraph_node
*node
;
2182 FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node
)
2183 node
->ipa_transforms_to_apply
.safe_push ((ipa_opt_pass_d
*)pass
);
2186 if (!current_function_decl
)
2187 symtab
->process_new_functions ();
2189 pass_fini_dump_file (pass
);
2191 if (pass
->type
!= SIMPLE_IPA_PASS
&& pass
->type
!= IPA_PASS
)
2192 gcc_assert (!(cfun
->curr_properties
& PROP_trees
)
2193 || pass
->type
!= RTL_PASS
);
2195 current_pass
= NULL
;
2197 /* Signal this is a suitable GC collection point. */
2198 if (!((todo_after
| pass
->todo_flags_finish
) & TODO_do_not_ggc_collect
))
2205 execute_pass_list_1 (opt_pass
*pass
)
2209 gcc_assert (pass
->type
== GIMPLE_PASS
2210 || pass
->type
== RTL_PASS
);
2211 if (execute_one_pass (pass
) && pass
->sub
)
2212 execute_pass_list_1 (pass
->sub
);
2219 execute_pass_list (function
*fn
, opt_pass
*pass
)
2222 execute_pass_list_1 (pass
);
2225 free_dominance_info (CDI_DOMINATORS
);
2226 free_dominance_info (CDI_POST_DOMINATORS
);
2231 /* Write out all LTO data. */
2235 timevar_push (TV_IPA_LTO_GIMPLE_OUT
);
2237 timevar_pop (TV_IPA_LTO_GIMPLE_OUT
);
2238 timevar_push (TV_IPA_LTO_DECL_OUT
);
2239 produce_asm_for_decls ();
2240 timevar_pop (TV_IPA_LTO_DECL_OUT
);
2243 /* Same as execute_pass_list but assume that subpasses of IPA passes
2244 are local passes. If SET is not NULL, write out summaries of only
2245 those node in SET. */
2248 ipa_write_summaries_2 (opt_pass
*pass
, struct lto_out_decl_state
*state
)
2252 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*)pass
;
2253 gcc_assert (!current_function_decl
);
2255 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2256 if (pass
->type
== IPA_PASS
2257 && ipa_pass
->write_summary
2258 && pass
->gate (cfun
))
2260 /* If a timevar is present, start it. */
2262 timevar_push (pass
->tv_id
);
2264 pass_init_dump_file (pass
);
2266 current_pass
= pass
;
2267 ipa_pass
->write_summary ();
2269 pass_fini_dump_file (pass
);
2271 /* If a timevar is present, start it. */
2273 timevar_pop (pass
->tv_id
);
2276 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2277 ipa_write_summaries_2 (pass
->sub
, state
);
2283 /* Helper function of ipa_write_summaries. Creates and destroys the
2284 decl state and calls ipa_write_summaries_2 for all passes that have
2285 summaries. SET is the set of nodes to be written. */
2288 ipa_write_summaries_1 (lto_symtab_encoder_t encoder
)
2290 pass_manager
*passes
= g
->get_passes ();
2291 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2292 state
->symtab_node_encoder
= encoder
;
2294 lto_push_out_decl_state (state
);
2296 gcc_assert (!flag_wpa
);
2297 ipa_write_summaries_2 (passes
->all_regular_ipa_passes
, state
);
2301 gcc_assert (lto_get_out_decl_state () == state
);
2302 lto_pop_out_decl_state ();
2303 lto_delete_out_decl_state (state
);
2306 /* Write out summaries for all the nodes in the callgraph. */
2309 ipa_write_summaries (bool is_omp
)
2311 lto_symtab_encoder_t encoder
;
2313 varpool_node
*vnode
;
2314 struct cgraph_node
*node
;
2315 struct cgraph_node
**order
;
2317 if (!(flag_generate_lto
|| flag_openacc
|| flag_openmp
) || seen_error () )
2320 select_what_to_dump (is_omp
);
2322 encoder
= lto_symtab_encoder_new (false);
2324 /* Create the callgraph set in the same order used in
2325 cgraph_expand_all_functions. This mostly facilitates debugging,
2326 since it causes the gimple file to be processed in the same order
2327 as the source code. */
2328 order
= XCNEWVEC (struct cgraph_node
*, symtab
->cgraph_count
);
2329 order_pos
= ipa_reverse_postorder (order
);
2330 gcc_assert (order_pos
== symtab
->cgraph_count
);
2332 for (i
= order_pos
- 1; i
>= 0; i
--)
2334 struct cgraph_node
*node
= order
[i
];
2336 if (node
->has_gimple_body_p ())
2338 /* When streaming out references to statements as part of some IPA
2339 pass summary, the statements need to have uids assigned and the
2340 following does that for all the IPA passes here. Naturally, this
2341 ordering then matches the one IPA-passes get in their stmt_fixup
2344 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2345 renumber_gimple_stmt_uids ();
2348 if (node
->definition
)
2349 lto_set_symtab_encoder_in_partition (encoder
, node
);
2352 FOR_EACH_DEFINED_FUNCTION (node
)
2354 lto_set_symtab_encoder_in_partition (encoder
, node
);
2355 FOR_EACH_DEFINED_VARIABLE (vnode
)
2356 lto_set_symtab_encoder_in_partition (encoder
, vnode
);
2358 ipa_write_summaries_1 (compute_ltrans_boundary (encoder
));
2363 /* Same as execute_pass_list but assume that subpasses of IPA passes
2364 are local passes. If SET is not NULL, write out optimization summaries of
2365 only those node in SET. */
2368 ipa_write_optimization_summaries_1 (opt_pass
*pass
,
2369 struct lto_out_decl_state
*state
)
2373 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*)pass
;
2374 gcc_assert (!current_function_decl
);
2376 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2377 if (pass
->type
== IPA_PASS
2378 && ipa_pass
->write_optimization_summary
2379 && pass
->gate (cfun
))
2381 /* If a timevar is present, start it. */
2383 timevar_push (pass
->tv_id
);
2385 pass_init_dump_file (pass
);
2387 current_pass
= pass
;
2388 ipa_pass
->write_optimization_summary ();
2390 pass_fini_dump_file (pass
);
2392 /* If a timevar is present, start it. */
2394 timevar_pop (pass
->tv_id
);
2397 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2398 ipa_write_optimization_summaries_1 (pass
->sub
, state
);
2404 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is
2405 NULL, write out all summaries of all nodes. */
2408 ipa_write_optimization_summaries (lto_symtab_encoder_t encoder
)
2410 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2411 lto_symtab_encoder_iterator lsei
;
2412 state
->symtab_node_encoder
= encoder
;
2414 lto_push_out_decl_state (state
);
2415 for (lsei
= lsei_start_function_in_partition (encoder
);
2416 !lsei_end_p (lsei
); lsei_next_function_in_partition (&lsei
))
2418 struct cgraph_node
*node
= lsei_cgraph_node (lsei
);
2419 /* When streaming out references to statements as part of some IPA
2420 pass summary, the statements need to have uids assigned.
2422 For functions newly born at WPA stage we need to initialize
2424 if (node
->definition
2425 && gimple_has_body_p (node
->decl
))
2427 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2428 renumber_gimple_stmt_uids ();
2433 gcc_assert (flag_wpa
);
2434 pass_manager
*passes
= g
->get_passes ();
2435 ipa_write_optimization_summaries_1 (passes
->all_regular_ipa_passes
, state
);
2439 gcc_assert (lto_get_out_decl_state () == state
);
2440 lto_pop_out_decl_state ();
2441 lto_delete_out_decl_state (state
);
2444 /* Same as execute_pass_list but assume that subpasses of IPA passes
2445 are local passes. */
2448 ipa_read_summaries_1 (opt_pass
*pass
)
2452 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2454 gcc_assert (!current_function_decl
);
2456 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2458 if (pass
->gate (cfun
))
2460 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_summary
)
2462 /* If a timevar is present, start it. */
2464 timevar_push (pass
->tv_id
);
2466 pass_init_dump_file (pass
);
2468 current_pass
= pass
;
2469 ipa_pass
->read_summary ();
2471 pass_fini_dump_file (pass
);
2475 timevar_pop (pass
->tv_id
);
2478 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2479 ipa_read_summaries_1 (pass
->sub
);
2486 /* Read all the summaries for all_regular_ipa_passes. */
2489 ipa_read_summaries (void)
2491 pass_manager
*passes
= g
->get_passes ();
2492 ipa_read_summaries_1 (passes
->all_regular_ipa_passes
);
2495 /* Same as execute_pass_list but assume that subpasses of IPA passes
2496 are local passes. */
2499 ipa_read_optimization_summaries_1 (opt_pass
*pass
)
2503 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2505 gcc_assert (!current_function_decl
);
2507 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2509 if (pass
->gate (cfun
))
2511 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_optimization_summary
)
2513 /* If a timevar is present, start it. */
2515 timevar_push (pass
->tv_id
);
2517 pass_init_dump_file (pass
);
2519 current_pass
= pass
;
2520 ipa_pass
->read_optimization_summary ();
2522 pass_fini_dump_file (pass
);
2526 timevar_pop (pass
->tv_id
);
2529 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2530 ipa_read_optimization_summaries_1 (pass
->sub
);
2536 /* Read all the summaries for all_regular_ipa_passes. */
2539 ipa_read_optimization_summaries (void)
2541 pass_manager
*passes
= g
->get_passes ();
2542 ipa_read_optimization_summaries_1 (passes
->all_regular_ipa_passes
);
2545 /* Same as execute_pass_list but assume that subpasses of IPA passes
2546 are local passes. */
2548 execute_ipa_pass_list (opt_pass
*pass
)
2552 gcc_assert (!current_function_decl
);
2554 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2555 if (execute_one_pass (pass
) && pass
->sub
)
2557 if (pass
->sub
->type
== GIMPLE_PASS
)
2559 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START
, NULL
);
2560 do_per_function_toporder ((void (*)(function
*, void *))
2563 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END
, NULL
);
2565 else if (pass
->sub
->type
== SIMPLE_IPA_PASS
2566 || pass
->sub
->type
== IPA_PASS
)
2567 execute_ipa_pass_list (pass
->sub
);
2571 gcc_assert (!current_function_decl
);
2572 symtab
->process_new_functions ();
2578 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
2581 execute_ipa_stmt_fixups (opt_pass
*pass
,
2582 struct cgraph_node
*node
, gimple
*stmts
)
2586 /* Execute all of the IPA_PASSes in the list. */
2587 if (pass
->type
== IPA_PASS
2588 && pass
->gate (cfun
))
2590 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2592 if (ipa_pass
->stmt_fixup
)
2594 pass_init_dump_file (pass
);
2595 /* If a timevar is present, start it. */
2597 timevar_push (pass
->tv_id
);
2599 current_pass
= pass
;
2600 ipa_pass
->stmt_fixup (node
, stmts
);
2604 timevar_pop (pass
->tv_id
);
2605 pass_fini_dump_file (pass
);
2608 execute_ipa_stmt_fixups (pass
->sub
, node
, stmts
);
2614 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */
2617 execute_all_ipa_stmt_fixups (struct cgraph_node
*node
, gimple
*stmts
)
2619 pass_manager
*passes
= g
->get_passes ();
2620 execute_ipa_stmt_fixups (passes
->all_regular_ipa_passes
, node
, stmts
);
2624 extern void debug_properties (unsigned int);
2625 extern void dump_properties (FILE *, unsigned int);
2628 dump_properties (FILE *dump
, unsigned int props
)
2630 fprintf (dump
, "Properties:\n");
2631 if (props
& PROP_gimple_any
)
2632 fprintf (dump
, "PROP_gimple_any\n");
2633 if (props
& PROP_gimple_lcf
)
2634 fprintf (dump
, "PROP_gimple_lcf\n");
2635 if (props
& PROP_gimple_leh
)
2636 fprintf (dump
, "PROP_gimple_leh\n");
2637 if (props
& PROP_cfg
)
2638 fprintf (dump
, "PROP_cfg\n");
2639 if (props
& PROP_ssa
)
2640 fprintf (dump
, "PROP_ssa\n");
2641 if (props
& PROP_no_crit_edges
)
2642 fprintf (dump
, "PROP_no_crit_edges\n");
2643 if (props
& PROP_rtl
)
2644 fprintf (dump
, "PROP_rtl\n");
2645 if (props
& PROP_gimple_lomp
)
2646 fprintf (dump
, "PROP_gimple_lomp\n");
2647 if (props
& PROP_gimple_lcx
)
2648 fprintf (dump
, "PROP_gimple_lcx\n");
2649 if (props
& PROP_gimple_lvec
)
2650 fprintf (dump
, "PROP_gimple_lvec\n");
2651 if (props
& PROP_cfglayout
)
2652 fprintf (dump
, "PROP_cfglayout\n");
2656 debug_properties (unsigned int props
)
2658 dump_properties (stderr
, props
);
2661 /* Called by local passes to see if function is called by already processed nodes.
2662 Because we process nodes in topological order, this means that function is
2663 in recursive cycle or we introduced new direct calls. */
2665 function_called_by_processed_nodes_p (void)
2667 struct cgraph_edge
*e
;
2668 for (e
= cgraph_node::get (current_function_decl
)->callers
;
2672 if (e
->caller
->decl
== current_function_decl
)
2674 if (!e
->caller
->has_gimple_body_p ())
2676 if (TREE_ASM_WRITTEN (e
->caller
->decl
))
2678 if (!e
->caller
->process
&& !e
->caller
->global
.inlined_to
)
2683 fprintf (dump_file
, "Already processed call to:\n");
2684 e
->caller
->dump (dump_file
);
2689 #include "gt-passes.h"