1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
29 #include "coretypes.h"
37 #include "insn-attr.h"
38 #include "insn-config.h"
39 #include "insn-flags.h"
40 #include "hard-reg-set.h"
47 #include "basic-block.h"
53 #include "diagnostic-core.h"
56 #include "dwarf2asm.h"
57 #include "integrate.h"
60 #include "langhooks.h"
61 #include "cfglayout.h"
63 #include "hosthooks.h"
67 #include "value-prof.h"
68 #include "tree-inline.h"
69 #include "tree-flow.h"
70 #include "tree-pass.h"
71 #include "tree-dump.h"
74 #include "lto-streamer.h"
77 #include "tree-pretty-print.h"
79 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
80 #include "dwarf2out.h"
83 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
87 #ifdef SDB_DEBUGGING_INFO
91 #ifdef XCOFF_DEBUGGING_INFO
92 #include "xcoffout.h" /* Needed for external data
93 declarations for e.g. AIX 4.x. */
96 /* This is used for debugging. It allows the current pass to printed
97 from anywhere in compilation.
98 The variable current_pass is also used for statistics and plugins. */
99 struct opt_pass
*current_pass
;
101 static void register_pass_name (struct opt_pass
*, const char *);
103 /* Call from anywhere to find out what pass this is. Useful for
104 printing out debugging information deep inside an service
107 print_current_pass (FILE *file
)
110 fprintf (file
, "current pass = %s (%d)\n",
111 current_pass
->name
, current_pass
->static_pass_number
);
113 fprintf (file
, "no current pass.\n");
117 /* Call from the debugger to get the current pass name. */
121 print_current_pass (stderr
);
126 /* Global variables used to communicate with passes. */
129 bool first_pass_instance
;
132 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
135 This does nothing for local (non-static) variables, unless the
136 variable is a register variable with DECL_ASSEMBLER_NAME set. In
137 that case, or if the variable is not an automatic, it sets up the
138 RTL and outputs any assembler code (label definition, storage
139 allocation and initialization).
141 DECL is the declaration. TOP_LEVEL is nonzero
142 if this declaration is not within a function. */
145 rest_of_decl_compilation (tree decl
,
149 /* We deferred calling assemble_alias so that we could collect
150 other attributes such as visibility. Emit the alias now. */
154 alias
= lookup_attribute ("alias", DECL_ATTRIBUTES (decl
));
157 alias
= TREE_VALUE (TREE_VALUE (alias
));
158 alias
= get_identifier (TREE_STRING_POINTER (alias
));
159 assemble_alias (decl
, alias
);
163 /* Can't defer this, because it needs to happen before any
164 later function definitions are processed. */
165 if (DECL_ASSEMBLER_NAME_SET_P (decl
) && DECL_REGISTER (decl
))
166 make_decl_rtl (decl
);
168 /* Forward declarations for nested functions are not "external",
169 but we need to treat them as if they were. */
170 if (TREE_STATIC (decl
) || DECL_EXTERNAL (decl
)
171 || TREE_CODE (decl
) == FUNCTION_DECL
)
173 timevar_push (TV_VARCONST
);
175 /* Don't output anything when a tentative file-scope definition
176 is seen. But at end of compilation, do output code for them.
178 We do output all variables and rely on
179 callgraph code to defer them except for forward declarations
180 (see gcc.c-torture/compile/920624-1.c) */
182 || !DECL_DEFER_OUTPUT (decl
)
183 || DECL_INITIAL (decl
))
184 && !DECL_EXTERNAL (decl
))
186 /* When reading LTO unit, we also read varpool, so do not
188 if (in_lto_p
&& !at_end
)
190 else if (TREE_CODE (decl
) != FUNCTION_DECL
)
191 varpool_finalize_decl (decl
);
194 #ifdef ASM_FINISH_DECLARE_OBJECT
195 if (decl
== last_assemble_variable_decl
)
197 ASM_FINISH_DECLARE_OBJECT (asm_out_file
, decl
,
203 /* Create the node early during parsing so
204 that module id can be captured. */
205 if (TREE_CODE (decl
) == VAR_DECL
)
209 timevar_pop (TV_VARCONST
);
211 else if (TREE_CODE (decl
) == TYPE_DECL
212 /* Like in rest_of_type_compilation, avoid confusing the debug
213 information machinery when there are errors. */
216 timevar_push (TV_SYMOUT
);
217 debug_hooks
->type_decl (decl
, !top_level
);
218 timevar_pop (TV_SYMOUT
);
221 /* Let cgraph know about the existence of variables. */
222 if (in_lto_p
&& !at_end
)
224 else if (TREE_CODE (decl
) == VAR_DECL
&& !DECL_EXTERNAL (decl
)
225 && TREE_STATIC (decl
))
229 /* Called after finishing a record, union or enumeral type. */
232 rest_of_type_compilation (tree type
, int toplev
)
234 /* Avoid confusing the debug information machinery when there are
239 timevar_push (TV_SYMOUT
);
240 debug_hooks
->type_decl (TYPE_STUB_DECL (type
), !toplev
);
241 timevar_pop (TV_SYMOUT
);
247 finish_optimization_passes (void)
250 struct dump_file_info
*dfi
;
253 timevar_push (TV_DUMP
);
254 if (profile_arc_flag
|| flag_test_coverage
|| flag_branch_probabilities
)
256 dump_file
= dump_begin (pass_profile
.pass
.static_pass_number
, NULL
);
259 dump_end (pass_profile
.pass
.static_pass_number
, dump_file
);
264 dump_file
= dump_begin (pass_combine
.pass
.static_pass_number
, NULL
);
267 dump_combine_total_stats (dump_file
);
268 dump_end (pass_combine
.pass
.static_pass_number
, dump_file
);
272 /* Do whatever is necessary to finish printing the graphs. */
273 if (graph_dump_format
!= no_graph
)
274 for (i
= TDI_end
; (dfi
= get_dump_file_info (i
)) != NULL
; ++i
)
275 if (dump_initialized_p (i
)
276 && (dfi
->flags
& TDF_GRAPH
) != 0
277 && (name
= get_dump_file_name (i
)) != NULL
)
279 finish_graph_dump_file (name
);
283 timevar_pop (TV_DUMP
);
287 gate_rest_of_compilation (void)
289 /* Early return if there were errors. We can run afoul of our
290 consistency checks, and there's not really much point in fixing them. */
291 return !(rtl_dump_and_exit
|| flag_syntax_only
|| seen_error ());
294 struct gimple_opt_pass pass_rest_of_compilation
=
298 "*rest_of_compilation", /* name */
299 gate_rest_of_compilation
, /* gate */
303 0, /* static_pass_number */
304 TV_REST_OF_COMPILATION
, /* tv_id */
305 PROP_rtl
, /* properties_required */
306 0, /* properties_provided */
307 0, /* properties_destroyed */
308 0, /* todo_flags_start */
309 TODO_ggc_collect
/* todo_flags_finish */
314 gate_postreload (void)
316 return reload_completed
;
319 struct rtl_opt_pass pass_postreload
=
323 "*all-postreload", /* name */
324 gate_postreload
, /* gate */
328 0, /* static_pass_number */
329 TV_POSTRELOAD
, /* tv_id */
330 PROP_rtl
, /* properties_required */
331 0, /* properties_provided */
332 0, /* properties_destroyed */
333 0, /* todo_flags_start */
334 TODO_ggc_collect
| TODO_verify_rtl_sharing
/* todo_flags_finish */
340 /* The root of the compilation pass tree, once constructed. */
341 struct opt_pass
*all_passes
, *all_small_ipa_passes
, *all_lowering_passes
,
342 *all_regular_ipa_passes
, *all_lto_gen_passes
;
344 /* This is used by plugins, and should also be used in register_pass. */
345 #define DEF_PASS_LIST(LIST) &LIST,
346 struct opt_pass
**gcc_pass_lists
[] = { GCC_PASS_LISTS NULL
};
349 /* A map from static pass id to optimization pass. */
350 struct opt_pass
**passes_by_id
;
351 int passes_by_id_size
;
353 /* Set the static pass number of pass PASS to ID and record that
354 in the mapping from static pass number to pass. */
357 set_pass_for_id (int id
, struct opt_pass
*pass
)
359 pass
->static_pass_number
= id
;
360 if (passes_by_id_size
<= id
)
362 passes_by_id
= XRESIZEVEC (struct opt_pass
*, passes_by_id
, id
+ 1);
363 memset (passes_by_id
+ passes_by_id_size
, 0,
364 (id
+ 1 - passes_by_id_size
) * sizeof (void *));
365 passes_by_id_size
= id
+ 1;
367 passes_by_id
[id
] = pass
;
370 /* Return the pass with the static pass number ID. */
373 get_pass_for_id (int id
)
375 if (id
>= passes_by_id_size
)
377 return passes_by_id
[id
];
380 /* Iterate over the pass tree allocating dump file numbers. We want
381 to do this depth first, and independent of whether the pass is
385 register_one_dump_file (struct opt_pass
*pass
)
387 char *dot_name
, *flag_name
, *glob_name
;
388 const char *name
, *full_name
, *prefix
;
392 /* See below in next_pass_1. */
394 if (pass
->static_pass_number
!= -1)
395 sprintf (num
, "%d", ((int) pass
->static_pass_number
< 0
396 ? 1 : pass
->static_pass_number
));
398 /* The name is both used to identify the pass for the purposes of plugins,
399 and to specify dump file name and option.
400 The latter two might want something short which is not quite unique; for
401 that reason, we may have a disambiguating prefix, followed by a space
402 to mark the start of the following dump file name / option string. */
403 name
= strchr (pass
->name
, ' ');
404 name
= name
? name
+ 1 : pass
->name
;
405 dot_name
= concat (".", name
, num
, NULL
);
406 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
407 prefix
= "ipa-", flags
= TDF_IPA
;
408 else if (pass
->type
== GIMPLE_PASS
)
409 prefix
= "tree-", flags
= TDF_TREE
;
411 prefix
= "rtl-", flags
= TDF_RTL
;
413 flag_name
= concat (prefix
, name
, num
, NULL
);
414 glob_name
= concat (prefix
, name
, NULL
);
415 id
= dump_register (dot_name
, flag_name
, glob_name
, flags
);
416 set_pass_for_id (id
, pass
);
417 full_name
= concat (prefix
, pass
->name
, num
, NULL
);
418 register_pass_name (pass
, full_name
);
421 /* Recursive worker function for register_dump_files. */
424 register_dump_files_1 (struct opt_pass
*pass
, int properties
)
428 int new_properties
= (properties
| pass
->properties_provided
)
429 & ~pass
->properties_destroyed
;
431 if (pass
->name
&& pass
->name
[0] != '*')
432 register_one_dump_file (pass
);
435 new_properties
= register_dump_files_1 (pass
->sub
, new_properties
);
437 /* If we have a gate, combine the properties that we could have with
438 and without the pass being examined. */
440 properties
&= new_properties
;
442 properties
= new_properties
;
451 /* Register the dump files for the pipeline starting at PASS.
452 PROPERTIES reflects the properties that are guaranteed to be available at
453 the beginning of the pipeline. */
456 register_dump_files (struct opt_pass
*pass
,int properties
)
458 pass
->properties_required
|= properties
;
459 register_dump_files_1 (pass
, properties
);
464 const char* unique_name
;
465 struct opt_pass
*pass
;
468 /* Pass registry hash function. */
471 passr_hash (const void *p
)
473 const struct pass_registry
*const s
= (const struct pass_registry
*const) p
;
474 return htab_hash_string (s
->unique_name
);
477 /* Hash equal function */
480 passr_eq (const void *p1
, const void *p2
)
482 const struct pass_registry
*const s1
= (const struct pass_registry
*const) p1
;
483 const struct pass_registry
*const s2
= (const struct pass_registry
*const) p2
;
485 return !strcmp (s1
->unique_name
, s2
->unique_name
);
488 static htab_t name_to_pass_map
= NULL
;
490 /* Register PASS with NAME. */
493 register_pass_name (struct opt_pass
*pass
, const char *name
)
495 struct pass_registry
**slot
;
496 struct pass_registry pr
;
498 if (!name_to_pass_map
)
499 name_to_pass_map
= htab_create (256, passr_hash
, passr_eq
, NULL
);
501 pr
.unique_name
= name
;
502 slot
= (struct pass_registry
**) htab_find_slot (name_to_pass_map
, &pr
, INSERT
);
505 struct pass_registry
*new_pr
;
507 new_pr
= XCNEW (struct pass_registry
);
508 new_pr
->unique_name
= xstrdup (name
);
513 return; /* Ignore plugin passes. */
516 /* Map from pass id to canonicalized pass name. */
518 typedef const char *char_ptr
;
520 DEF_VEC_ALLOC_P(char_ptr
, heap
);
521 static VEC(char_ptr
, heap
) *pass_tab
= NULL
;
523 /* Callback function for traversing NAME_TO_PASS_MAP. */
526 pass_traverse (void **slot
, void *data ATTRIBUTE_UNUSED
)
528 struct pass_registry
**p
= (struct pass_registry
**)slot
;
529 struct opt_pass
*pass
= (*p
)->pass
;
531 gcc_assert (pass
->static_pass_number
> 0);
532 gcc_assert (pass_tab
);
534 VEC_replace (char_ptr
, pass_tab
, pass
->static_pass_number
,
540 /* The function traverses NAME_TO_PASS_MAP and creates a pass info
541 table for dumping purpose. */
544 create_pass_tab (void)
546 if (!flag_dump_passes
)
549 VEC_safe_grow_cleared (char_ptr
, heap
,
550 pass_tab
, passes_by_id_size
+ 1);
551 htab_traverse (name_to_pass_map
, pass_traverse
, NULL
);
554 static bool override_gate_status (struct opt_pass
*, tree
, bool);
556 /* Dump the instantiated name for PASS. IS_ON indicates if PASS
557 is turned on or not. */
560 dump_one_pass (struct opt_pass
*pass
, int pass_indent
)
562 int indent
= 3 * pass_indent
;
564 bool is_on
, is_really_on
;
566 is_on
= (pass
->gate
== NULL
) ? true : pass
->gate();
567 is_really_on
= override_gate_status (pass
, current_function_decl
, is_on
);
569 if (pass
->static_pass_number
<= 0)
572 pn
= VEC_index (char_ptr
, pass_tab
, pass
->static_pass_number
);
574 fprintf (stderr
, "%*s%-40s%*s:%s%s\n", indent
, " ", pn
,
575 (15 - indent
< 0 ? 0 : 15 - indent
), " ",
576 is_on
? " ON" : " OFF",
577 ((!is_on
) == (!is_really_on
) ? ""
578 : (is_really_on
? " (FORCED_ON)" : " (FORCED_OFF)")));
581 /* Dump pass list PASS with indentation INDENT. */
584 dump_pass_list (struct opt_pass
*pass
, int indent
)
588 dump_one_pass (pass
, indent
);
590 dump_pass_list (pass
->sub
, indent
+ 1);
596 /* Dump all optimization passes. */
601 struct cgraph_node
*n
, *node
= NULL
;
602 tree save_fndecl
= current_function_decl
;
609 if (DECL_STRUCT_FUNCTION (n
->decl
))
620 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
621 current_function_decl
= node
->decl
;
623 dump_pass_list (all_lowering_passes
, 1);
624 dump_pass_list (all_small_ipa_passes
, 1);
625 dump_pass_list (all_regular_ipa_passes
, 1);
626 dump_pass_list (all_lto_gen_passes
, 1);
627 dump_pass_list (all_passes
, 1);
630 current_function_decl
= save_fndecl
;
634 /* Returns the pass with NAME. */
636 static struct opt_pass
*
637 get_pass_by_name (const char *name
)
639 struct pass_registry
**slot
, pr
;
641 pr
.unique_name
= name
;
642 slot
= (struct pass_registry
**) htab_find_slot (name_to_pass_map
,
648 return (*slot
)->pass
;
652 /* Range [start, last]. */
658 const char *assem_name
;
659 struct uid_range
*next
;
662 typedef struct uid_range
*uid_range_p
;
664 DEF_VEC_P(uid_range_p
);
665 DEF_VEC_ALLOC_P(uid_range_p
, heap
);
667 static VEC(uid_range_p
, heap
) *enabled_pass_uid_range_tab
= NULL
;
668 static VEC(uid_range_p
, heap
) *disabled_pass_uid_range_tab
= NULL
;
671 /* Parse option string for -fdisable- and -fenable-
672 The syntax of the options:
675 -fdisable-<pass_name>
677 -fenable-<pass_name>=s1:e1,s2:e2,...
678 -fdisable-<pass_name>=s1:e1,s2:e2,...
682 enable_disable_pass (const char *arg
, bool is_enable
)
684 struct opt_pass
*pass
;
685 char *range_str
, *phase_name
;
686 char *argstr
= xstrdup (arg
);
687 VEC(uid_range_p
, heap
) **tab
= 0;
689 range_str
= strchr (argstr
,'=');
700 error ("unrecognized option -fenable");
702 error ("unrecognized option -fdisable");
706 pass
= get_pass_by_name (phase_name
);
707 if (!pass
|| pass
->static_pass_number
== -1)
710 error ("unknown pass %s specified in -fenable", phase_name
);
712 error ("unknown pass %s specified in -fdisble", phase_name
);
718 tab
= &enabled_pass_uid_range_tab
;
720 tab
= &disabled_pass_uid_range_tab
;
722 if ((unsigned) pass
->static_pass_number
>= VEC_length (uid_range_p
, *tab
))
723 VEC_safe_grow_cleared (uid_range_p
, heap
,
724 *tab
, pass
->static_pass_number
+ 1);
729 uid_range_p new_range
= XCNEW (struct uid_range
);
731 new_range
->start
= 0;
732 new_range
->last
= (unsigned)-1;
734 slot
= VEC_index (uid_range_p
, *tab
, pass
->static_pass_number
);
735 new_range
->next
= slot
;
736 VEC_replace (uid_range_p
, *tab
, pass
->static_pass_number
,
739 inform (UNKNOWN_LOCATION
, "enable pass %s for functions in the range "
740 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
742 inform (UNKNOWN_LOCATION
, "disable pass %s for functions in the range "
743 "of [%u, %u]", phase_name
, new_range
->start
, new_range
->last
);
747 char *next_range
= NULL
;
748 char *one_range
= range_str
;
749 char *end_val
= NULL
;
754 uid_range_p new_range
;
755 char *invalid
= NULL
;
757 char *func_name
= NULL
;
759 next_range
= strchr (one_range
, ',');
766 end_val
= strchr (one_range
, ':');
772 start
= strtol (one_range
, &invalid
, 10);
773 if (*invalid
|| start
< 0)
775 if (end_val
|| (one_range
[0] >= '0'
776 && one_range
[0] <= '9'))
778 error ("Invalid range %s in option %s",
780 is_enable
? "-fenable" : "-fdisable");
784 func_name
= one_range
;
788 new_range
= XCNEW (struct uid_range
);
791 new_range
->start
= (unsigned) start
;
792 new_range
->last
= (unsigned) start
;
796 new_range
->start
= (unsigned) -1;
797 new_range
->last
= (unsigned) -1;
798 new_range
->assem_name
= xstrdup (func_name
);
803 long last
= strtol (end_val
, &invalid
, 10);
804 if (*invalid
|| last
< start
)
806 error ("Invalid range %s in option %s",
808 is_enable
? "-fenable" : "-fdisable");
812 new_range
= XCNEW (struct uid_range
);
813 new_range
->start
= (unsigned) start
;
814 new_range
->last
= (unsigned) last
;
817 slot
= VEC_index (uid_range_p
, *tab
, pass
->static_pass_number
);
818 new_range
->next
= slot
;
819 VEC_replace (uid_range_p
, *tab
, pass
->static_pass_number
,
823 if (new_range
->assem_name
)
824 inform (UNKNOWN_LOCATION
,
825 "enable pass %s for function %s",
826 phase_name
, new_range
->assem_name
);
828 inform (UNKNOWN_LOCATION
,
829 "enable pass %s for functions in the range of [%u, %u]",
830 phase_name
, new_range
->start
, new_range
->last
);
834 if (new_range
->assem_name
)
835 inform (UNKNOWN_LOCATION
,
836 "disable pass %s for function %s",
837 phase_name
, new_range
->assem_name
);
839 inform (UNKNOWN_LOCATION
,
840 "disable pass %s for functions in the range of [%u, %u]",
841 phase_name
, new_range
->start
, new_range
->last
);
844 one_range
= next_range
;
845 } while (next_range
);
851 /* Enable pass specified by ARG. */
854 enable_pass (const char *arg
)
856 enable_disable_pass (arg
, true);
859 /* Disable pass specified by ARG. */
862 disable_pass (const char *arg
)
864 enable_disable_pass (arg
, false);
867 /* Returns true if PASS is explicitly enabled/disabled for FUNC. */
870 is_pass_explicitly_enabled_or_disabled (struct opt_pass
*pass
,
872 VEC(uid_range_p
, heap
) *tab
)
874 uid_range_p slot
, range
;
876 const char *aname
= NULL
;
879 || (unsigned) pass
->static_pass_number
>= VEC_length (uid_range_p
, tab
)
880 || pass
->static_pass_number
== -1)
883 slot
= VEC_index (uid_range_p
, tab
, pass
->static_pass_number
);
887 cgraph_uid
= func
? cgraph_get_node (func
)->uid
: 0;
888 if (func
&& DECL_ASSEMBLER_NAME_SET_P (func
))
889 aname
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func
));
894 if ((unsigned) cgraph_uid
>= range
->start
895 && (unsigned) cgraph_uid
<= range
->last
)
897 if (range
->assem_name
&& aname
898 && !strcmp (range
->assem_name
, aname
))
906 /* Look at the static_pass_number and duplicate the pass
907 if it is already added to a list. */
909 static struct opt_pass
*
910 make_pass_instance (struct opt_pass
*pass
, bool track_duplicates
)
912 /* A nonzero static_pass_number indicates that the
913 pass is already in the list. */
914 if (pass
->static_pass_number
)
916 struct opt_pass
*new_pass
;
918 if (pass
->type
== GIMPLE_PASS
919 || pass
->type
== RTL_PASS
920 || pass
->type
== SIMPLE_IPA_PASS
)
922 new_pass
= XNEW (struct opt_pass
);
923 memcpy (new_pass
, pass
, sizeof (struct opt_pass
));
925 else if (pass
->type
== IPA_PASS
)
927 new_pass
= (struct opt_pass
*)XNEW (struct ipa_opt_pass_d
);
928 memcpy (new_pass
, pass
, sizeof (struct ipa_opt_pass_d
));
933 new_pass
->next
= NULL
;
935 new_pass
->todo_flags_start
&= ~TODO_mark_first_instance
;
937 /* Indicate to register_dump_files that this pass has duplicates,
938 and so it should rename the dump file. The first instance will
939 be -1, and be number of duplicates = -static_pass_number - 1.
940 Subsequent instances will be > 0 and just the duplicate number. */
941 if ((pass
->name
&& pass
->name
[0] != '*') || track_duplicates
)
943 pass
->static_pass_number
-= 1;
944 new_pass
->static_pass_number
= -pass
->static_pass_number
;
950 pass
->todo_flags_start
|= TODO_mark_first_instance
;
951 pass
->static_pass_number
= -1;
953 invoke_plugin_callbacks (PLUGIN_NEW_PASS
, pass
);
958 /* Add a pass to the pass list. Duplicate the pass if it's already
961 static struct opt_pass
**
962 next_pass_1 (struct opt_pass
**list
, struct opt_pass
*pass
)
964 /* Every pass should have a name so that plugins can refer to them. */
965 gcc_assert (pass
->name
!= NULL
);
967 *list
= make_pass_instance (pass
, false);
969 return &(*list
)->next
;
972 /* List node for an inserted pass instance. We need to keep track of all
973 the newly-added pass instances (with 'added_pass_nodes' defined below)
974 so that we can register their dump files after pass-positioning is finished.
975 Registering dumping files needs to be post-processed or the
976 static_pass_number of the opt_pass object would be modified and mess up
977 the dump file names of future pass instances to be added. */
979 struct pass_list_node
981 struct opt_pass
*pass
;
982 struct pass_list_node
*next
;
985 static struct pass_list_node
*added_pass_nodes
= NULL
;
986 static struct pass_list_node
*prev_added_pass_node
;
988 /* Insert the pass at the proper position. Return true if the pass
989 is successfully added.
991 NEW_PASS_INFO - new pass to be inserted
992 PASS_LIST - root of the pass list to insert the new pass to */
995 position_pass (struct register_pass_info
*new_pass_info
,
996 struct opt_pass
**pass_list
)
998 struct opt_pass
*pass
= *pass_list
, *prev_pass
= NULL
;
999 bool success
= false;
1001 for ( ; pass
; prev_pass
= pass
, pass
= pass
->next
)
1003 /* Check if the current pass is of the same type as the new pass and
1004 matches the name and the instance number of the reference pass. */
1005 if (pass
->type
== new_pass_info
->pass
->type
1007 && !strcmp (pass
->name
, new_pass_info
->reference_pass_name
)
1008 && ((new_pass_info
->ref_pass_instance_number
== 0)
1009 || (new_pass_info
->ref_pass_instance_number
==
1010 pass
->static_pass_number
)
1011 || (new_pass_info
->ref_pass_instance_number
== 1
1012 && pass
->todo_flags_start
& TODO_mark_first_instance
)))
1014 struct opt_pass
*new_pass
;
1015 struct pass_list_node
*new_pass_node
;
1017 new_pass
= make_pass_instance (new_pass_info
->pass
, true);
1019 /* Insert the new pass instance based on the positioning op. */
1020 switch (new_pass_info
->pos_op
)
1022 case PASS_POS_INSERT_AFTER
:
1023 new_pass
->next
= pass
->next
;
1024 pass
->next
= new_pass
;
1026 /* Skip newly inserted pass to avoid repeated
1027 insertions in the case where the new pass and the
1028 existing one have the same name. */
1031 case PASS_POS_INSERT_BEFORE
:
1032 new_pass
->next
= pass
;
1034 prev_pass
->next
= new_pass
;
1036 *pass_list
= new_pass
;
1038 case PASS_POS_REPLACE
:
1039 new_pass
->next
= pass
->next
;
1041 prev_pass
->next
= new_pass
;
1043 *pass_list
= new_pass
;
1044 new_pass
->sub
= pass
->sub
;
1045 new_pass
->tv_id
= pass
->tv_id
;
1049 error ("invalid pass positioning operation");
1053 /* Save the newly added pass (instance) in the added_pass_nodes
1054 list so that we can register its dump file later. Note that
1055 we cannot register the dump file now because doing so will modify
1056 the static_pass_number of the opt_pass object and therefore
1057 mess up the dump file name of future instances. */
1058 new_pass_node
= XCNEW (struct pass_list_node
);
1059 new_pass_node
->pass
= new_pass
;
1060 if (!added_pass_nodes
)
1061 added_pass_nodes
= new_pass_node
;
1063 prev_added_pass_node
->next
= new_pass_node
;
1064 prev_added_pass_node
= new_pass_node
;
1069 if (pass
->sub
&& position_pass (new_pass_info
, &pass
->sub
))
1076 /* Hooks a new pass into the pass lists.
1078 PASS_INFO - pass information that specifies the opt_pass object,
1079 reference pass, instance number, and how to position
1083 register_pass (struct register_pass_info
*pass_info
)
1085 bool all_instances
, success
;
1087 /* The checks below could fail in buggy plugins. Existing GCC
1088 passes should never fail these checks, so we mention plugin in
1090 if (!pass_info
->pass
)
1091 fatal_error ("plugin cannot register a missing pass");
1093 if (!pass_info
->pass
->name
)
1094 fatal_error ("plugin cannot register an unnamed pass");
1096 if (!pass_info
->reference_pass_name
)
1098 ("plugin cannot register pass %qs without reference pass name",
1099 pass_info
->pass
->name
);
1101 /* Try to insert the new pass to the pass lists. We need to check
1102 all five lists as the reference pass could be in one (or all) of
1104 all_instances
= pass_info
->ref_pass_instance_number
== 0;
1105 success
= position_pass (pass_info
, &all_lowering_passes
);
1106 if (!success
|| all_instances
)
1107 success
|= position_pass (pass_info
, &all_small_ipa_passes
);
1108 if (!success
|| all_instances
)
1109 success
|= position_pass (pass_info
, &all_regular_ipa_passes
);
1110 if (!success
|| all_instances
)
1111 success
|= position_pass (pass_info
, &all_lto_gen_passes
);
1112 if (!success
|| all_instances
)
1113 success
|= position_pass (pass_info
, &all_passes
);
1116 ("pass %qs not found but is referenced by new pass %qs",
1117 pass_info
->reference_pass_name
, pass_info
->pass
->name
);
1119 /* OK, we have successfully inserted the new pass. We need to register
1120 the dump files for the newly added pass and its duplicates (if any).
1121 Because the registration of plugin/backend passes happens after the
1122 command-line options are parsed, the options that specify single
1123 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
1124 passes. Therefore we currently can only enable dumping of
1125 new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
1126 are specified. While doing so, we also delete the pass_list_node
1127 objects created during pass positioning. */
1128 while (added_pass_nodes
)
1130 struct pass_list_node
*next_node
= added_pass_nodes
->next
;
1131 enum tree_dump_index tdi
;
1132 register_one_dump_file (added_pass_nodes
->pass
);
1133 if (added_pass_nodes
->pass
->type
== SIMPLE_IPA_PASS
1134 || added_pass_nodes
->pass
->type
== IPA_PASS
)
1136 else if (added_pass_nodes
->pass
->type
== GIMPLE_PASS
)
1140 /* Check if dump-all flag is specified. */
1141 if (get_dump_file_info (tdi
)->state
)
1142 get_dump_file_info (added_pass_nodes
->pass
->static_pass_number
)
1143 ->state
= get_dump_file_info (tdi
)->state
;
1144 XDELETE (added_pass_nodes
);
1145 added_pass_nodes
= next_node
;
1149 /* Construct the pass tree. The sequencing of passes is driven by
1150 the cgraph routines:
1152 cgraph_finalize_compilation_unit ()
1153 for each node N in the cgraph
1154 cgraph_analyze_function (N)
1155 cgraph_lower_function (N) -> all_lowering_passes
1157 If we are optimizing, cgraph_optimize is then invoked:
1160 ipa_passes () -> all_small_ipa_passes
1161 cgraph_expand_all_functions ()
1162 for each node N in the cgraph
1163 cgraph_expand_function (N)
1164 tree_rest_of_compilation (DECL (N)) -> all_passes
1168 init_optimization_passes (void)
1170 struct opt_pass
**p
;
1172 #define NEXT_PASS(PASS) (p = next_pass_1 (p, &((PASS).pass)))
1174 /* All passes needed to lower the function into shape optimizers can
1175 operate on. These passes are always run first on the function, but
1176 backend might produce already lowered functions that are not processed
1178 p
= &all_lowering_passes
;
1179 NEXT_PASS (pass_warn_unused_result
);
1180 NEXT_PASS (pass_diagnose_omp_blocks
);
1181 NEXT_PASS (pass_mudflap_1
);
1182 NEXT_PASS (pass_lower_omp
);
1183 NEXT_PASS (pass_lower_cf
);
1184 NEXT_PASS (pass_refactor_eh
);
1185 NEXT_PASS (pass_lower_eh
);
1186 NEXT_PASS (pass_build_cfg
);
1187 NEXT_PASS (pass_warn_function_return
);
1188 NEXT_PASS (pass_build_cgraph_edges
);
1191 /* Interprocedural optimization passes. */
1192 p
= &all_small_ipa_passes
;
1193 NEXT_PASS (pass_ipa_free_lang_data
);
1194 NEXT_PASS (pass_ipa_function_and_variable_visibility
);
1195 NEXT_PASS (pass_early_local_passes
);
1197 struct opt_pass
**p
= &pass_early_local_passes
.pass
.sub
;
1198 NEXT_PASS (pass_fixup_cfg
);
1199 NEXT_PASS (pass_init_datastructures
);
1200 NEXT_PASS (pass_expand_omp
);
1202 NEXT_PASS (pass_referenced_vars
);
1203 NEXT_PASS (pass_build_ssa
);
1204 NEXT_PASS (pass_lower_vector
);
1205 NEXT_PASS (pass_early_warn_uninitialized
);
1206 NEXT_PASS (pass_rebuild_cgraph_edges
);
1207 NEXT_PASS (pass_threadsafe_analyze
);
1208 NEXT_PASS (pass_inline_parameters
);
1209 NEXT_PASS (pass_early_inline
);
1210 NEXT_PASS (pass_all_early_optimizations
);
1212 struct opt_pass
**p
= &pass_all_early_optimizations
.pass
.sub
;
1213 NEXT_PASS (pass_remove_cgraph_callee_edges
);
1214 NEXT_PASS (pass_rename_ssa_copies
);
1215 NEXT_PASS (pass_ccp
);
1216 NEXT_PASS (pass_forwprop
);
1217 /* pass_build_ealias is a dummy pass that ensures that we
1218 execute TODO_rebuild_alias at this point. Re-building
1219 alias information also rewrites no longer addressed
1220 locals into SSA form if possible. */
1221 NEXT_PASS (pass_build_ealias
);
1222 NEXT_PASS (pass_sra_early
);
1223 NEXT_PASS (pass_copy_prop
);
1224 NEXT_PASS (pass_merge_phi
);
1225 NEXT_PASS (pass_cd_dce
);
1226 NEXT_PASS (pass_early_ipa_sra
);
1227 NEXT_PASS (pass_tail_recursion
);
1228 NEXT_PASS (pass_convert_switch
);
1229 NEXT_PASS (pass_cleanup_eh
);
1230 NEXT_PASS (pass_profile
);
1231 NEXT_PASS (pass_local_pure_const
);
1232 /* Split functions creates parts that are not run through
1233 early optimizations again. It is thus good idea to do this
1235 NEXT_PASS (pass_split_functions
);
1237 NEXT_PASS (pass_release_ssa_names
);
1238 NEXT_PASS (pass_rebuild_cgraph_edges
);
1239 NEXT_PASS (pass_inline_parameters
);
1241 NEXT_PASS (pass_ipa_tree_profile
);
1243 struct opt_pass
**p
= &pass_ipa_tree_profile
.pass
.sub
;
1244 NEXT_PASS (pass_feedback_split_functions
);
1246 NEXT_PASS (pass_ipa_increase_alignment
);
1247 NEXT_PASS (pass_ipa_matrix_reorg
);
1248 NEXT_PASS (pass_ipa_multiversion_dispatch
);
1250 struct opt_pass
**p
= &pass_ipa_multiversion_dispatch
.pass
.sub
;
1251 NEXT_PASS (pass_tree_convert_builtin_dispatch
);
1252 /* Rebuilding cgraph edges is necessary as the above passes change
1253 the call graph. Otherwise, future optimizations use the old
1254 call graph and make wrong decisions sometimes.*/
1255 NEXT_PASS (pass_rebuild_cgraph_edges
);
1257 NEXT_PASS (pass_ipa_lower_emutls
);
1260 p
= &all_regular_ipa_passes
;
1261 NEXT_PASS (pass_ipa_whole_program_visibility
);
1262 NEXT_PASS (pass_ipa_profile
);
1263 NEXT_PASS (pass_ipa_cp
);
1264 NEXT_PASS (pass_ipa_cdtor_merge
);
1265 NEXT_PASS (pass_ipa_inline
);
1266 NEXT_PASS (pass_ipa_pure_const
);
1267 NEXT_PASS (pass_ipa_reference
);
1268 NEXT_PASS (pass_ipa_type_escape
);
1269 NEXT_PASS (pass_ipa_pta
);
1270 NEXT_PASS (pass_ipa_struct_reorg
);
1273 p
= &all_lto_gen_passes
;
1274 NEXT_PASS (pass_ipa_lto_gimple_out
);
1275 NEXT_PASS (pass_ipa_lto_finish_out
); /* This must be the last LTO pass. */
1278 /* These passes are run after IPA passes on every function that is being
1279 output to the assembler file. */
1281 NEXT_PASS (pass_auto_clone
);
1282 NEXT_PASS (pass_direct_call_profile
);
1283 NEXT_PASS (pass_lower_eh_dispatch
);
1284 NEXT_PASS (pass_all_optimizations
);
1286 struct opt_pass
**p
= &pass_all_optimizations
.pass
.sub
;
1287 NEXT_PASS (pass_remove_cgraph_callee_edges
);
1288 /* Initial scalar cleanups before alias computation.
1289 They ensure memory accesses are not indirect wherever possible. */
1290 NEXT_PASS (pass_strip_predict_hints
);
1291 NEXT_PASS (pass_rename_ssa_copies
);
1292 NEXT_PASS (pass_complete_unrolli
);
1293 NEXT_PASS (pass_ccp
);
1294 NEXT_PASS (pass_forwprop
);
1295 NEXT_PASS (pass_call_cdce
);
1296 /* pass_build_alias is a dummy pass that ensures that we
1297 execute TODO_rebuild_alias at this point. Re-building
1298 alias information also rewrites no longer addressed
1299 locals into SSA form if possible. */
1300 NEXT_PASS (pass_build_alias
);
1301 NEXT_PASS (pass_return_slot
);
1302 NEXT_PASS (pass_phiprop
);
1303 NEXT_PASS (pass_fre
);
1304 NEXT_PASS (pass_copy_prop
);
1305 NEXT_PASS (pass_merge_phi
);
1306 NEXT_PASS (pass_vrp
);
1307 NEXT_PASS (pass_dce
);
1308 NEXT_PASS (pass_cselim
);
1309 NEXT_PASS (pass_tree_ifcombine
);
1310 NEXT_PASS (pass_phiopt
);
1311 NEXT_PASS (pass_tail_recursion
);
1312 NEXT_PASS (pass_ch
);
1313 NEXT_PASS (pass_stdarg
);
1314 NEXT_PASS (pass_lower_complex
);
1315 NEXT_PASS (pass_sra
);
1316 NEXT_PASS (pass_rename_ssa_copies
);
1317 /* The dom pass will also resolve all __builtin_constant_p calls
1318 that are still there to 0. This has to be done after some
1319 propagations have already run, but before some more dead code
1320 is removed, and this place fits nicely. Remember this when
1321 trying to move or duplicate pass_dominator somewhere earlier. */
1322 NEXT_PASS (pass_dominator
);
1323 /* The only const/copy propagation opportunities left after
1324 DOM should be due to degenerate PHI nodes. So rather than
1325 run the full propagators, run a specialized pass which
1326 only examines PHIs to discover const/copy propagation
1328 NEXT_PASS (pass_phi_only_cprop
);
1329 NEXT_PASS (pass_dse
);
1330 NEXT_PASS (pass_reassoc
);
1331 NEXT_PASS (pass_dce
);
1332 NEXT_PASS (pass_forwprop
);
1333 NEXT_PASS (pass_phiopt
);
1334 NEXT_PASS (pass_object_sizes
);
1335 NEXT_PASS (pass_ccp
);
1336 NEXT_PASS (pass_copy_prop
);
1337 NEXT_PASS (pass_cse_sincos
);
1338 NEXT_PASS (pass_optimize_bswap
);
1339 NEXT_PASS (pass_split_crit_edges
);
1340 NEXT_PASS (pass_pre
);
1341 NEXT_PASS (pass_sink_code
);
1342 NEXT_PASS (pass_tsan
);
1343 NEXT_PASS (pass_tree_loop
);
1345 struct opt_pass
**p
= &pass_tree_loop
.pass
.sub
;
1346 NEXT_PASS (pass_tree_loop_init
);
1347 NEXT_PASS (pass_lim
);
1348 NEXT_PASS (pass_copy_prop
);
1349 NEXT_PASS (pass_dce_loop
);
1350 NEXT_PASS (pass_tree_unswitch
);
1351 NEXT_PASS (pass_scev_cprop
);
1352 NEXT_PASS (pass_record_bounds
);
1353 NEXT_PASS (pass_check_data_deps
);
1354 NEXT_PASS (pass_loop_distribution
);
1355 NEXT_PASS (pass_copy_prop
);
1356 NEXT_PASS (pass_graphite
);
1358 struct opt_pass
**p
= &pass_graphite
.pass
.sub
;
1359 NEXT_PASS (pass_graphite_transforms
);
1360 NEXT_PASS (pass_lim
);
1361 NEXT_PASS (pass_copy_prop
);
1362 NEXT_PASS (pass_dce_loop
);
1364 NEXT_PASS (pass_iv_canon
);
1365 NEXT_PASS (pass_if_conversion
);
1366 NEXT_PASS (pass_vectorize
);
1368 struct opt_pass
**p
= &pass_vectorize
.pass
.sub
;
1369 NEXT_PASS (pass_lower_vector_ssa
);
1370 NEXT_PASS (pass_dce_loop
);
1372 NEXT_PASS (pass_predcom
);
1373 NEXT_PASS (pass_complete_unroll
);
1374 NEXT_PASS (pass_slp_vectorize
);
1375 NEXT_PASS (pass_parallelize_loops
);
1376 NEXT_PASS (pass_loop_prefetch
);
1377 NEXT_PASS (pass_iv_optimize
);
1378 NEXT_PASS (pass_tree_loop_done
);
1380 NEXT_PASS (pass_cse_reciprocals
);
1381 NEXT_PASS (pass_reassoc
);
1382 NEXT_PASS (pass_vrp
);
1383 NEXT_PASS (pass_dominator
);
1384 /* The only const/copy propagation opportunities left after
1385 DOM should be due to degenerate PHI nodes. So rather than
1386 run the full propagators, run a specialized pass which
1387 only examines PHIs to discover const/copy propagation
1389 NEXT_PASS (pass_phi_only_cprop
);
1390 NEXT_PASS (pass_cd_dce
);
1391 NEXT_PASS (pass_tracer
);
1393 /* FIXME: If DCE is not run before checking for uninitialized uses,
1394 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
1395 However, this also causes us to misdiagnose cases that should be
1396 real warnings (e.g., testsuite/gcc.dg/pr18501.c).
1398 To fix the false positives in uninit-5.c, we would have to
1399 account for the predicates protecting the set and the use of each
1400 variable. Using a representation like Gated Single Assignment
1402 NEXT_PASS (pass_late_warn_uninitialized
);
1403 NEXT_PASS (pass_dse
);
1404 NEXT_PASS (pass_forwprop
);
1405 NEXT_PASS (pass_phiopt
);
1406 NEXT_PASS (pass_fold_builtins
);
1407 NEXT_PASS (pass_optimize_widening_mul
);
1408 NEXT_PASS (pass_tail_calls
);
1409 NEXT_PASS (pass_rename_ssa_copies
);
1410 NEXT_PASS (pass_uncprop
);
1411 NEXT_PASS (pass_local_pure_const
);
1413 NEXT_PASS (pass_lower_complex_O0
);
1414 NEXT_PASS (pass_cleanup_eh
);
1415 NEXT_PASS (pass_lower_resx
);
1416 NEXT_PASS (pass_nrv
);
1417 NEXT_PASS (pass_mudflap_2
);
1418 NEXT_PASS (pass_cleanup_cfg_post_optimizing
);
1419 NEXT_PASS (pass_warn_function_noreturn
);
1421 NEXT_PASS (pass_expand
);
1423 NEXT_PASS (pass_rest_of_compilation
);
1425 struct opt_pass
**p
= &pass_rest_of_compilation
.pass
.sub
;
1426 NEXT_PASS (pass_init_function
);
1427 NEXT_PASS (pass_jump
);
1428 NEXT_PASS (pass_rtl_eh
);
1429 NEXT_PASS (pass_initial_value_sets
);
1430 NEXT_PASS (pass_unshare_all_rtl
);
1431 NEXT_PASS (pass_instantiate_virtual_regs
);
1432 NEXT_PASS (pass_into_cfg_layout_mode
);
1433 NEXT_PASS (pass_jump2
);
1434 NEXT_PASS (pass_lower_subreg
);
1435 NEXT_PASS (pass_df_initialize_opt
);
1436 NEXT_PASS (pass_cse
);
1437 NEXT_PASS (pass_rtl_fwprop
);
1438 NEXT_PASS (pass_rtl_cprop
);
1439 NEXT_PASS (pass_rtl_pre
);
1440 NEXT_PASS (pass_rtl_hoist
);
1441 NEXT_PASS (pass_rtl_cprop
);
1442 NEXT_PASS (pass_rtl_store_motion
);
1443 NEXT_PASS (pass_cse_after_global_opts
);
1444 NEXT_PASS (pass_rtl_ifcvt
);
1445 NEXT_PASS (pass_reginfo_init
);
1446 /* Perform loop optimizations. It might be better to do them a bit
1447 sooner, but we want the profile feedback to work more
1449 NEXT_PASS (pass_loop2
);
1451 struct opt_pass
**p
= &pass_loop2
.pass
.sub
;
1452 NEXT_PASS (pass_rtl_loop_init
);
1453 NEXT_PASS (pass_rtl_move_loop_invariants
);
1454 NEXT_PASS (pass_rtl_unswitch
);
1455 NEXT_PASS (pass_rtl_unroll_and_peel_loops
);
1456 NEXT_PASS (pass_rtl_doloop
);
1457 NEXT_PASS (pass_rtl_loop_done
);
1460 NEXT_PASS (pass_simplify_got
);
1461 NEXT_PASS (pass_web
);
1462 NEXT_PASS (pass_rtl_cprop
);
1463 NEXT_PASS (pass_cse2
);
1464 NEXT_PASS (pass_rtl_dse1
);
1465 NEXT_PASS (pass_rtl_fwprop_addr
);
1466 NEXT_PASS (pass_inc_dec
);
1467 NEXT_PASS (pass_initialize_regs
);
1468 NEXT_PASS (pass_ud_rtl_dce
);
1469 NEXT_PASS (pass_combine
);
1470 NEXT_PASS (pass_if_after_combine
);
1471 NEXT_PASS (pass_partition_blocks
);
1472 NEXT_PASS (pass_regmove
);
1473 NEXT_PASS (pass_outof_cfg_layout_mode
);
1474 NEXT_PASS (pass_split_all_insns
);
1475 NEXT_PASS (pass_lower_subreg2
);
1476 NEXT_PASS (pass_df_initialize_no_opt
);
1477 NEXT_PASS (pass_stack_ptr_mod
);
1478 NEXT_PASS (pass_mode_switching
);
1479 NEXT_PASS (pass_match_asm_constraints
);
1480 NEXT_PASS (pass_sms
);
1481 NEXT_PASS (pass_sched
);
1482 NEXT_PASS (pass_ira
);
1483 NEXT_PASS (pass_postreload
);
1485 struct opt_pass
**p
= &pass_postreload
.pass
.sub
;
1486 NEXT_PASS (pass_postreload_cse
);
1487 NEXT_PASS (pass_gcse2
);
1488 NEXT_PASS (pass_split_after_reload
);
1489 NEXT_PASS (pass_implicit_zee
);
1490 NEXT_PASS (pass_compare_elim_after_reload
);
1491 NEXT_PASS (pass_branch_target_load_optimize1
);
1492 NEXT_PASS (pass_thread_prologue_and_epilogue
);
1493 NEXT_PASS (pass_rtl_dse2
);
1494 NEXT_PASS (pass_stack_adjustments
);
1495 NEXT_PASS (pass_peephole2
);
1496 NEXT_PASS (pass_if_after_reload
);
1497 NEXT_PASS (pass_regrename
);
1498 NEXT_PASS (pass_cprop_hardreg
);
1499 NEXT_PASS (pass_fast_rtl_dce
);
1500 NEXT_PASS (pass_reorder_blocks
);
1501 NEXT_PASS (pass_branch_target_load_optimize2
);
1502 NEXT_PASS (pass_leaf_regs
);
1503 NEXT_PASS (pass_split_before_sched2
);
1504 NEXT_PASS (pass_sched2
);
1505 NEXT_PASS (pass_stack_regs
);
1507 struct opt_pass
**p
= &pass_stack_regs
.pass
.sub
;
1508 NEXT_PASS (pass_split_before_regstack
);
1509 NEXT_PASS (pass_stack_regs_run
);
1511 NEXT_PASS (pass_compute_alignments
);
1512 NEXT_PASS (pass_duplicate_computed_gotos
);
1513 NEXT_PASS (pass_variable_tracking
);
1514 NEXT_PASS (pass_free_cfg
);
1515 NEXT_PASS (pass_machine_reorg
);
1516 NEXT_PASS (pass_cleanup_barriers
);
1517 NEXT_PASS (pass_delay_slots
);
1518 NEXT_PASS (pass_split_for_shorten_branches
);
1519 NEXT_PASS (pass_convert_to_eh_region_ranges
);
1520 NEXT_PASS (pass_shorten_branches
);
1521 NEXT_PASS (pass_set_nothrow_function_flags
);
1522 NEXT_PASS (pass_final
);
1524 NEXT_PASS (pass_df_finish
);
1526 NEXT_PASS (pass_clean_state
);
1531 /* Register the passes with the tree dump code. */
1532 register_dump_files (all_lowering_passes
, PROP_gimple_any
);
1533 register_dump_files (all_small_ipa_passes
,
1534 PROP_gimple_any
| PROP_gimple_lcf
| PROP_gimple_leh
1536 register_dump_files (all_regular_ipa_passes
,
1537 PROP_gimple_any
| PROP_gimple_lcf
| PROP_gimple_leh
1539 register_dump_files (all_lto_gen_passes
,
1540 PROP_gimple_any
| PROP_gimple_lcf
| PROP_gimple_leh
1542 register_dump_files (all_passes
,
1543 PROP_gimple_any
| PROP_gimple_lcf
| PROP_gimple_leh
1547 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1548 function CALLBACK for every function in the call graph. Otherwise,
1549 call CALLBACK on the current function. */
1552 do_per_function (void (*callback
) (void *data
), void *data
)
1554 if (current_function_decl
)
1558 struct cgraph_node
*node
;
1559 for (node
= cgraph_nodes
; node
; node
= node
->next
)
1560 if (node
->analyzed
&& gimple_has_body_p (node
->decl
)
1561 && (!node
->clone_of
|| node
->decl
!= node
->clone_of
->decl
))
1563 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
1564 current_function_decl
= node
->decl
;
1568 free_dominance_info (CDI_DOMINATORS
);
1569 free_dominance_info (CDI_POST_DOMINATORS
);
1571 current_function_decl
= NULL
;
1578 /* Because inlining might remove no-longer reachable nodes, we need to
1579 keep the array visible to garbage collector to avoid reading collected
1582 static GTY ((length ("nnodes"))) cgraph_node_ptr
*order
;
1584 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1585 function CALLBACK for every function in the call graph. Otherwise,
1586 call CALLBACK on the current function.
1587 This function is global so that plugins can use it. */
1589 do_per_function_toporder (void (*callback
) (void *data
), void *data
)
1593 if (current_function_decl
)
1597 gcc_assert (!order
);
1598 order
= ggc_alloc_vec_cgraph_node_ptr (cgraph_n_nodes
);
1599 nnodes
= cgraph_postorder (order
);
1600 for (i
= nnodes
- 1; i
>= 0; i
--)
1601 order
[i
]->process
= 1;
1602 for (i
= nnodes
- 1; i
>= 0; i
--)
1604 struct cgraph_node
*node
= order
[i
];
1606 /* Allow possibly removed nodes to be garbage collected. */
1611 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
1612 current_function_decl
= node
->decl
;
1614 free_dominance_info (CDI_DOMINATORS
);
1615 free_dominance_info (CDI_POST_DOMINATORS
);
1616 current_function_decl
= NULL
;
1627 /* Perform all TODO actions that ought to be done on each function. */
1630 execute_function_todo (void *data
)
1632 unsigned int flags
= (size_t)data
;
1633 flags
&= ~cfun
->last_verified
;
1637 /* Always cleanup the CFG before trying to update SSA. */
1638 if (flags
& TODO_cleanup_cfg
)
1640 bool cleanup
= cleanup_tree_cfg ();
1642 if (cleanup
&& (cfun
->curr_properties
& PROP_ssa
))
1643 flags
|= TODO_remove_unused_locals
;
1645 /* When cleanup_tree_cfg merges consecutive blocks, it may
1646 perform some simplistic propagation when removing single
1647 valued PHI nodes. This propagation may, in turn, cause the
1648 SSA form to become out-of-date (see PR 22037). So, even
1649 if the parent pass had not scheduled an SSA update, we may
1650 still need to do one. */
1651 if (!(flags
& TODO_update_ssa_any
) && need_ssa_update_p (cfun
))
1652 flags
|= TODO_update_ssa
;
1655 if (flags
& TODO_update_ssa_any
)
1657 unsigned update_flags
= flags
& TODO_update_ssa_any
;
1658 update_ssa (update_flags
);
1659 cfun
->last_verified
&= ~TODO_verify_ssa
;
1662 if (flags
& TODO_rebuild_alias
)
1664 execute_update_addresses_taken ();
1665 compute_may_aliases ();
1667 else if (optimize
&& (flags
& TODO_update_address_taken
))
1668 execute_update_addresses_taken ();
1670 if (flags
& TODO_remove_unused_locals
)
1671 remove_unused_locals ();
1673 if ((flags
& TODO_dump_func
) && dump_file
&& current_function_decl
)
1675 if (cfun
->curr_properties
& PROP_trees
)
1676 dump_function_to_file (current_function_decl
, dump_file
, dump_flags
);
1679 if (dump_flags
& TDF_SLIM
)
1680 print_rtl_slim_with_bb (dump_file
, get_insns (), dump_flags
);
1681 else if ((cfun
->curr_properties
& PROP_cfg
)
1682 && (dump_flags
& TDF_BLOCKS
))
1683 print_rtl_with_bb (dump_file
, get_insns ());
1685 print_rtl (dump_file
, get_insns ());
1687 if ((cfun
->curr_properties
& PROP_cfg
)
1688 && graph_dump_format
!= no_graph
1689 && (dump_flags
& TDF_GRAPH
))
1690 print_rtl_graph_with_bb (dump_file_name
, get_insns ());
1693 /* Flush the file. If verification fails, we won't be able to
1694 close the file before aborting. */
1698 if (flags
& TODO_rebuild_frequencies
)
1699 rebuild_frequencies ();
1701 if (flags
& TODO_rebuild_cgraph_edges
)
1702 rebuild_cgraph_edges ();
1704 /* If we've seen errors do not bother running any verifiers. */
1708 #if defined ENABLE_CHECKING
1709 if (flags
& TODO_verify_ssa
1710 || (current_loops
&& loops_state_satisfies_p (LOOP_CLOSED_SSA
)))
1712 if (flags
& TODO_verify_flow
)
1713 verify_flow_info ();
1714 if (flags
& TODO_verify_stmts
)
1716 if (current_loops
&& loops_state_satisfies_p (LOOP_CLOSED_SSA
))
1717 verify_loop_closed_ssa (false);
1718 if (flags
& TODO_verify_rtl_sharing
)
1719 verify_rtl_sharing ();
1722 cfun
->last_verified
= flags
& TODO_verify_all
;
1725 /* Perform all TODO actions. */
1727 execute_todo (unsigned int flags
)
1729 #if defined ENABLE_CHECKING
1731 && need_ssa_update_p (cfun
))
1732 gcc_assert (flags
& TODO_update_ssa_any
);
1735 timevar_push (TV_TODO
);
1737 /* Inform the pass whether it is the first time it is run. */
1738 first_pass_instance
= (flags
& TODO_mark_first_instance
) != 0;
1740 statistics_fini_pass ();
1742 do_per_function (execute_function_todo
, (void *)(size_t) flags
);
1744 /* Always remove functions just as before inlining: IPA passes might be
1745 interested to see bodies of extern inline functions that are not inlined
1746 to analyze side effects. The full removal is done just at the end
1747 of IPA pass queue. */
1748 if (flags
& TODO_remove_functions
)
1751 cgraph_remove_unreachable_nodes (true, dump_file
);
1754 if ((flags
& TODO_dump_cgraph
) && dump_file
&& !current_function_decl
)
1757 dump_cgraph (dump_file
);
1758 /* Flush the file. If verification fails, we won't be able to
1759 close the file before aborting. */
1763 if (flags
& TODO_ggc_collect
)
1766 /* Now that the dumping has been done, we can get rid of the optional
1768 if (flags
& TODO_df_finish
)
1769 df_finish_pass ((flags
& TODO_df_verify
) != 0);
1771 timevar_pop (TV_TODO
);
1774 /* Verify invariants that should hold between passes. This is a place
1775 to put simple sanity checks. */
1778 verify_interpass_invariants (void)
1780 gcc_checking_assert (!fold_deferring_overflow_warnings_p ());
1783 /* Clear the last verified flag. */
1786 clear_last_verified (void *data ATTRIBUTE_UNUSED
)
1788 cfun
->last_verified
= 0;
1791 /* Helper function. Verify that the properties has been turn into the
1792 properties expected by the pass. */
1794 #ifdef ENABLE_CHECKING
1796 verify_curr_properties (void *data
)
1798 unsigned int props
= (size_t)data
;
1799 gcc_assert ((cfun
->curr_properties
& props
) == props
);
1803 /* Initialize pass dump file. */
1804 /* This is non-static so that the plugins can use it. */
1807 pass_init_dump_file (struct opt_pass
*pass
)
1809 /* If a dump file name is present, open it if enabled. */
1810 if (pass
->static_pass_number
!= -1)
1812 bool initializing_dump
= !dump_initialized_p (pass
->static_pass_number
);
1813 dump_file_name
= get_dump_file_name (pass
->static_pass_number
);
1814 dump_file
= dump_begin (pass
->static_pass_number
, &dump_flags
);
1815 if (dump_file
&& current_function_decl
)
1816 dump_function_header (dump_file
, current_function_decl
, dump_flags
);
1817 return initializing_dump
;
1823 /* Flush PASS dump file. */
1824 /* This is non-static so that plugins can use it. */
1827 pass_fini_dump_file (struct opt_pass
*pass
)
1829 /* Flush and close dump file. */
1832 free (CONST_CAST (char *, dump_file_name
));
1833 dump_file_name
= NULL
;
1838 dump_end (pass
->static_pass_number
, dump_file
);
1843 /* After executing the pass, apply expected changes to the function
1847 update_properties_after_pass (void *data
)
1849 struct opt_pass
*pass
= (struct opt_pass
*) data
;
1850 cfun
->curr_properties
= (cfun
->curr_properties
| pass
->properties_provided
)
1851 & ~pass
->properties_destroyed
;
1854 /* Execute summary generation for all of the passes in IPA_PASS. */
1857 execute_ipa_summary_passes (struct ipa_opt_pass_d
*ipa_pass
)
1861 struct opt_pass
*pass
= &ipa_pass
->pass
;
1863 /* Execute all of the IPA_PASSes in the list. */
1864 if (ipa_pass
->pass
.type
== IPA_PASS
1865 && (!pass
->gate
|| pass
->gate ())
1866 && ipa_pass
->generate_summary
)
1868 pass_init_dump_file (pass
);
1870 /* If a timevar is present, start it. */
1872 timevar_push (pass
->tv_id
);
1874 ipa_pass
->generate_summary ();
1878 timevar_pop (pass
->tv_id
);
1880 pass_fini_dump_file (pass
);
1882 ipa_pass
= (struct ipa_opt_pass_d
*)ipa_pass
->pass
.next
;
1886 /* Execute IPA_PASS function transform on NODE. */
1889 execute_one_ipa_transform_pass (struct cgraph_node
*node
,
1890 struct ipa_opt_pass_d
*ipa_pass
)
1892 struct opt_pass
*pass
= &ipa_pass
->pass
;
1893 unsigned int todo_after
= 0;
1895 current_pass
= pass
;
1896 if (!ipa_pass
->function_transform
)
1899 /* Note that the folders should only create gimple expressions.
1900 This is a hack until the new folder is ready. */
1901 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
1903 pass_init_dump_file (pass
);
1905 /* Run pre-pass verification. */
1906 execute_todo (ipa_pass
->function_transform_todo_flags_start
);
1908 /* If a timevar is present, start it. */
1909 if (pass
->tv_id
!= TV_NONE
)
1910 timevar_push (pass
->tv_id
);
1913 todo_after
= ipa_pass
->function_transform (node
);
1916 if (pass
->tv_id
!= TV_NONE
)
1917 timevar_pop (pass
->tv_id
);
1919 /* Run post-pass cleanup and verification. */
1920 execute_todo (todo_after
);
1921 verify_interpass_invariants ();
1923 pass_fini_dump_file (pass
);
1925 current_pass
= NULL
;
1928 /* For the current function, execute all ipa transforms. */
1931 execute_all_ipa_transforms (void)
1933 struct cgraph_node
*node
;
1936 node
= cgraph_node (current_function_decl
);
1938 if (node
->ipa_transforms_to_apply
)
1942 for (i
= 0; i
< VEC_length (ipa_opt_pass
, node
->ipa_transforms_to_apply
);
1944 execute_one_ipa_transform_pass (node
,
1945 VEC_index (ipa_opt_pass
,
1946 node
->ipa_transforms_to_apply
,
1948 VEC_free (ipa_opt_pass
, heap
, node
->ipa_transforms_to_apply
);
1949 node
->ipa_transforms_to_apply
= NULL
;
1953 /* Check if PASS is explicitly disabled or enabled and return
1954 the gate status. FUNC is the function to be processed, and
1955 GATE_STATUS is the gate status determined by pass manager by
1959 override_gate_status (struct opt_pass
*pass
, tree func
, bool gate_status
)
1961 bool explicitly_enabled
= false;
1962 bool explicitly_disabled
= false;
1965 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
1966 enabled_pass_uid_range_tab
);
1968 = is_pass_explicitly_enabled_or_disabled (pass
, func
,
1969 disabled_pass_uid_range_tab
);
1971 gate_status
= !explicitly_disabled
&& (gate_status
|| explicitly_enabled
);
1980 execute_one_pass (struct opt_pass
*pass
)
1982 bool initializing_dump
;
1983 unsigned int todo_after
= 0;
1987 /* IPA passes are executed on whole program, so cfun should be NULL.
1988 Other passes need function context set. */
1989 if (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
)
1990 gcc_assert (!cfun
&& !current_function_decl
);
1992 gcc_assert (cfun
&& current_function_decl
);
1994 current_pass
= pass
;
1996 /* Check whether gate check should be avoided.
1997 User controls the value of the gate through the parameter "gate_status". */
1998 gate_status
= (pass
->gate
== NULL
) ? true : pass
->gate();
1999 gate_status
= override_gate_status (pass
, current_function_decl
, gate_status
);
2001 /* Override gate with plugin. */
2002 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE
, &gate_status
);
2006 current_pass
= NULL
;
2010 /* Pass execution event trigger: useful to identify passes being
2012 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION
, pass
);
2014 if (!quiet_flag
&& !cfun
)
2015 fprintf (stderr
, " <%s>", pass
->name
? pass
->name
: "");
2017 /* Note that the folders should only create gimple expressions.
2018 This is a hack until the new folder is ready. */
2019 in_gimple_form
= (cfun
&& (cfun
->curr_properties
& PROP_trees
)) != 0;
2021 initializing_dump
= pass_init_dump_file (pass
);
2023 /* Run pre-pass verification. */
2024 execute_todo (pass
->todo_flags_start
);
2026 #ifdef ENABLE_CHECKING
2027 do_per_function (verify_curr_properties
,
2028 (void *)(size_t)pass
->properties_required
);
2031 /* If a timevar is present, start it. */
2032 if (pass
->tv_id
!= TV_NONE
)
2033 timevar_push (pass
->tv_id
);
2038 todo_after
= pass
->execute ();
2039 do_per_function (clear_last_verified
, NULL
);
2043 if (pass
->tv_id
!= TV_NONE
)
2044 timevar_pop (pass
->tv_id
);
2046 do_per_function (update_properties_after_pass
, pass
);
2048 if (initializing_dump
2050 && graph_dump_format
!= no_graph
2052 && (cfun
->curr_properties
& (PROP_cfg
| PROP_rtl
))
2053 == (PROP_cfg
| PROP_rtl
))
2055 get_dump_file_info (pass
->static_pass_number
)->flags
|= TDF_GRAPH
;
2056 dump_flags
|= TDF_GRAPH
;
2057 clean_graph_dump_file (dump_file_name
);
2060 /* Run post-pass cleanup and verification. */
2061 execute_todo (todo_after
| pass
->todo_flags_finish
);
2062 verify_interpass_invariants ();
2063 if (pass
->type
== IPA_PASS
)
2065 struct cgraph_node
*node
;
2066 for (node
= cgraph_nodes
; node
; node
= node
->next
)
2068 VEC_safe_push (ipa_opt_pass
, heap
, node
->ipa_transforms_to_apply
,
2069 (struct ipa_opt_pass_d
*)pass
);
2072 if (!current_function_decl
)
2073 cgraph_process_new_functions ();
2075 pass_fini_dump_file (pass
);
2077 if (pass
->type
!= SIMPLE_IPA_PASS
&& pass
->type
!= IPA_PASS
)
2078 gcc_assert (!(cfun
->curr_properties
& PROP_trees
)
2079 || pass
->type
!= RTL_PASS
);
2081 current_pass
= NULL
;
2087 execute_pass_list (struct opt_pass
*pass
)
2091 gcc_assert (pass
->type
== GIMPLE_PASS
2092 || pass
->type
== RTL_PASS
);
2093 if (execute_one_pass (pass
) && pass
->sub
)
2094 execute_pass_list (pass
->sub
);
2100 /* Same as execute_pass_list but assume that subpasses of IPA passes
2101 are local passes. If SET is not NULL, write out summaries of only
2102 those node in SET. */
2105 ipa_write_summaries_2 (struct opt_pass
*pass
, cgraph_node_set set
,
2106 varpool_node_set vset
,
2107 struct lto_out_decl_state
*state
)
2111 struct ipa_opt_pass_d
*ipa_pass
= (struct ipa_opt_pass_d
*)pass
;
2112 gcc_assert (!current_function_decl
);
2114 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2115 if (pass
->type
== IPA_PASS
2116 && ipa_pass
->write_summary
2117 && (!pass
->gate
|| pass
->gate ()))
2119 /* If a timevar is present, start it. */
2121 timevar_push (pass
->tv_id
);
2123 pass_init_dump_file (pass
);
2125 ipa_pass
->write_summary (set
,vset
);
2127 pass_fini_dump_file (pass
);
2129 /* If a timevar is present, start it. */
2131 timevar_pop (pass
->tv_id
);
2134 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2135 ipa_write_summaries_2 (pass
->sub
, set
, vset
, state
);
2141 /* Helper function of ipa_write_summaries. Creates and destroys the
2142 decl state and calls ipa_write_summaries_2 for all passes that have
2143 summaries. SET is the set of nodes to be written. */
2146 ipa_write_summaries_1 (cgraph_node_set set
, varpool_node_set vset
)
2148 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2149 compute_ltrans_boundary (state
, set
, vset
);
2151 lto_push_out_decl_state (state
);
2153 gcc_assert (!flag_wpa
);
2154 ipa_write_summaries_2 (all_regular_ipa_passes
, set
, vset
, state
);
2155 ipa_write_summaries_2 (all_lto_gen_passes
, set
, vset
, state
);
2157 gcc_assert (lto_get_out_decl_state () == state
);
2158 lto_pop_out_decl_state ();
2159 lto_delete_out_decl_state (state
);
2162 /* Write out summaries for all the nodes in the callgraph. */
2165 ipa_write_summaries (void)
2167 cgraph_node_set set
;
2168 varpool_node_set vset
;
2169 struct cgraph_node
**order
;
2170 struct varpool_node
*vnode
;
2173 if (!flag_generate_lto
|| seen_error ())
2176 set
= cgraph_node_set_new ();
2178 /* Create the callgraph set in the same order used in
2179 cgraph_expand_all_functions. This mostly facilitates debugging,
2180 since it causes the gimple file to be processed in the same order
2181 as the source code. */
2182 order
= XCNEWVEC (struct cgraph_node
*, cgraph_n_nodes
);
2183 order_pos
= cgraph_postorder (order
);
2184 gcc_assert (order_pos
== cgraph_n_nodes
);
2186 for (i
= order_pos
- 1; i
>= 0; i
--)
2188 struct cgraph_node
*node
= order
[i
];
2192 /* When streaming out references to statements as part of some IPA
2193 pass summary, the statements need to have uids assigned and the
2194 following does that for all the IPA passes here. Naturally, this
2195 ordering then matches the one IPA-passes get in their stmt_fixup
2198 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2199 renumber_gimple_stmt_uids ();
2203 cgraph_node_set_add (set
, node
);
2205 vset
= varpool_node_set_new ();
2207 for (vnode
= varpool_nodes
; vnode
; vnode
= vnode
->next
)
2208 if (vnode
->needed
&& !vnode
->alias
)
2209 varpool_node_set_add (vset
, vnode
);
2211 ipa_write_summaries_1 (set
, vset
);
2218 /* Same as execute_pass_list but assume that subpasses of IPA passes
2219 are local passes. If SET is not NULL, write out optimization summaries of
2220 only those node in SET. */
2223 ipa_write_optimization_summaries_1 (struct opt_pass
*pass
, cgraph_node_set set
,
2224 varpool_node_set vset
,
2225 struct lto_out_decl_state
*state
)
2229 struct ipa_opt_pass_d
*ipa_pass
= (struct ipa_opt_pass_d
*)pass
;
2230 gcc_assert (!current_function_decl
);
2232 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2233 if (pass
->type
== IPA_PASS
2234 && ipa_pass
->write_optimization_summary
2235 && (!pass
->gate
|| pass
->gate ()))
2237 /* If a timevar is present, start it. */
2239 timevar_push (pass
->tv_id
);
2241 pass_init_dump_file (pass
);
2243 ipa_pass
->write_optimization_summary (set
, vset
);
2245 pass_fini_dump_file (pass
);
2247 /* If a timevar is present, start it. */
2249 timevar_pop (pass
->tv_id
);
2252 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2253 ipa_write_optimization_summaries_1 (pass
->sub
, set
, vset
, state
);
2259 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is
2260 NULL, write out all summaries of all nodes. */
2263 ipa_write_optimization_summaries (cgraph_node_set set
, varpool_node_set vset
)
2265 struct lto_out_decl_state
*state
= lto_new_out_decl_state ();
2266 cgraph_node_set_iterator csi
;
2267 compute_ltrans_boundary (state
, set
, vset
);
2269 lto_push_out_decl_state (state
);
2270 for (csi
= csi_start (set
); !csi_end_p (csi
); csi_next (&csi
))
2272 struct cgraph_node
*node
= csi_node (csi
);
2273 /* When streaming out references to statements as part of some IPA
2274 pass summary, the statements need to have uids assigned.
2276 For functions newly born at WPA stage we need to initialize
2279 && gimple_has_body_p (node
->decl
))
2281 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
2282 renumber_gimple_stmt_uids ();
2287 gcc_assert (flag_wpa
);
2288 ipa_write_optimization_summaries_1 (all_regular_ipa_passes
, set
, vset
, state
);
2289 ipa_write_optimization_summaries_1 (all_lto_gen_passes
, set
, vset
, state
);
2291 gcc_assert (lto_get_out_decl_state () == state
);
2292 lto_pop_out_decl_state ();
2293 lto_delete_out_decl_state (state
);
2296 /* Same as execute_pass_list but assume that subpasses of IPA passes
2297 are local passes. */
2300 ipa_read_summaries_1 (struct opt_pass
*pass
)
2304 struct ipa_opt_pass_d
*ipa_pass
= (struct ipa_opt_pass_d
*) pass
;
2306 gcc_assert (!current_function_decl
);
2308 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2310 if (pass
->gate
== NULL
|| pass
->gate ())
2312 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_summary
)
2314 /* If a timevar is present, start it. */
2316 timevar_push (pass
->tv_id
);
2318 pass_init_dump_file (pass
);
2320 ipa_pass
->read_summary ();
2322 pass_fini_dump_file (pass
);
2326 timevar_pop (pass
->tv_id
);
2329 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2330 ipa_read_summaries_1 (pass
->sub
);
2337 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */
2340 ipa_read_summaries (void)
2342 ipa_read_summaries_1 (all_regular_ipa_passes
);
2343 ipa_read_summaries_1 (all_lto_gen_passes
);
2346 /* Same as execute_pass_list but assume that subpasses of IPA passes
2347 are local passes. */
2350 ipa_read_optimization_summaries_1 (struct opt_pass
*pass
)
2354 struct ipa_opt_pass_d
*ipa_pass
= (struct ipa_opt_pass_d
*) pass
;
2356 gcc_assert (!current_function_decl
);
2358 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2360 if (pass
->gate
== NULL
|| pass
->gate ())
2362 if (pass
->type
== IPA_PASS
&& ipa_pass
->read_optimization_summary
)
2364 /* If a timevar is present, start it. */
2366 timevar_push (pass
->tv_id
);
2368 pass_init_dump_file (pass
);
2370 ipa_pass
->read_optimization_summary ();
2372 pass_fini_dump_file (pass
);
2376 timevar_pop (pass
->tv_id
);
2379 if (pass
->sub
&& pass
->sub
->type
!= GIMPLE_PASS
)
2380 ipa_read_optimization_summaries_1 (pass
->sub
);
2386 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */
2389 ipa_read_optimization_summaries (void)
2391 ipa_read_optimization_summaries_1 (all_regular_ipa_passes
);
2392 ipa_read_optimization_summaries_1 (all_lto_gen_passes
);
2395 /* Same as execute_pass_list but assume that subpasses of IPA passes
2396 are local passes. */
2398 execute_ipa_pass_list (struct opt_pass
*pass
)
2402 gcc_assert (!current_function_decl
);
2404 gcc_assert (pass
->type
== SIMPLE_IPA_PASS
|| pass
->type
== IPA_PASS
);
2405 if (execute_one_pass (pass
) && pass
->sub
)
2407 if (pass
->sub
->type
== GIMPLE_PASS
)
2409 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START
, NULL
);
2410 do_per_function_toporder ((void (*)(void *))execute_pass_list
,
2412 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END
, NULL
);
2414 else if (pass
->sub
->type
== SIMPLE_IPA_PASS
2415 || pass
->sub
->type
== IPA_PASS
)
2416 execute_ipa_pass_list (pass
->sub
);
2420 gcc_assert (!current_function_decl
);
2421 cgraph_process_new_functions ();
2427 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
2430 execute_ipa_stmt_fixups (struct opt_pass
*pass
,
2431 struct cgraph_node
*node
, gimple
*stmts
)
2435 /* Execute all of the IPA_PASSes in the list. */
2436 if (pass
->type
== IPA_PASS
2437 && (!pass
->gate
|| pass
->gate ()))
2439 struct ipa_opt_pass_d
*ipa_pass
= (struct ipa_opt_pass_d
*) pass
;
2441 if (ipa_pass
->stmt_fixup
)
2443 pass_init_dump_file (pass
);
2444 /* If a timevar is present, start it. */
2446 timevar_push (pass
->tv_id
);
2448 ipa_pass
->stmt_fixup (node
, stmts
);
2452 timevar_pop (pass
->tv_id
);
2453 pass_fini_dump_file (pass
);
2456 execute_ipa_stmt_fixups (pass
->sub
, node
, stmts
);
2462 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */
2465 execute_all_ipa_stmt_fixups (struct cgraph_node
*node
, gimple
*stmts
)
2467 execute_ipa_stmt_fixups (all_regular_ipa_passes
, node
, stmts
);
2471 extern void debug_properties (unsigned int);
2472 extern void dump_properties (FILE *, unsigned int);
2475 dump_properties (FILE *dump
, unsigned int props
)
2477 fprintf (dump
, "Properties:\n");
2478 if (props
& PROP_gimple_any
)
2479 fprintf (dump
, "PROP_gimple_any\n");
2480 if (props
& PROP_gimple_lcf
)
2481 fprintf (dump
, "PROP_gimple_lcf\n");
2482 if (props
& PROP_gimple_leh
)
2483 fprintf (dump
, "PROP_gimple_leh\n");
2484 if (props
& PROP_cfg
)
2485 fprintf (dump
, "PROP_cfg\n");
2486 if (props
& PROP_referenced_vars
)
2487 fprintf (dump
, "PROP_referenced_vars\n");
2488 if (props
& PROP_ssa
)
2489 fprintf (dump
, "PROP_ssa\n");
2490 if (props
& PROP_no_crit_edges
)
2491 fprintf (dump
, "PROP_no_crit_edges\n");
2492 if (props
& PROP_rtl
)
2493 fprintf (dump
, "PROP_rtl\n");
2494 if (props
& PROP_gimple_lomp
)
2495 fprintf (dump
, "PROP_gimple_lomp\n");
2496 if (props
& PROP_gimple_lcx
)
2497 fprintf (dump
, "PROP_gimple_lcx\n");
2498 if (props
& PROP_cfglayout
)
2499 fprintf (dump
, "PROP_cfglayout\n");
2503 debug_properties (unsigned int props
)
2505 dump_properties (stderr
, props
);
2508 /* Called by local passes to see if function is called by already processed nodes.
2509 Because we process nodes in topological order, this means that function is
2510 in recursive cycle or we introduced new direct calls. */
2512 function_called_by_processed_nodes_p (void)
2514 struct cgraph_edge
*e
;
2515 for (e
= cgraph_node (current_function_decl
)->callers
; e
; e
= e
->next_caller
)
2517 if (e
->caller
->decl
== current_function_decl
)
2519 if (!e
->caller
->analyzed
)
2521 if (TREE_ASM_WRITTEN (e
->caller
->decl
))
2523 if (!e
->caller
->process
&& !e
->caller
->global
.inlined_to
)
2528 fprintf (dump_file
, "Already processed call to:\n");
2529 dump_cgraph_node (dump_file
, e
->caller
);
2534 #include "gt-passes.h"