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"
91 /* This is used for debugging. It allows the current pass to printed
92 from anywhere in compilation.
93 The variable current_pass is also used for statistics and plugins. */
94 opt_pass
*current_pass
;
96 static void register_pass_name (opt_pass
*, const char *);
98 /* Most passes are single-instance (within their context) and thus don't
99 need to implement cloning, but passes that support multiple instances
100 *must* provide their own implementation of the clone method.
102 Handle this by providing a default implemenation, but make it a fatal
108 internal_error ("pass %s does not support cloning", name
);
112 opt_pass::gate (function
*)
118 opt_pass::execute (function
*)
123 opt_pass::opt_pass (const pass_data
&data
, context
*ctxt
)
127 static_pass_number (0),
134 pass_manager::execute_early_local_passes ()
136 execute_pass_list (cfun
, pass_early_local_passes_1
->sub
);
140 pass_manager::execute_pass_mode_switching ()
142 return pass_mode_switching_1
->execute (cfun
);
146 /* Call from anywhere to find out what pass this is. Useful for
147 printing out debugging information deep inside an service
150 print_current_pass (FILE *file
)
153 fprintf (file
, "current pass = %s (%d)\n",
154 current_pass
->name
, current_pass
->static_pass_number
);
156 fprintf (file
, "no current pass.\n");
160 /* Call from the debugger to get the current pass name. */
164 print_current_pass (stderr
);
169 /* Global variables used to communicate with passes. */
171 bool first_pass_instance
;
174 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
177 This does nothing for local (non-static) variables, unless the
178 variable is a register variable with DECL_ASSEMBLER_NAME set. In
179 that case, or if the variable is not an automatic, it sets up the
180 RTL and outputs any assembler code (label definition, storage
181 allocation and initialization).
183 DECL is the declaration. TOP_LEVEL is nonzero
184 if this declaration is not within a function. */
187 rest_of_decl_compilation (tree decl
,
191 bool finalize
= true;
193 /* We deferred calling assemble_alias so that we could collect
194 other attributes such as visibility. Emit the alias now. */
198 alias
= lookup_attribute ("alias", DECL_ATTRIBUTES (decl
));
201 alias
= TREE_VALUE (TREE_VALUE (alias
));
202 alias
= get_identifier (TREE_STRING_POINTER (alias
));
203 /* A quirk of the initial implementation of aliases required that the
204 user add "extern" to all of them. Which is silly, but now
205 historical. Do note that the symbol is in fact locally defined. */
206 DECL_EXTERNAL (decl
) = 0;
207 TREE_STATIC (decl
) = 1;
208 assemble_alias (decl
, alias
);
213 /* Can't defer this, because it needs to happen before any
214 later function definitions are processed. */
215 if (DECL_ASSEMBLER_NAME_SET_P (decl
) && DECL_REGISTER (decl
))
216 make_decl_rtl (decl
);
218 /* Forward declarations for nested functions are not "external",
219 but we need to treat them as if they were. */
220 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
221 || TREE_CODE (decl
) == FUNCTION_DECL
)
223 timevar_push (TV_VARCONST
);
225 /* Don't output anything when a tentative file-scope definition
226 is seen. But at end of compilation, do output code for them.
228 We do output all variables and rely on
229 callgraph code to defer them except for forward declarations
230 (see gcc.c-torture/compile/920624-1.c) */
232 || !DECL_DEFER_OUTPUT (decl
)
233 || DECL_INITIAL (decl
))
234 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_HAS_VALUE_EXPR_P (decl
))
235 && !DECL_EXTERNAL (decl
))
237 /* When reading LTO unit, we also read varpool, so do not
239 if (in_lto_p
&& !at_end
)
241 else if (finalize
&& TREE_CODE (decl
) != FUNCTION_DECL
)
242 varpool_finalize_decl (decl
);
245 #ifdef ASM_FINISH_DECLARE_OBJECT
246 if (decl
== last_assemble_variable_decl
)
248 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
253 timevar_pop (TV_VARCONST
);
255 else if (TREE_CODE (decl
) == TYPE_DECL
256 /* Like in rest_of_type_compilation, avoid confusing the debug
257 information machinery when there are errors. */
260 timevar_push (TV_SYMOUT
);
261 debug_hooks
->type_decl (decl
, !top_level
);
262 timevar_pop (TV_SYMOUT
);
265 /* Let cgraph know about the existence of variables. */
266 if (in_lto_p
&& !at_end
)
268 else if (TREE_CODE (decl
) == VAR_DECL
&& !DECL_EXTERNAL (decl
)
269 && TREE_STATIC (decl
))
270 varpool_node_for_decl (decl
);
273 /* Called after finishing a record, union or enumeral type. */
276 rest_of_type_compilation (tree type
, int toplev
)
278 /* Avoid confusing the debug information machinery when there are
283 timevar_push (TV_SYMOUT
);
284 debug_hooks
->type_decl (TYPE_STUB_DECL (type
), !toplev
);
285 timevar_pop (TV_SYMOUT
);
292 finish_optimization_passes (void)
295 struct dump_file_info
*dfi
;
297 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
299 timevar_push (TV_DUMP
);
300 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
302 dumps
->dump_start (pass_profile_1
->static_pass_number
, NULL
);
304 dumps
->dump_finish (pass_profile_1
->static_pass_number
);
309 dumps
->dump_start (pass_profile_1
->static_pass_number
, NULL
);
310 print_combine_total_stats ();
311 dumps
->dump_finish (pass_profile_1
->static_pass_number
);
314 /* Do whatever is necessary to finish printing the graphs. */
315 for (i
= TDI_end
; (dfi
= dumps
->get_dump_file_info (i
)) != NULL
; ++i
)
316 if (dumps
->dump_initialized_p (i
)
317 && (dfi
->pflags
& TDF_GRAPH
) != 0
318 && (name
= dumps
->get_dump_file_name (i
)) != NULL
)
320 finish_graph_dump_file (name
);
324 timevar_pop (TV_DUMP
);
328 execute_all_early_local_passes (void)
330 /* Once this pass (and its sub-passes) are complete, all functions
331 will be in SSA form. Technically this state change is happening
332 a tad early, since the sub-passes have not yet run, but since
333 none of the sub-passes are IPA passes and do not create new
334 functions, this is ok. We're setting this value for the benefit
335 of IPA passes that follow. */
336 if (cgraph_state
< CGRAPH_STATE_IPA_SSA
)
337 cgraph_state
= CGRAPH_STATE_IPA_SSA
;
343 const pass_data pass_data_early_local_passes
=
345 SIMPLE_IPA_PASS
, /* type */
346 "early_local_cleanups", /* name */
347 OPTGROUP_NONE
, /* optinfo_flags */
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 virtual unsigned int execute (function
*)
372 return execute_all_early_local_passes ();
375 }; // class pass_early_local_passes
379 simple_ipa_opt_pass
*
380 make_pass_early_local_passes (gcc::context
*ctxt
)
382 return new pass_early_local_passes (ctxt
);
387 const pass_data pass_data_all_early_optimizations
=
389 GIMPLE_PASS
, /* type */
390 "early_optimizations", /* name */
391 OPTGROUP_NONE
, /* optinfo_flags */
393 0, /* properties_required */
394 0, /* properties_provided */
395 0, /* properties_destroyed */
396 0, /* todo_flags_start */
397 0, /* todo_flags_finish */
400 class pass_all_early_optimizations
: public gimple_opt_pass
403 pass_all_early_optimizations (gcc::context
*ctxt
)
404 : gimple_opt_pass (pass_data_all_early_optimizations
, ctxt
)
407 /* opt_pass methods: */
408 virtual bool gate (function
*)
410 return (optimize
>= 1
411 /* Don't bother doing anything if the program has errors. */
415 }; // class pass_all_early_optimizations
419 static gimple_opt_pass
*
420 make_pass_all_early_optimizations (gcc::context
*ctxt
)
422 return new pass_all_early_optimizations (ctxt
);
427 const pass_data pass_data_all_optimizations
=
429 GIMPLE_PASS
, /* type */
430 "*all_optimizations", /* name */
431 OPTGROUP_NONE
, /* optinfo_flags */
432 TV_OPTIMIZE
, /* tv_id */
433 0, /* properties_required */
434 0, /* properties_provided */
435 0, /* properties_destroyed */
436 0, /* todo_flags_start */
437 0, /* todo_flags_finish */
440 class pass_all_optimizations
: public gimple_opt_pass
443 pass_all_optimizations (gcc::context
*ctxt
)
444 : gimple_opt_pass (pass_data_all_optimizations
, ctxt
)
447 /* opt_pass methods: */
448 virtual bool gate (function
*) { return optimize
>= 1 && !optimize_debug
; }
450 }; // class pass_all_optimizations
454 static gimple_opt_pass
*
455 make_pass_all_optimizations (gcc::context
*ctxt
)
457 return new pass_all_optimizations (ctxt
);
462 const pass_data pass_data_all_optimizations_g
=
464 GIMPLE_PASS
, /* type */
465 "*all_optimizations_g", /* name */
466 OPTGROUP_NONE
, /* optinfo_flags */
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 TV_REST_OF_COMPILATION
, /* tv_id */
503 PROP_rtl
, /* properties_required */
504 0, /* properties_provided */
505 0, /* properties_destroyed */
506 0, /* todo_flags_start */
507 0, /* todo_flags_finish */
510 class pass_rest_of_compilation
: public rtl_opt_pass
513 pass_rest_of_compilation (gcc::context
*ctxt
)
514 : rtl_opt_pass (pass_data_rest_of_compilation
, ctxt
)
517 /* opt_pass methods: */
518 virtual bool gate (function
*)
520 /* Early return if there were errors. We can run afoul of our
521 consistency checks, and there's not really much point in fixing them. */
522 return !(rtl_dump_and_exit
|| flag_syntax_only
|| seen_error ());
525 }; // class pass_rest_of_compilation
529 static rtl_opt_pass
*
530 make_pass_rest_of_compilation (gcc::context
*ctxt
)
532 return new pass_rest_of_compilation (ctxt
);
537 const pass_data pass_data_postreload
=
540 "*all-postreload", /* name */
541 OPTGROUP_NONE
, /* optinfo_flags */
542 TV_POSTRELOAD
, /* tv_id */
543 PROP_rtl
, /* properties_required */
544 0, /* properties_provided */
545 0, /* properties_destroyed */
546 0, /* todo_flags_start */
547 0, /* todo_flags_finish */
550 class pass_postreload
: public rtl_opt_pass
553 pass_postreload (gcc::context
*ctxt
)
554 : rtl_opt_pass (pass_data_postreload
, ctxt
)
557 /* opt_pass methods: */
558 virtual bool gate (function
*) { return reload_completed
; }
560 }; // class pass_postreload
564 static rtl_opt_pass
*
565 make_pass_postreload (gcc::context
*ctxt
)
567 return new pass_postreload (ctxt
);
572 /* Set the static pass number of pass PASS to ID and record that
573 in the mapping from static pass number to pass. */
577 set_pass_for_id (int id
, opt_pass
*pass
)
579 pass
->static_pass_number
= id
;
580 if (passes_by_id_size
<= id
)
582 passes_by_id
= XRESIZEVEC (opt_pass
*, passes_by_id
, id
+ 1);
583 memset (passes_by_id
+ passes_by_id_size
, 0,
584 (id
+ 1 - passes_by_id_size
) * sizeof (void *));
585 passes_by_id_size
= id
+ 1;
587 passes_by_id
[id
] = pass
;
590 /* Return the pass with the static pass number ID. */
593 pass_manager::get_pass_for_id (int id
) const
595 if (id
>= passes_by_id_size
)
597 return passes_by_id
[id
];
600 /* Iterate over the pass tree allocating dump file numbers. We want
601 to do this depth first, and independent of whether the pass is
605 register_one_dump_file (opt_pass
*pass
)
607 g
->get_passes ()->register_one_dump_file (pass
);
611 pass_manager::register_one_dump_file (opt_pass
*pass
)
613 char *dot_name
, *flag_name
, *glob_name
;
614 const char *name
, *full_name
, *prefix
;
617 int optgroup_flags
= OPTGROUP_NONE
;
618 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
620 /* See below in next_pass_1. */
622 if (pass
->static_pass_number
!= -1)
623 sprintf (num
, "%d", ((int) pass
->static_pass_number
< 0
624 ? 1 : pass
->static_pass_number
));
626 /* The name is both used to identify the pass for the purposes of plugins,
627 and to specify dump file name and option.
628 The latter two might want something short which is not quite unique; for
629 that reason, we may have a disambiguating prefix, followed by a space
630 to mark the start of the following dump file name / option string. */
631 name
= strchr (pass
->name
, ' ');
632 name
= name
? name
+ 1 : pass
->name
;
633 dot_name
= concat (".", name
, num
, NULL
);
634 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
638 optgroup_flags
|= OPTGROUP_IPA
;
640 else if (pass
->type
== GIMPLE_PASS
)
651 flag_name
= concat (prefix
, name
, num
, NULL
);
652 glob_name
= concat (prefix
, name
, NULL
);
653 optgroup_flags
|= pass
->optinfo_flags
;
654 /* For any passes that do not have an optgroup set, and which are not
655 IPA passes setup above, set the optgroup to OPTGROUP_OTHER so that
656 any dump messages are emitted properly under -fopt-info(-optall). */
657 if (optgroup_flags
== OPTGROUP_NONE
)
658 optgroup_flags
= OPTGROUP_OTHER
;
659 id
= dumps
->dump_register (dot_name
, flag_name
, glob_name
, flags
,
661 set_pass_for_id (id
, pass
);
662 full_name
= concat (prefix
, pass
->name
, num
, NULL
);
663 register_pass_name (pass
, full_name
);
664 free (CONST_CAST (char *, full_name
));
667 /* Register the dump files for the pass_manager starting at PASS. */
670 pass_manager::register_dump_files (opt_pass
*pass
)
674 if (pass
->name
&& pass
->name
[0] != '*')
675 register_one_dump_file (pass
);
678 register_dump_files (pass
->sub
);
685 /* Helper for pass_registry hash table. */
687 struct pass_registry_hasher
: default_hashmap_traits
689 static inline hashval_t
hash (const char *);
690 static inline bool equal_keys (const char *, const char *);
693 /* Pass registry hash function. */
696 pass_registry_hasher::hash (const char *name
)
698 return htab_hash_string (name
);
701 /* Hash equal function */
704 pass_registry_hasher::equal_keys (const char *s1
, const char *s2
)
706 return !strcmp (s1
, s2
);
709 static hash_map
<const char *, opt_pass
*, pass_registry_hasher
>
712 /* Register PASS with NAME. */
715 register_pass_name (opt_pass
*pass
, const char *name
)
717 if (!name_to_pass_map
)
719 = new hash_map
<const char *, opt_pass
*, pass_registry_hasher
> (256);
721 if (name_to_pass_map
->get (name
))
722 return; /* Ignore plugin passes. */
724 const char *unique_name
= xstrdup (name
);
725 name_to_pass_map
->put (unique_name
, pass
);
728 /* Map from pass id to canonicalized pass name. */
730 typedef const char *char_ptr
;
731 static vec
<char_ptr
> pass_tab
= vNULL
;
733 /* Callback function for traversing NAME_TO_PASS_MAP. */
736 passes_pass_traverse (const char *const &name
, opt_pass
*const &pass
, void *)
738 gcc_assert (pass
->static_pass_number
> 0);
739 gcc_assert (pass_tab
.exists ());
741 pass_tab
[pass
->static_pass_number
] = name
;
746 /* The function traverses NAME_TO_PASS_MAP and creates a pass info
747 table for dumping purpose. */
750 create_pass_tab (void)
752 if (!flag_dump_passes
)
755 pass_tab
.safe_grow_cleared (g
->get_passes ()->passes_by_id_size
+ 1);
756 name_to_pass_map
->traverse
<void *, passes_pass_traverse
> (NULL
);
759 static bool override_gate_status (opt_pass
*, tree
, bool);
761 /* Dump the instantiated name for PASS. IS_ON indicates if PASS
762 is turned on or not. */
765 dump_one_pass (opt_pass
*pass
, int pass_indent
)
767 int indent
= 3 * pass_indent
;
769 bool is_on
, is_really_on
;
771 is_on
= pass
->gate (cfun
);
772 is_really_on
= override_gate_status (pass
, current_function_decl
, is_on
);
774 if (pass
->static_pass_number
<= 0)
777 pn
= pass_tab
[pass
->static_pass_number
];
779 fprintf (stderr
, "%*s%-40s%*s:%s%s\n", indent
, " ", pn
,
780 (15 - indent
< 0 ? 0 : 15 - indent
), " ",
781 is_on
? " ON" : " OFF",
782 ((!is_on
) == (!is_really_on
) ? ""
783 : (is_really_on
? " (FORCED_ON)" : " (FORCED_OFF)")));
786 /* Dump pass list PASS with indentation INDENT. */
789 dump_pass_list (opt_pass
*pass
, int indent
)
793 dump_one_pass (pass
, indent
);
795 dump_pass_list (pass
->sub
, indent
+ 1);
801 /* Dump all optimization passes. */
806 g
->get_passes ()->dump_passes ();
810 pass_manager::dump_passes () const
812 struct cgraph_node
*n
, *node
= NULL
;
816 FOR_EACH_FUNCTION (n
)
817 if (DECL_STRUCT_FUNCTION (n
->decl
))
826 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
828 dump_pass_list (all_lowering_passes
, 1);
829 dump_pass_list (all_small_ipa_passes
, 1);
830 dump_pass_list (all_regular_ipa_passes
, 1);
831 dump_pass_list (all_late_ipa_passes
, 1);
832 dump_pass_list (all_passes
, 1);
838 /* Returns the pass with NAME. */
841 get_pass_by_name (const char *name
)
843 opt_pass
**p
= name_to_pass_map
->get (name
);
851 /* Range [start, last]. */
857 const char *assem_name
;
858 struct uid_range
*next
;
861 typedef struct uid_range
*uid_range_p
;
864 static vec
<uid_range_p
>
865 enabled_pass_uid_range_tab
= vNULL
;
866 static vec
<uid_range_p
>
867 disabled_pass_uid_range_tab
= vNULL
;
870 /* Parse option string for -fdisable- and -fenable-
871 The syntax of the options:
874 -fdisable-<pass_name>
876 -fenable-<pass_name>=s1:e1,s2:e2,...
877 -fdisable-<pass_name>=s1:e1,s2:e2,...
881 enable_disable_pass (const char *arg
, bool is_enable
)
884 char *range_str
, *phase_name
;
885 char *argstr
= xstrdup (arg
);
886 vec
<uid_range_p
> *tab
= 0;
888 range_str
= strchr (argstr
,'=');
899 error ("unrecognized option -fenable");
901 error ("unrecognized option -fdisable");
905 pass
= get_pass_by_name (phase_name
);
906 if (!pass
|| pass
->static_pass_number
== -1)
909 error ("unknown pass %s specified in -fenable", phase_name
);
911 error ("unknown pass %s specified in -fdisable", phase_name
);
917 tab
= &enabled_pass_uid_range_tab
;
919 tab
= &disabled_pass_uid_range_tab
;
921 if ((unsigned) pass
->static_pass_number
>= tab
->length ())
922 tab
->safe_grow_cleared (pass
->static_pass_number
+ 1);
927 uid_range_p new_range
= XCNEW (struct uid_range
);
929 new_range
->start
= 0;
930 new_range
->last
= (unsigned)-1;
932 slot
= (*tab
)[pass
->static_pass_number
];
933 new_range
->next
= slot
;
934 (*tab
)[pass
->static_pass_number
] = new_range
;
936 inform (UNKNOWN_LOCATION
, "enable pass %s for functions in the range "
937 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
939 inform (UNKNOWN_LOCATION
, "disable pass %s for functions in the range "
940 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
944 char *next_range
= NULL
;
945 char *one_range
= range_str
;
946 char *end_val
= NULL
;
951 uid_range_p new_range
;
952 char *invalid
= NULL
;
954 char *func_name
= NULL
;
956 next_range
= strchr (one_range
, ',');
963 end_val
= strchr (one_range
, ':');
969 start
= strtol (one_range
, &invalid
, 10);
970 if (*invalid
|| start
< 0)
972 if (end_val
|| (one_range
[0] >= '0'
973 && one_range
[0] <= '9'))
975 error ("Invalid range %s in option %s",
977 is_enable
? "-fenable" : "-fdisable");
981 func_name
= one_range
;
985 new_range
= XCNEW (struct uid_range
);
988 new_range
->start
= (unsigned) start
;
989 new_range
->last
= (unsigned) start
;
993 new_range
->start
= (unsigned) -1;
994 new_range
->last
= (unsigned) -1;
995 new_range
->assem_name
= xstrdup (func_name
);
1000 long last
= strtol (end_val
, &invalid
, 10);
1001 if (*invalid
|| last
< start
)
1003 error ("Invalid range %s in option %s",
1005 is_enable
? "-fenable" : "-fdisable");
1009 new_range
= XCNEW (struct uid_range
);
1010 new_range
->start
= (unsigned) start
;
1011 new_range
->last
= (unsigned) last
;
1014 slot
= (*tab
)[pass
->static_pass_number
];
1015 new_range
->next
= slot
;
1016 (*tab
)[pass
->static_pass_number
] = new_range
;
1019 if (new_range
->assem_name
)
1020 inform (UNKNOWN_LOCATION
,
1021 "enable pass %s for function %s",
1022 phase_name
, new_range
->assem_name
);
1024 inform (UNKNOWN_LOCATION
,
1025 "enable pass %s for functions in the range of [%u, %u]",
1026 phase_name
, new_range
->start
, new_range
->last
);
1030 if (new_range
->assem_name
)
1031 inform (UNKNOWN_LOCATION
,
1032 "disable pass %s for function %s",
1033 phase_name
, new_range
->assem_name
);
1035 inform (UNKNOWN_LOCATION
,
1036 "disable pass %s for functions in the range of [%u, %u]",
1037 phase_name
, new_range
->start
, new_range
->last
);
1040 one_range
= next_range
;
1041 } while (next_range
);
1047 /* Enable pass specified by ARG. */
1050 enable_pass (const char *arg
)
1052 enable_disable_pass (arg
, true);
1055 /* Disable pass specified by ARG. */
1058 disable_pass (const char *arg
)
1060 enable_disable_pass (arg
, false);
1063 /* Returns true if PASS is explicitly enabled/disabled for FUNC. */
1066 is_pass_explicitly_enabled_or_disabled (opt_pass
*pass
,
1068 vec
<uid_range_p
> tab
)
1070 uid_range_p slot
, range
;
1072 const char *aname
= NULL
;
1075 || (unsigned) pass
->static_pass_number
>= tab
.length ()
1076 || pass
->static_pass_number
== -1)
1079 slot
= tab
[pass
->static_pass_number
];
1083 cgraph_uid
= func
? cgraph_node::get (func
)->uid
: 0;
1084 if (func
&& DECL_ASSEMBLER_NAME_SET_P (func
))
1085 aname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func
));
1090 if ((unsigned) cgraph_uid
>= range
->start
1091 && (unsigned) cgraph_uid
<= range
->last
)
1093 if (range
->assem_name
&& aname
1094 && !strcmp (range
->assem_name
, aname
))
1096 range
= range
->next
;
1103 /* Update static_pass_number for passes (and the flag
1104 TODO_mark_first_instance).
1106 Passes are constructed with static_pass_number preinitialized to 0
1108 This field is used in two different ways: initially as instance numbers
1109 of their kind, and then as ids within the entire pass manager.
1111 Within pass_manager::pass_manager:
1113 * In add_pass_instance(), as called by next_pass_1 in
1114 NEXT_PASS in init_optimization_passes
1116 * When the initial instance of a pass within a pass manager is seen,
1117 it is flagged, and its static_pass_number is set to -1
1119 * On subsequent times that it is seen, the static pass number
1120 is decremented each time, so that if there are e.g. 4 dups,
1121 they have static_pass_number -4, 2, 3, 4 respectively (note
1122 how the initial one is negative and gives the count); these
1123 can be thought of as instance numbers of the specific pass
1125 * Within the register_dump_files () traversal, set_pass_for_id()
1126 is called on each pass, using these instance numbers to create
1127 dumpfile switches, and then overwriting them with a pass id,
1128 which are global to the whole pass manager (based on
1129 (TDI_end + current value of extra_dump_files_in_use) ) */
1132 add_pass_instance (opt_pass
*new_pass
, bool track_duplicates
,
1133 opt_pass
*initial_pass
)
1135 /* Are we dealing with the first pass of its kind, or a clone? */
1136 if (new_pass
!= initial_pass
)
1138 /* We're dealing with a clone. */
1139 new_pass
->todo_flags_start
&= ~TODO_mark_first_instance
;
1141 /* Indicate to register_dump_files that this pass has duplicates,
1142 and so it should rename the dump file. The first instance will
1143 be -1, and be number of duplicates = -static_pass_number - 1.
1144 Subsequent instances will be > 0 and just the duplicate number. */
1145 if ((new_pass
->name
&& new_pass
->name
[0] != '*') || track_duplicates
)
1147 initial_pass
->static_pass_number
-= 1;
1148 new_pass
->static_pass_number
= -initial_pass
->static_pass_number
;
1153 /* We're dealing with the first pass of its kind. */
1154 new_pass
->todo_flags_start
|= TODO_mark_first_instance
;
1155 new_pass
->static_pass_number
= -1;
1157 invoke_plugin_callbacks (PLUGIN_NEW_PASS
, new_pass
);
1161 /* Add a pass to the pass list. Duplicate the pass if it's already
1165 next_pass_1 (opt_pass
**list
, opt_pass
*pass
, opt_pass
*initial_pass
)
1167 /* Every pass should have a name so that plugins can refer to them. */
1168 gcc_assert (pass
->name
!= NULL
);
1170 add_pass_instance (pass
, false, initial_pass
);
1173 return &(*list
)->next
;
1176 /* List node for an inserted pass instance. We need to keep track of all
1177 the newly-added pass instances (with 'added_pass_nodes' defined below)
1178 so that we can register their dump files after pass-positioning is finished.
1179 Registering dumping files needs to be post-processed or the
1180 static_pass_number of the opt_pass object would be modified and mess up
1181 the dump file names of future pass instances to be added. */
1183 struct pass_list_node
1186 struct pass_list_node
*next
;
1189 static struct pass_list_node
*added_pass_nodes
= NULL
;
1190 static struct pass_list_node
*prev_added_pass_node
;
1192 /* Insert the pass at the proper position. Return true if the pass
1193 is successfully added.
1195 NEW_PASS_INFO - new pass to be inserted
1196 PASS_LIST - root of the pass list to insert the new pass to */
1199 position_pass (struct register_pass_info
*new_pass_info
, opt_pass
**pass_list
)
1201 opt_pass
*pass
= *pass_list
, *prev_pass
= NULL
;
1202 bool success
= false;
1204 for ( ; pass
; prev_pass
= pass
, pass
= pass
->next
)
1206 /* Check if the current pass is of the same type as the new pass and
1207 matches the name and the instance number of the reference pass. */
1208 if (pass
->type
== new_pass_info
->pass
->type
1210 && !strcmp (pass
->name
, new_pass_info
->reference_pass_name
)
1211 && ((new_pass_info
->ref_pass_instance_number
== 0)
1212 || (new_pass_info
->ref_pass_instance_number
==
1213 pass
->static_pass_number
)
1214 || (new_pass_info
->ref_pass_instance_number
== 1
1215 && pass
->todo_flags_start
& TODO_mark_first_instance
)))
1218 struct pass_list_node
*new_pass_node
;
1220 if (new_pass_info
->ref_pass_instance_number
== 0)
1222 new_pass
= new_pass_info
->pass
->clone ();
1223 add_pass_instance (new_pass
, true, new_pass_info
->pass
);
1227 new_pass
= new_pass_info
->pass
;
1228 add_pass_instance (new_pass
, true, new_pass
);
1231 /* Insert the new pass instance based on the positioning op. */
1232 switch (new_pass_info
->pos_op
)
1234 case PASS_POS_INSERT_AFTER
:
1235 new_pass
->next
= pass
->next
;
1236 pass
->next
= new_pass
;
1238 /* Skip newly inserted pass to avoid repeated
1239 insertions in the case where the new pass and the
1240 existing one have the same name. */
1243 case PASS_POS_INSERT_BEFORE
:
1244 new_pass
->next
= pass
;
1246 prev_pass
->next
= new_pass
;
1248 *pass_list
= new_pass
;
1250 case PASS_POS_REPLACE
:
1251 new_pass
->next
= pass
->next
;
1253 prev_pass
->next
= new_pass
;
1255 *pass_list
= new_pass
;
1256 new_pass
->sub
= pass
->sub
;
1257 new_pass
->tv_id
= pass
->tv_id
;
1261 error ("invalid pass positioning operation");
1265 /* Save the newly added pass (instance) in the added_pass_nodes
1266 list so that we can register its dump file later. Note that
1267 we cannot register the dump file now because doing so will modify
1268 the static_pass_number of the opt_pass object and therefore
1269 mess up the dump file name of future instances. */
1270 new_pass_node
= XCNEW (struct pass_list_node
);
1271 new_pass_node
->pass
= new_pass
;
1272 if (!added_pass_nodes
)
1273 added_pass_nodes
= new_pass_node
;
1275 prev_added_pass_node
->next
= new_pass_node
;
1276 prev_added_pass_node
= new_pass_node
;
1281 if (pass
->sub
&& position_pass (new_pass_info
, &pass
->sub
))
1288 /* Hooks a new pass into the pass lists.
1290 PASS_INFO - pass information that specifies the opt_pass object,
1291 reference pass, instance number, and how to position
1295 register_pass (struct register_pass_info
*pass_info
)
1297 g
->get_passes ()->register_pass (pass_info
);
1301 register_pass (opt_pass
* pass
, pass_positioning_ops pos
,
1302 const char* ref_pass_name
, int ref_pass_inst_number
)
1304 register_pass_info i
;
1306 i
.reference_pass_name
= ref_pass_name
;
1307 i
.ref_pass_instance_number
= ref_pass_inst_number
;
1310 g
->get_passes ()->register_pass (&i
);
1314 pass_manager::register_pass (struct register_pass_info
*pass_info
)
1316 bool all_instances
, success
;
1317 gcc::dump_manager
*dumps
= m_ctxt
->get_dumps ();
1319 /* The checks below could fail in buggy plugins. Existing GCC
1320 passes should never fail these checks, so we mention plugin in
1322 if (!pass_info
->pass
)
1323 fatal_error ("plugin cannot register a missing pass");
1325 if (!pass_info
->pass
->name
)
1326 fatal_error ("plugin cannot register an unnamed pass");
1328 if (!pass_info
->reference_pass_name
)
1330 ("plugin cannot register pass %qs without reference pass name",
1331 pass_info
->pass
->name
);
1333 /* Try to insert the new pass to the pass lists. We need to check
1334 all five lists as the reference pass could be in one (or all) of
1336 all_instances
= pass_info
->ref_pass_instance_number
== 0;
1337 success
= position_pass (pass_info
, &all_lowering_passes
);
1338 if (!success
|| all_instances
)
1339 success
|= position_pass (pass_info
, &all_small_ipa_passes
);
1340 if (!success
|| all_instances
)
1341 success
|= position_pass (pass_info
, &all_regular_ipa_passes
);
1342 if (!success
|| all_instances
)
1343 success
|= position_pass (pass_info
, &all_late_ipa_passes
);
1344 if (!success
|| all_instances
)
1345 success
|= position_pass (pass_info
, &all_passes
);
1348 ("pass %qs not found but is referenced by new pass %qs",
1349 pass_info
->reference_pass_name
, pass_info
->pass
->name
);
1351 /* OK, we have successfully inserted the new pass. We need to register
1352 the dump files for the newly added pass and its duplicates (if any).
1353 Because the registration of plugin/backend passes happens after the
1354 command-line options are parsed, the options that specify single
1355 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
1356 passes. Therefore we currently can only enable dumping of
1357 new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
1358 are specified. While doing so, we also delete the pass_list_node
1359 objects created during pass positioning. */
1360 while (added_pass_nodes
)
1362 struct pass_list_node
*next_node
= added_pass_nodes
->next
;
1363 enum tree_dump_index tdi
;
1364 register_one_dump_file (added_pass_nodes
->pass
);
1365 if (added_pass_nodes
->pass
->type
== SIMPLE_IPA_PASS
1366 || added_pass_nodes
->pass
->type
== IPA_PASS
)
1368 else if (added_pass_nodes
->pass
->type
== GIMPLE_PASS
)
1372 /* Check if dump-all flag is specified. */
1373 if (dumps
->get_dump_file_info (tdi
)->pstate
)
1374 dumps
->get_dump_file_info (added_pass_nodes
->pass
->static_pass_number
)
1375 ->pstate
= dumps
->get_dump_file_info (tdi
)->pstate
;
1376 XDELETE (added_pass_nodes
);
1377 added_pass_nodes
= next_node
;
1381 /* Construct the pass tree. The sequencing of passes is driven by
1382 the cgraph routines:
1384 finalize_compilation_unit ()
1385 for each node N in the cgraph
1386 cgraph_analyze_function (N)
1387 cgraph_lower_function (N) -> all_lowering_passes
1389 If we are optimizing, compile is then invoked:
1392 ipa_passes () -> all_small_ipa_passes
1393 -> Analysis of all_regular_ipa_passes
1394 * possible LTO streaming at copmilation time *
1395 -> Execution of all_regular_ipa_passes
1396 * possible LTO streaming at link time *
1397 -> all_late_ipa_passes
1398 expand_all_functions ()
1399 for each node N in the cgraph
1400 expand_function (N) -> Transformation of all_regular_ipa_passes
1405 pass_manager::operator new (size_t sz
)
1407 /* Ensure that all fields of the pass manager are zero-initialized. */
1408 return xcalloc (1, sz
);
1411 pass_manager::pass_manager (context
*ctxt
)
1412 : all_passes (NULL
), all_small_ipa_passes (NULL
), all_lowering_passes (NULL
),
1413 all_regular_ipa_passes (NULL
),
1414 all_late_ipa_passes (NULL
), passes_by_id (NULL
), passes_by_id_size (0),
1419 /* Initialize the pass_lists array. */
1420 #define DEF_PASS_LIST(LIST) pass_lists[PASS_LIST_NO_##LIST] = &LIST;
1422 #undef DEF_PASS_LIST
1424 /* Build the tree of passes. */
1426 #define INSERT_PASSES_AFTER(PASS) \
1429 #define PUSH_INSERT_PASSES_WITHIN(PASS) \
1431 opt_pass **p = &(PASS ## _1)->sub;
1433 #define POP_INSERT_PASSES() \
1436 #define NEXT_PASS(PASS, NUM) \
1438 gcc_assert (NULL == PASS ## _ ## NUM); \
1440 PASS ## _1 = make_##PASS (m_ctxt); \
1443 gcc_assert (PASS ## _1); \
1444 PASS ## _ ## NUM = PASS ## _1->clone (); \
1446 p = next_pass_1 (p, PASS ## _ ## NUM, PASS ## _1); \
1449 #define TERMINATE_PASS_LIST() \
1452 #include "pass-instances.def"
1454 #undef INSERT_PASSES_AFTER
1455 #undef PUSH_INSERT_PASSES_WITHIN
1456 #undef POP_INSERT_PASSES
1458 #undef TERMINATE_PASS_LIST
1460 /* Register the passes with the tree dump code. */
1461 register_dump_files (all_lowering_passes
);
1462 register_dump_files (all_small_ipa_passes
);
1463 register_dump_files (all_regular_ipa_passes
);
1464 register_dump_files (all_late_ipa_passes
);
1465 register_dump_files (all_passes
);
1468 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1469 function CALLBACK for every function in the call graph. Otherwise,
1470 call CALLBACK on the current function. */
1473 do_per_function (void (*callback
) (function
*, void *data
), void *data
)
1475 if (current_function_decl
)
1476 callback (cfun
, data
);
1479 struct cgraph_node
*node
;
1480 FOR_EACH_DEFINED_FUNCTION (node
)
1481 if (node
->analyzed
&& gimple_has_body_p (node
->decl
)
1482 && (!node
->clone_of
|| node
->decl
!= node
->clone_of
->decl
))
1483 callback (DECL_STRUCT_FUNCTION (node
->decl
), data
);
1487 /* Because inlining might remove no-longer reachable nodes, we need to
1488 keep the array visible to garbage collector to avoid reading collected
1491 static GTY ((length ("nnodes"))) cgraph_node
**order
;
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.
1496 This function is global so that plugins can use it. */
1498 do_per_function_toporder (void (*callback
) (function
*, void *data
), void *data
)
1502 if (current_function_decl
)
1503 callback (cfun
, data
);
1506 gcc_assert (!order
);
1507 order
= ggc_vec_alloc
<cgraph_node
*> (cgraph_n_nodes
);
1508 nnodes
= ipa_reverse_postorder (order
);
1509 for (i
= nnodes
- 1; i
>= 0; i
--)
1510 order
[i
]->process
= 1;
1511 for (i
= nnodes
- 1; i
>= 0; i
--)
1513 struct cgraph_node
*node
= order
[i
];
1515 /* Allow possibly removed nodes to be garbage collected. */
1518 if (node
->has_gimple_body_p ())
1519 callback (DECL_STRUCT_FUNCTION (node
->decl
), data
);
1527 /* Helper function to perform function body dump. */
1530 execute_function_dump (function
*fn
, void *data
)
1532 opt_pass
*pass
= (opt_pass
*)data
;
1538 if (fn
->curr_properties
& PROP_trees
)
1539 dump_function_to_file (fn
->decl
, dump_file
, dump_flags
);
1541 print_rtl_with_bb (dump_file
, get_insns (), dump_flags
);
1543 /* Flush the file. If verification fails, we won't be able to
1544 close the file before aborting. */
1547 if ((fn
->curr_properties
& PROP_cfg
)
1548 && (dump_flags
& TDF_GRAPH
))
1550 if (!pass
->graph_dump_initialized
)
1552 clean_graph_dump_file (dump_file_name
);
1553 pass
->graph_dump_initialized
= true;
1555 print_graph_cfg (dump_file_name
, fn
);
1562 static struct profile_record
*profile_record
;
1564 /* Do profile consistency book-keeping for the pass with static number INDEX.
1565 If SUBPASS is zero, we run _before_ the pass, and if SUBPASS is one, then
1566 we run _after_ the pass. RUN is true if the pass really runs, or FALSE
1567 if we are only book-keeping on passes that may have selectively disabled
1568 themselves on a given function. */
1570 check_profile_consistency (int index
, int subpass
, bool run
)
1572 pass_manager
*passes
= g
->get_passes ();
1575 if (!profile_record
)
1576 profile_record
= XCNEWVEC (struct profile_record
,
1577 passes
->passes_by_id_size
);
1578 gcc_assert (index
< passes
->passes_by_id_size
&& index
>= 0);
1579 gcc_assert (subpass
< 2);
1580 profile_record
[index
].run
|= run
;
1581 account_profile_record (&profile_record
[index
], subpass
);
1584 /* Output profile consistency. */
1587 dump_profile_report (void)
1589 g
->get_passes ()->dump_profile_report ();
1593 pass_manager::dump_profile_report () const
1596 int last_freq_in
= 0, last_count_in
= 0, last_freq_out
= 0, last_count_out
= 0;
1597 gcov_type last_time
= 0, last_size
= 0;
1598 double rel_time_change
, rel_size_change
;
1599 int last_reported
= 0;
1601 if (!profile_record
)
1603 fprintf (stderr
, "\nProfile consistency report:\n\n");
1604 fprintf (stderr
, "Pass name |mismatch in |mismated out|Overall\n");
1605 fprintf (stderr
, " |freq count |freq count |size time\n");
1607 for (i
= 0; i
< passes_by_id_size
; i
++)
1608 for (j
= 0 ; j
< 2; j
++)
1609 if (profile_record
[i
].run
)
1612 rel_time_change
= (profile_record
[i
].time
[j
]
1613 - (double)last_time
) * 100 / (double)last_time
;
1615 rel_time_change
= 0;
1617 rel_size_change
= (profile_record
[i
].size
[j
]
1618 - (double)last_size
) * 100 / (double)last_size
;
1620 rel_size_change
= 0;
1622 if (profile_record
[i
].num_mismatched_freq_in
[j
] != last_freq_in
1623 || profile_record
[i
].num_mismatched_freq_out
[j
] != last_freq_out
1624 || profile_record
[i
].num_mismatched_count_in
[j
] != last_count_in
1625 || profile_record
[i
].num_mismatched_count_out
[j
] != last_count_out
1626 || rel_time_change
|| rel_size_change
)
1629 fprintf (stderr
, "%-20s %s",
1630 passes_by_id
[i
]->name
,
1631 j
? "(after TODO)" : " ");
1632 if (profile_record
[i
].num_mismatched_freq_in
[j
] != last_freq_in
)
1633 fprintf (stderr
, "| %+5i",
1634 profile_record
[i
].num_mismatched_freq_in
[j
]
1637 fprintf (stderr
, "| ");
1638 if (profile_record
[i
].num_mismatched_count_in
[j
] != last_count_in
)
1639 fprintf (stderr
, " %+5i",
1640 profile_record
[i
].num_mismatched_count_in
[j
]
1643 fprintf (stderr
, " ");
1644 if (profile_record
[i
].num_mismatched_freq_out
[j
] != last_freq_out
)
1645 fprintf (stderr
, "| %+5i",
1646 profile_record
[i
].num_mismatched_freq_out
[j
]
1649 fprintf (stderr
, "| ");
1650 if (profile_record
[i
].num_mismatched_count_out
[j
] != last_count_out
)
1651 fprintf (stderr
, " %+5i",
1652 profile_record
[i
].num_mismatched_count_out
[j
]
1655 fprintf (stderr
, " ");
1657 /* Size/time units change across gimple and RTL. */
1658 if (i
== pass_expand_1
->static_pass_number
)
1659 fprintf (stderr
, "|----------");
1662 if (rel_size_change
)
1663 fprintf (stderr
, "| %+8.4f%%", rel_size_change
);
1665 fprintf (stderr
, "| ");
1666 if (rel_time_change
)
1667 fprintf (stderr
, " %+8.4f%%", rel_time_change
);
1669 fprintf (stderr
, "\n");
1670 last_freq_in
= profile_record
[i
].num_mismatched_freq_in
[j
];
1671 last_freq_out
= profile_record
[i
].num_mismatched_freq_out
[j
];
1672 last_count_in
= profile_record
[i
].num_mismatched_count_in
[j
];
1673 last_count_out
= profile_record
[i
].num_mismatched_count_out
[j
];
1675 else if (j
&& last_reported
!= i
)
1678 fprintf (stderr
, "%-20s ------------| | |\n",
1679 passes_by_id
[i
]->name
);
1681 last_time
= profile_record
[i
].time
[j
];
1682 last_size
= profile_record
[i
].size
[j
];
1686 /* Perform all TODO actions that ought to be done on each function. */
1689 execute_function_todo (function
*fn
, void *data
)
1691 bool from_ipa_pass
= (cfun
== NULL
);
1692 unsigned int flags
= (size_t)data
;
1693 flags
&= ~fn
->last_verified
;
1699 /* Always cleanup the CFG before trying to update SSA. */
1700 if (flags
& TODO_cleanup_cfg
)
1702 cleanup_tree_cfg ();
1704 /* When cleanup_tree_cfg merges consecutive blocks, it may
1705 perform some simplistic propagation when removing single
1706 valued PHI nodes. This propagation may, in turn, cause the
1707 SSA form to become out-of-date (see PR 22037). So, even
1708 if the parent pass had not scheduled an SSA update, we may
1709 still need to do one. */
1710 if (!(flags
& TODO_update_ssa_any
) && need_ssa_update_p (cfun
))
1711 flags
|= TODO_update_ssa
;
1714 if (flags
& TODO_update_ssa_any
)
1716 unsigned update_flags
= flags
& TODO_update_ssa_any
;
1717 update_ssa (update_flags
);
1720 if (flag_tree_pta
&& (flags
& TODO_rebuild_alias
))
1721 compute_may_aliases ();
1723 if (optimize
&& (flags
& TODO_update_address_taken
))
1724 execute_update_addresses_taken ();
1726 if (flags
& TODO_remove_unused_locals
)
1727 remove_unused_locals ();
1729 if (flags
& TODO_rebuild_frequencies
)
1730 rebuild_frequencies ();
1732 if (flags
& TODO_rebuild_cgraph_edges
)
1733 rebuild_cgraph_edges ();
1735 /* If we've seen errors do not bother running any verifiers. */
1738 #if defined ENABLE_CHECKING
1739 dom_state pre_verify_state
= dom_info_state (fn
, CDI_DOMINATORS
);
1740 dom_state pre_verify_pstate
= dom_info_state (fn
, CDI_POST_DOMINATORS
);
1742 if (flags
& TODO_verify_il
)
1744 if (cfun
->curr_properties
& PROP_trees
)
1746 if (cfun
->curr_properties
& PROP_cfg
)
1747 /* IPA passes leave stmts to be fixed up, so make sure to
1748 not verify stmts really throw. */
1749 verify_gimple_in_cfg (cfun
, !from_ipa_pass
);
1751 verify_gimple_in_seq (gimple_body (cfun
->decl
));
1753 if (cfun
->curr_properties
& PROP_ssa
)
1754 /* IPA passes leave stmts to be fixed up, so make sure to
1755 not verify SSA operands whose verifier will choke on that. */
1756 verify_ssa (true, !from_ipa_pass
);
1757 /* IPA passes leave basic-blocks unsplit, so make sure to
1758 not trip on that. */
1759 if ((cfun
->curr_properties
& PROP_cfg
)
1761 verify_flow_info ();
1763 && loops_state_satisfies_p (LOOP_CLOSED_SSA
))
1764 verify_loop_closed_ssa (false);
1765 if (cfun
->curr_properties
& PROP_rtl
)
1766 verify_rtl_sharing ();
1769 /* Make sure verifiers don't change dominator state. */
1770 gcc_assert (dom_info_state (fn
, CDI_DOMINATORS
) == pre_verify_state
);
1771 gcc_assert (dom_info_state (fn
, CDI_POST_DOMINATORS
) == pre_verify_pstate
);
1775 fn
->last_verified
= flags
& TODO_verify_all
;
1779 /* For IPA passes make sure to release dominator info, it can be
1780 computed by non-verifying TODOs. */
1783 free_dominance_info (fn
, CDI_DOMINATORS
);
1784 free_dominance_info (fn
, CDI_POST_DOMINATORS
);
1788 /* Perform all TODO actions. */
1790 execute_todo (unsigned int flags
)
1792 #if defined ENABLE_CHECKING
1794 && need_ssa_update_p (cfun
))
1795 gcc_assert (flags
& TODO_update_ssa_any
);
1798 timevar_push (TV_TODO
);
1800 /* Inform the pass whether it is the first time it is run. */
1801 first_pass_instance
= (flags
& TODO_mark_first_instance
) != 0;
1803 statistics_fini_pass ();
1806 do_per_function (execute_function_todo
, (void *)(size_t) flags
);
1808 /* Always remove functions just as before inlining: IPA passes might be
1809 interested to see bodies of extern inline functions that are not inlined
1810 to analyze side effects. The full removal is done just at the end
1811 of IPA pass queue. */
1812 if (flags
& TODO_remove_functions
)
1815 symtab_remove_unreachable_nodes (true, dump_file
);
1818 if ((flags
& TODO_dump_symtab
) && dump_file
&& !current_function_decl
)
1821 symtab_node::dump_table (dump_file
);
1822 /* Flush the file. If verification fails, we won't be able to
1823 close the file before aborting. */
1827 /* Now that the dumping has been done, we can get rid of the optional
1829 if (flags
& TODO_df_finish
)
1830 df_finish_pass ((flags
& TODO_df_verify
) != 0);
1832 timevar_pop (TV_TODO
);
1835 /* Verify invariants that should hold between passes. This is a place
1836 to put simple sanity checks. */
1839 verify_interpass_invariants (void)
1841 gcc_checking_assert (!fold_deferring_overflow_warnings_p ());
1844 /* Clear the last verified flag. */
1847 clear_last_verified (function
*fn
, void *data ATTRIBUTE_UNUSED
)
1849 fn
->last_verified
= 0;
1852 /* Helper function. Verify that the properties has been turn into the
1853 properties expected by the pass. */
1855 #ifdef ENABLE_CHECKING
1857 verify_curr_properties (function
*fn
, void *data
)
1859 unsigned int props
= (size_t)data
;
1860 gcc_assert ((fn
->curr_properties
& props
) == props
);
1864 /* Initialize pass dump file. */
1865 /* This is non-static so that the plugins can use it. */
1868 pass_init_dump_file (opt_pass
*pass
)
1870 /* If a dump file name is present, open it if enabled. */
1871 if (pass
->static_pass_number
!= -1)
1873 timevar_push (TV_DUMP
);
1874 gcc::dump_manager
*dumps
= g
->get_dumps ();
1875 bool initializing_dump
=
1876 !dumps
->dump_initialized_p (pass
->static_pass_number
);
1877 dump_file_name
= dumps
->get_dump_file_name (pass
->static_pass_number
);
1878 dumps
->dump_start (pass
->static_pass_number
, &dump_flags
);
1879 if (dump_file
&& current_function_decl
)
1880 dump_function_header (dump_file
, current_function_decl
, dump_flags
);
1881 if (initializing_dump
1882 && dump_file
&& (dump_flags
& TDF_GRAPH
)
1883 && cfun
&& (cfun
->curr_properties
& PROP_cfg
))
1885 clean_graph_dump_file (dump_file_name
);
1886 pass
->graph_dump_initialized
= true;
1888 timevar_pop (TV_DUMP
);
1889 return initializing_dump
;
1895 /* Flush PASS dump file. */
1896 /* This is non-static so that plugins can use it. */
1899 pass_fini_dump_file (opt_pass
*pass
)
1901 timevar_push (TV_DUMP
);
1903 /* Flush and close dump file. */
1906 free (CONST_CAST (char *, dump_file_name
));
1907 dump_file_name
= NULL
;
1910 g
->get_dumps ()->dump_finish (pass
->static_pass_number
);
1911 timevar_pop (TV_DUMP
);
1914 /* After executing the pass, apply expected changes to the function
1918 update_properties_after_pass (function
*fn
, void *data
)
1920 opt_pass
*pass
= (opt_pass
*) data
;
1921 fn
->curr_properties
= (fn
->curr_properties
| pass
->properties_provided
)
1922 & ~pass
->properties_destroyed
;
1925 /* Execute summary generation for all of the passes in IPA_PASS. */
1928 execute_ipa_summary_passes (ipa_opt_pass_d
*ipa_pass
)
1932 opt_pass
*pass
= ipa_pass
;
1934 /* Execute all of the IPA_PASSes in the list. */
1935 if (ipa_pass
->type
== IPA_PASS
1936 && pass
->gate (cfun
)
1937 && ipa_pass
->generate_summary
)
1939 pass_init_dump_file (pass
);
1941 /* If a timevar is present, start it. */
1943 timevar_push (pass
->tv_id
);
1945 ipa_pass
->generate_summary ();
1949 timevar_pop (pass
->tv_id
);
1951 pass_fini_dump_file (pass
);
1953 ipa_pass
= (ipa_opt_pass_d
*)ipa_pass
->next
;
1957 /* Execute IPA_PASS function transform on NODE. */
1960 execute_one_ipa_transform_pass (struct cgraph_node
*node
,
1961 ipa_opt_pass_d
*ipa_pass
)
1963 opt_pass
*pass
= ipa_pass
;
1964 unsigned int todo_after
= 0;
1966 current_pass
= pass
;
1967 if (!ipa_pass
->function_transform
)
1970 /* Note that the folders should only create gimple expressions.
1971 This is a hack until the new folder is ready. */
1972 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
1974 pass_init_dump_file (pass
);
1976 /* Run pre-pass verification. */
1977 execute_todo (ipa_pass
->function_transform_todo_flags_start
);
1979 /* If a timevar is present, start it. */
1980 if (pass
->tv_id
!= TV_NONE
)
1981 timevar_push (pass
->tv_id
);
1984 todo_after
= ipa_pass
->function_transform (node
);
1987 if (pass
->tv_id
!= TV_NONE
)
1988 timevar_pop (pass
->tv_id
);
1990 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
1991 check_profile_consistency (pass
->static_pass_number
, 0, true);
1993 /* Run post-pass cleanup and verification. */
1994 execute_todo (todo_after
);
1995 verify_interpass_invariants ();
1996 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
1997 check_profile_consistency (pass
->static_pass_number
, 1, true);
2000 do_per_function (execute_function_dump
, NULL
);
2001 pass_fini_dump_file (pass
);
2003 current_pass
= NULL
;
2005 /* Signal this is a suitable GC collection point. */
2006 if (!(todo_after
& TODO_do_not_ggc_collect
))
2010 /* For the current function, execute all ipa transforms. */
2013 execute_all_ipa_transforms (void)
2015 struct cgraph_node
*node
;
2018 node
= cgraph_node::get (current_function_decl
);
2020 if (node
->ipa_transforms_to_apply
.exists ())
2024 for (i
= 0; i
< node
->ipa_transforms_to_apply
.length (); i
++)
2025 execute_one_ipa_transform_pass (node
, node
->ipa_transforms_to_apply
[i
]);
2026 node
->ipa_transforms_to_apply
.release ();
2030 /* Check if PASS is explicitly disabled or enabled and return
2031 the gate status. FUNC is the function to be processed, and
2032 GATE_STATUS is the gate status determined by pass manager by
2036 override_gate_status (opt_pass
*pass
, tree func
, bool gate_status
)
2038 bool explicitly_enabled
= false;
2039 bool explicitly_disabled
= false;
2042 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
2043 enabled_pass_uid_range_tab
);
2045 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
2046 disabled_pass_uid_range_tab
);
2048 gate_status
= !explicitly_disabled
&& (gate_status
|| explicitly_enabled
);
2057 execute_one_pass (opt_pass
*pass
)
2059 unsigned int todo_after
= 0;
2063 /* IPA passes are executed on whole program, so cfun should be NULL.
2064 Other passes need function context set. */
2065 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
2066 gcc_assert (!cfun
&& !current_function_decl
);
2068 gcc_assert (cfun
&& current_function_decl
);
2070 current_pass
= pass
;
2072 /* Check whether gate check should be avoided.
2073 User controls the value of the gate through the parameter "gate_status". */
2074 gate_status
= pass
->gate (cfun
);
2075 gate_status
= override_gate_status (pass
, current_function_decl
, gate_status
);
2077 /* Override gate with plugin. */
2078 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE
, &gate_status
);
2082 /* Run so passes selectively disabling themselves on a given function
2083 are not miscounted. */
2084 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2086 check_profile_consistency (pass
->static_pass_number
, 0, false);
2087 check_profile_consistency (pass
->static_pass_number
, 1, false);
2089 current_pass
= NULL
;
2093 /* Pass execution event trigger: useful to identify passes being
2095 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION
, pass
);
2097 /* SIPLE IPA passes do not handle callgraphs with IPA transforms in it.
2098 Apply all trnasforms first. */
2099 if (pass
->type
== SIMPLE_IPA_PASS
)
2101 struct cgraph_node
*node
;
2102 bool applied
= false;
2103 FOR_EACH_DEFINED_FUNCTION (node
)
2105 && node
->has_gimple_body_p ()
2106 && (!node
->clone_of
|| node
->decl
!= node
->clone_of
->decl
))
2108 if (!node
->global
.inlined_to
2109 && node
->ipa_transforms_to_apply
.exists ())
2112 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2113 execute_all_ipa_transforms ();
2114 rebuild_cgraph_edges ();
2115 free_dominance_info (CDI_DOMINATORS
);
2116 free_dominance_info (CDI_POST_DOMINATORS
);
2122 symtab_remove_unreachable_nodes (true, dump_file
);
2123 /* Restore current_pass. */
2124 current_pass
= pass
;
2127 if (!quiet_flag
&& !cfun
)
2128 fprintf (stderr
, " <%s>", pass
->name
? pass
->name
: "");
2130 /* Note that the folders should only create gimple expressions.
2131 This is a hack until the new folder is ready. */
2132 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
2134 pass_init_dump_file (pass
);
2136 /* Run pre-pass verification. */
2137 execute_todo (pass
->todo_flags_start
);
2139 #ifdef ENABLE_CHECKING
2140 do_per_function (verify_curr_properties
,
2141 (void *)(size_t)pass
->properties_required
);
2144 /* If a timevar is present, start it. */
2145 if (pass
->tv_id
!= TV_NONE
)
2146 timevar_push (pass
->tv_id
);
2149 todo_after
= pass
->execute (cfun
);
2150 do_per_function (clear_last_verified
, NULL
);
2153 if (pass
->tv_id
!= TV_NONE
)
2154 timevar_pop (pass
->tv_id
);
2156 do_per_function (update_properties_after_pass
, pass
);
2158 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2159 check_profile_consistency (pass
->static_pass_number
, 0, true);
2161 /* Run post-pass cleanup and verification. */
2162 execute_todo (todo_after
| pass
->todo_flags_finish
| TODO_verify_il
);
2163 if (profile_report
&& cfun
&& (cfun
->curr_properties
& PROP_cfg
))
2164 check_profile_consistency (pass
->static_pass_number
, 1, true);
2166 verify_interpass_invariants ();
2168 do_per_function (execute_function_dump
, pass
);
2169 if (pass
->type
== IPA_PASS
)
2171 struct cgraph_node
*node
;
2172 FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node
)
2173 node
->ipa_transforms_to_apply
.safe_push ((ipa_opt_pass_d
*)pass
);
2176 if (!current_function_decl
)
2177 cgraph_process_new_functions ();
2179 pass_fini_dump_file (pass
);
2181 if (pass
->type
!= SIMPLE_IPA_PASS
&& pass
->type
!= IPA_PASS
)
2182 gcc_assert (!(cfun
->curr_properties
& PROP_trees
)
2183 || pass
->type
!= RTL_PASS
);
2185 current_pass
= NULL
;
2187 /* Signal this is a suitable GC collection point. */
2188 if (!((todo_after
| pass
->todo_flags_finish
) & TODO_do_not_ggc_collect
))
2195 execute_pass_list_1 (opt_pass
*pass
)
2199 gcc_assert (pass
->type
== GIMPLE_PASS
2200 || pass
->type
== RTL_PASS
);
2201 if (execute_one_pass (pass
) && pass
->sub
)
2202 execute_pass_list_1 (pass
->sub
);
2209 execute_pass_list (function
*fn
, opt_pass
*pass
)
2212 execute_pass_list_1 (pass
);
2215 free_dominance_info (CDI_DOMINATORS
);
2216 free_dominance_info (CDI_POST_DOMINATORS
);
2221 /* Write out all LTO data. */
2225 timevar_push (TV_IPA_LTO_GIMPLE_OUT
);
2227 timevar_pop (TV_IPA_LTO_GIMPLE_OUT
);
2228 timevar_push (TV_IPA_LTO_DECL_OUT
);
2229 produce_asm_for_decls ();
2230 timevar_pop (TV_IPA_LTO_DECL_OUT
);
2233 /* Same as execute_pass_list but assume that subpasses of IPA passes
2234 are local passes. If SET is not NULL, write out summaries of only
2235 those node in SET. */
2238 ipa_write_summaries_2 (opt_pass
*pass
, struct lto_out_decl_state
*state
)
2242 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*)pass
;
2243 gcc_assert (!current_function_decl
);
2245 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2246 if (pass
->type
== IPA_PASS
2247 && ipa_pass
->write_summary
2248 && pass
->gate (cfun
))
2250 /* If a timevar is present, start it. */
2252 timevar_push (pass
->tv_id
);
2254 pass_init_dump_file (pass
);
2256 ipa_pass
->write_summary ();
2258 pass_fini_dump_file (pass
);
2260 /* If a timevar is present, start it. */
2262 timevar_pop (pass
->tv_id
);
2265 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2266 ipa_write_summaries_2 (pass
->sub
, state
);
2272 /* Helper function of ipa_write_summaries. Creates and destroys the
2273 decl state and calls ipa_write_summaries_2 for all passes that have
2274 summaries. SET is the set of nodes to be written. */
2277 ipa_write_summaries_1 (lto_symtab_encoder_t encoder
)
2279 pass_manager
*passes
= g
->get_passes ();
2280 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2281 state
->symtab_node_encoder
= encoder
;
2283 lto_push_out_decl_state (state
);
2285 gcc_assert (!flag_wpa
);
2286 ipa_write_summaries_2 (passes
->all_regular_ipa_passes
, state
);
2290 gcc_assert (lto_get_out_decl_state () == state
);
2291 lto_pop_out_decl_state ();
2292 lto_delete_out_decl_state (state
);
2295 /* Write out summaries for all the nodes in the callgraph. */
2298 ipa_write_summaries (void)
2300 lto_symtab_encoder_t encoder
;
2302 varpool_node
*vnode
;
2303 struct cgraph_node
*node
;
2304 struct cgraph_node
**order
;
2306 if (!flag_generate_lto
|| seen_error ())
2309 encoder
= lto_symtab_encoder_new (false);
2311 /* Create the callgraph set in the same order used in
2312 cgraph_expand_all_functions. This mostly facilitates debugging,
2313 since it causes the gimple file to be processed in the same order
2314 as the source code. */
2315 order
= XCNEWVEC (struct cgraph_node
*, cgraph_n_nodes
);
2316 order_pos
= ipa_reverse_postorder (order
);
2317 gcc_assert (order_pos
== cgraph_n_nodes
);
2319 for (i
= order_pos
- 1; i
>= 0; i
--)
2321 struct cgraph_node
*node
= order
[i
];
2323 if (node
->has_gimple_body_p ())
2325 /* When streaming out references to statements as part of some IPA
2326 pass summary, the statements need to have uids assigned and the
2327 following does that for all the IPA passes here. Naturally, this
2328 ordering then matches the one IPA-passes get in their stmt_fixup
2331 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2332 renumber_gimple_stmt_uids ();
2335 if (node
->definition
)
2336 lto_set_symtab_encoder_in_partition (encoder
, node
);
2339 FOR_EACH_DEFINED_FUNCTION (node
)
2341 lto_set_symtab_encoder_in_partition (encoder
, node
);
2342 FOR_EACH_DEFINED_VARIABLE (vnode
)
2343 lto_set_symtab_encoder_in_partition (encoder
, vnode
);
2345 ipa_write_summaries_1 (compute_ltrans_boundary (encoder
));
2350 /* Same as execute_pass_list but assume that subpasses of IPA passes
2351 are local passes. If SET is not NULL, write out optimization summaries of
2352 only those node in SET. */
2355 ipa_write_optimization_summaries_1 (opt_pass
*pass
,
2356 struct lto_out_decl_state
*state
)
2360 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*)pass
;
2361 gcc_assert (!current_function_decl
);
2363 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2364 if (pass
->type
== IPA_PASS
2365 && ipa_pass
->write_optimization_summary
2366 && pass
->gate (cfun
))
2368 /* If a timevar is present, start it. */
2370 timevar_push (pass
->tv_id
);
2372 pass_init_dump_file (pass
);
2374 ipa_pass
->write_optimization_summary ();
2376 pass_fini_dump_file (pass
);
2378 /* If a timevar is present, start it. */
2380 timevar_pop (pass
->tv_id
);
2383 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2384 ipa_write_optimization_summaries_1 (pass
->sub
, state
);
2390 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is
2391 NULL, write out all summaries of all nodes. */
2394 ipa_write_optimization_summaries (lto_symtab_encoder_t encoder
)
2396 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2397 lto_symtab_encoder_iterator lsei
;
2398 state
->symtab_node_encoder
= encoder
;
2400 lto_push_out_decl_state (state
);
2401 for (lsei
= lsei_start_function_in_partition (encoder
);
2402 !lsei_end_p (lsei
); lsei_next_function_in_partition (&lsei
))
2404 struct cgraph_node
*node
= lsei_cgraph_node (lsei
);
2405 /* When streaming out references to statements as part of some IPA
2406 pass summary, the statements need to have uids assigned.
2408 For functions newly born at WPA stage we need to initialize
2410 if (node
->definition
2411 && gimple_has_body_p (node
->decl
))
2413 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2414 renumber_gimple_stmt_uids ();
2419 gcc_assert (flag_wpa
);
2420 pass_manager
*passes
= g
->get_passes ();
2421 ipa_write_optimization_summaries_1 (passes
->all_regular_ipa_passes
, state
);
2425 gcc_assert (lto_get_out_decl_state () == state
);
2426 lto_pop_out_decl_state ();
2427 lto_delete_out_decl_state (state
);
2430 /* Same as execute_pass_list but assume that subpasses of IPA passes
2431 are local passes. */
2434 ipa_read_summaries_1 (opt_pass
*pass
)
2438 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2440 gcc_assert (!current_function_decl
);
2442 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2444 if (pass
->gate (cfun
))
2446 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_summary
)
2448 /* If a timevar is present, start it. */
2450 timevar_push (pass
->tv_id
);
2452 pass_init_dump_file (pass
);
2454 ipa_pass
->read_summary ();
2456 pass_fini_dump_file (pass
);
2460 timevar_pop (pass
->tv_id
);
2463 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2464 ipa_read_summaries_1 (pass
->sub
);
2471 /* Read all the summaries for all_regular_ipa_passes. */
2474 ipa_read_summaries (void)
2476 pass_manager
*passes
= g
->get_passes ();
2477 ipa_read_summaries_1 (passes
->all_regular_ipa_passes
);
2480 /* Same as execute_pass_list but assume that subpasses of IPA passes
2481 are local passes. */
2484 ipa_read_optimization_summaries_1 (opt_pass
*pass
)
2488 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2490 gcc_assert (!current_function_decl
);
2492 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2494 if (pass
->gate (cfun
))
2496 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_optimization_summary
)
2498 /* If a timevar is present, start it. */
2500 timevar_push (pass
->tv_id
);
2502 pass_init_dump_file (pass
);
2504 ipa_pass
->read_optimization_summary ();
2506 pass_fini_dump_file (pass
);
2510 timevar_pop (pass
->tv_id
);
2513 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2514 ipa_read_optimization_summaries_1 (pass
->sub
);
2520 /* Read all the summaries for all_regular_ipa_passes. */
2523 ipa_read_optimization_summaries (void)
2525 pass_manager
*passes
= g
->get_passes ();
2526 ipa_read_optimization_summaries_1 (passes
->all_regular_ipa_passes
);
2529 /* Same as execute_pass_list but assume that subpasses of IPA passes
2530 are local passes. */
2532 execute_ipa_pass_list (opt_pass
*pass
)
2536 gcc_assert (!current_function_decl
);
2538 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2539 if (execute_one_pass (pass
) && pass
->sub
)
2541 if (pass
->sub
->type
== GIMPLE_PASS
)
2543 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START
, NULL
);
2544 do_per_function_toporder ((void (*)(function
*, void *))
2547 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END
, NULL
);
2549 else if (pass
->sub
->type
== SIMPLE_IPA_PASS
2550 || pass
->sub
->type
== IPA_PASS
)
2551 execute_ipa_pass_list (pass
->sub
);
2555 gcc_assert (!current_function_decl
);
2556 cgraph_process_new_functions ();
2562 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
2565 execute_ipa_stmt_fixups (opt_pass
*pass
,
2566 struct cgraph_node
*node
, gimple
*stmts
)
2570 /* Execute all of the IPA_PASSes in the list. */
2571 if (pass
->type
== IPA_PASS
2572 && pass
->gate (cfun
))
2574 ipa_opt_pass_d
*ipa_pass
= (ipa_opt_pass_d
*) pass
;
2576 if (ipa_pass
->stmt_fixup
)
2578 pass_init_dump_file (pass
);
2579 /* If a timevar is present, start it. */
2581 timevar_push (pass
->tv_id
);
2583 ipa_pass
->stmt_fixup (node
, stmts
);
2587 timevar_pop (pass
->tv_id
);
2588 pass_fini_dump_file (pass
);
2591 execute_ipa_stmt_fixups (pass
->sub
, node
, stmts
);
2597 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */
2600 execute_all_ipa_stmt_fixups (struct cgraph_node
*node
, gimple
*stmts
)
2602 pass_manager
*passes
= g
->get_passes ();
2603 execute_ipa_stmt_fixups (passes
->all_regular_ipa_passes
, node
, stmts
);
2607 extern void debug_properties (unsigned int);
2608 extern void dump_properties (FILE *, unsigned int);
2611 dump_properties (FILE *dump
, unsigned int props
)
2613 fprintf (dump
, "Properties:\n");
2614 if (props
& PROP_gimple_any
)
2615 fprintf (dump
, "PROP_gimple_any\n");
2616 if (props
& PROP_gimple_lcf
)
2617 fprintf (dump
, "PROP_gimple_lcf\n");
2618 if (props
& PROP_gimple_leh
)
2619 fprintf (dump
, "PROP_gimple_leh\n");
2620 if (props
& PROP_cfg
)
2621 fprintf (dump
, "PROP_cfg\n");
2622 if (props
& PROP_ssa
)
2623 fprintf (dump
, "PROP_ssa\n");
2624 if (props
& PROP_no_crit_edges
)
2625 fprintf (dump
, "PROP_no_crit_edges\n");
2626 if (props
& PROP_rtl
)
2627 fprintf (dump
, "PROP_rtl\n");
2628 if (props
& PROP_gimple_lomp
)
2629 fprintf (dump
, "PROP_gimple_lomp\n");
2630 if (props
& PROP_gimple_lcx
)
2631 fprintf (dump
, "PROP_gimple_lcx\n");
2632 if (props
& PROP_gimple_lvec
)
2633 fprintf (dump
, "PROP_gimple_lvec\n");
2634 if (props
& PROP_cfglayout
)
2635 fprintf (dump
, "PROP_cfglayout\n");
2639 debug_properties (unsigned int props
)
2641 dump_properties (stderr
, props
);
2644 /* Called by local passes to see if function is called by already processed nodes.
2645 Because we process nodes in topological order, this means that function is
2646 in recursive cycle or we introduced new direct calls. */
2648 function_called_by_processed_nodes_p (void)
2650 struct cgraph_edge
*e
;
2651 for (e
= cgraph_node::get (current_function_decl
)->callers
;
2655 if (e
->caller
->decl
== current_function_decl
)
2657 if (!e
->caller
->has_gimple_body_p ())
2659 if (TREE_ASM_WRITTEN (e
->caller
->decl
))
2661 if (!e
->caller
->process
&& !e
->caller
->global
.inlined_to
)
2666 fprintf (dump_file
, "Already processed call to:\n");
2667 e
->caller
->dump (dump_file
);
2672 #include "gt-passes.h"