1 /* Dump infrastructure for optimizations and intermediate representation.
2 Copyright (C) 2012-2015 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/>. */
22 #include "coretypes.h"
23 #include "diagnostic-core.h"
30 #include "gimple-pretty-print.h"
33 /* If non-NULL, return one past-the-end of the matching SUBPART of
35 #define skip_leading_substring(whole, part) \
36 (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
38 static int pflags
; /* current dump_flags */
39 static int alt_flags
; /* current opt_info flags */
41 static void dump_loc (int, FILE *, source_location
);
42 static FILE *dump_open_alternate_stream (struct dump_file_info
*);
44 /* These are currently used for communicating between passes.
45 However, instead of accessing them directly, the passes can use
46 dump_printf () for dumps. */
47 FILE *dump_file
= NULL
;
48 FILE *alt_dump_file
= NULL
;
49 const char *dump_file_name
;
52 /* Table of tree dump switches. This must be consistent with the
53 TREE_DUMP_INDEX enumeration in dumpfile.h. */
54 static struct dump_file_info dump_files
[TDI_end
] =
56 {NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, false},
57 {".cgraph", "ipa-cgraph", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
58 0, 0, 0, 0, 0, false},
59 {".type-inheritance", "ipa-type-inheritance", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
60 0, 0, 0, 0, 0, false},
61 {".tu", "translation-unit", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
62 0, 0, 0, 0, 1, false},
63 {".class", "class-hierarchy", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
64 0, 0, 0, 0, 2, false},
65 {".original", "tree-original", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
66 0, 0, 0, 0, 3, false},
67 {".gimple", "tree-gimple", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
68 0, 0, 0, 0, 4, false},
69 {".nested", "tree-nested", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
70 0, 0, 0, 0, 5, false},
71 #define FIRST_AUTO_NUMBERED_DUMP 6
73 {NULL
, "tree-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
74 0, 0, 0, 0, 0, false},
75 {NULL
, "rtl-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_RTL
,
76 0, 0, 0, 0, 0, false},
77 {NULL
, "ipa-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
78 0, 0, 0, 0, 0, false},
81 /* Define a name->number mapping for a dump flag value. */
82 struct dump_option_value_info
84 const char *const name
; /* the name of the value */
85 const int value
; /* the value of the name */
88 /* Table of dump options. This must be consistent with the TDF_* flags
89 in dumpfile.h and opt_info_options below. */
90 static const struct dump_option_value_info dump_options
[] =
92 {"address", TDF_ADDRESS
},
93 {"asmname", TDF_ASMNAME
},
97 {"details", (TDF_DETAILS
| MSG_OPTIMIZED_LOCATIONS
98 | MSG_MISSED_OPTIMIZATION
100 {"cselib", TDF_CSELIB
},
101 {"stats", TDF_STATS
},
102 {"blocks", TDF_BLOCKS
},
104 {"lineno", TDF_LINENO
},
106 {"stmtaddr", TDF_STMTADDR
},
107 {"memsyms", TDF_MEMSYMS
},
108 {"verbose", TDF_VERBOSE
},
110 {"alias", TDF_ALIAS
},
111 {"nouid", TDF_NOUID
},
112 {"enumerate_locals", TDF_ENUMERATE_LOCALS
},
114 {"optimized", MSG_OPTIMIZED_LOCATIONS
},
115 {"missed", MSG_MISSED_OPTIMIZATION
},
118 {"all", ~(TDF_RAW
| TDF_SLIM
| TDF_LINENO
| TDF_TREE
| TDF_RTL
| TDF_IPA
119 | TDF_STMTADDR
| TDF_GRAPH
| TDF_DIAGNOSTIC
| TDF_VERBOSE
120 | TDF_RHS_ONLY
| TDF_NOUID
| TDF_ENUMERATE_LOCALS
| TDF_SCEV
)},
124 /* A subset of the dump_options table which is used for -fopt-info
125 types. This must be consistent with the MSG_* flags in dumpfile.h.
127 static const struct dump_option_value_info optinfo_verbosity_options
[] =
129 {"optimized", MSG_OPTIMIZED_LOCATIONS
},
130 {"missed", MSG_MISSED_OPTIMIZATION
},
136 /* Flags used for -fopt-info groups. */
137 static const struct dump_option_value_info optgroup_options
[] =
139 {"ipa", OPTGROUP_IPA
},
140 {"loop", OPTGROUP_LOOP
},
141 {"inline", OPTGROUP_INLINE
},
142 {"vec", OPTGROUP_VEC
},
143 {"optall", OPTGROUP_ALL
},
147 gcc::dump_manager::dump_manager ():
148 m_next_dump (FIRST_AUTO_NUMBERED_DUMP
),
149 m_extra_dump_files (NULL
),
150 m_extra_dump_files_in_use (0),
151 m_extra_dump_files_alloced (0)
155 gcc::dump_manager::~dump_manager ()
157 for (size_t i
= 0; i
< m_extra_dump_files_in_use
; i
++)
159 dump_file_info
*dfi
= &m_extra_dump_files
[i
];
160 /* suffix, swtch, glob are statically allocated for the entries
161 in dump_files, and for statistics, but are dynamically allocated
162 for those for passes. */
163 if (dfi
->owns_strings
)
165 XDELETEVEC (const_cast <char *> (dfi
->suffix
));
166 XDELETEVEC (const_cast <char *> (dfi
->swtch
));
167 XDELETEVEC (const_cast <char *> (dfi
->glob
));
169 /* These, if non-NULL, are always dynamically allocated. */
170 XDELETEVEC (const_cast <char *> (dfi
->pfilename
));
171 XDELETEVEC (const_cast <char *> (dfi
->alt_filename
));
173 XDELETEVEC (m_extra_dump_files
);
178 dump_register (const char *suffix
, const char *swtch
, const char *glob
,
179 int flags
, int optgroup_flags
,
182 int num
= m_next_dump
++;
184 size_t count
= m_extra_dump_files_in_use
++;
186 if (count
>= m_extra_dump_files_alloced
)
188 if (m_extra_dump_files_alloced
== 0)
189 m_extra_dump_files_alloced
= 32;
191 m_extra_dump_files_alloced
*= 2;
192 m_extra_dump_files
= XRESIZEVEC (struct dump_file_info
,
194 m_extra_dump_files_alloced
);
197 memset (&m_extra_dump_files
[count
], 0, sizeof (struct dump_file_info
));
198 m_extra_dump_files
[count
].suffix
= suffix
;
199 m_extra_dump_files
[count
].swtch
= swtch
;
200 m_extra_dump_files
[count
].glob
= glob
;
201 m_extra_dump_files
[count
].pflags
= flags
;
202 m_extra_dump_files
[count
].optgroup_flags
= optgroup_flags
;
203 m_extra_dump_files
[count
].num
= num
;
204 m_extra_dump_files
[count
].owns_strings
= take_ownership
;
206 return count
+ TDI_end
;
210 /* Return the dump_file_info for the given phase. */
212 struct dump_file_info
*
214 get_dump_file_info (int phase
) const
217 return &dump_files
[phase
];
218 else if ((size_t) (phase
- TDI_end
) >= m_extra_dump_files_in_use
)
221 return m_extra_dump_files
+ (phase
- TDI_end
);
224 /* Locate the dump_file_info with swtch equal to SWTCH,
225 or return NULL if no such dump_file_info exists. */
227 struct dump_file_info
*
229 get_dump_file_info_by_switch (const char *swtch
) const
231 for (unsigned i
= 0; i
< m_extra_dump_files_in_use
; i
++)
232 if (0 == strcmp (m_extra_dump_files
[i
].swtch
, swtch
))
233 return &m_extra_dump_files
[i
];
240 /* Return the name of the dump file for the given phase.
241 The caller is responsible for calling free on the returned
243 If the dump is not enabled, returns NULL. */
247 get_dump_file_name (int phase
) const
249 struct dump_file_info
*dfi
;
251 if (phase
== TDI_none
)
254 dfi
= get_dump_file_info (phase
);
256 return get_dump_file_name (dfi
);
259 /* Return the name of the dump file for the given dump_file_info.
260 The caller is responsible for calling free on the returned
262 If the dump is not enabled, returns NULL. */
266 get_dump_file_name (struct dump_file_info
*dfi
) const
272 if (dfi
->pstate
== 0)
275 /* If available, use the command line dump filename. */
277 return xstrdup (dfi
->pfilename
);
284 if (dfi
->pflags
& TDF_TREE
)
286 else if (dfi
->pflags
& TDF_IPA
)
291 if (snprintf (dump_id
, sizeof (dump_id
), ".%03d%c", dfi
->num
, suffix
) < 0)
295 return concat (dump_base_name
, dump_id
, dfi
->suffix
, NULL
);
298 /* For a given DFI, open an alternate dump filename (which could also
299 be a standard stream such as stdout/stderr). If the alternate dump
300 file cannot be opened, return NULL. */
303 dump_open_alternate_stream (struct dump_file_info
*dfi
)
306 if (!dfi
->alt_filename
)
310 return dfi
->alt_stream
;
312 stream
= strcmp ("stderr", dfi
->alt_filename
) == 0
314 : strcmp ("stdout", dfi
->alt_filename
) == 0
316 : fopen (dfi
->alt_filename
, dfi
->alt_state
< 0 ? "w" : "a");
319 error ("could not open dump file %qs: %m", dfi
->alt_filename
);
326 /* Print source location on DFILE if enabled. */
329 dump_loc (int dump_kind
, FILE *dfile
, source_location loc
)
333 if (LOCATION_LOCUS (loc
) > BUILTINS_LOCATION
)
334 fprintf (dfile
, "%s:%d:%d: note: ", LOCATION_FILE (loc
),
335 LOCATION_LINE (loc
), LOCATION_COLUMN (loc
));
336 else if (current_function_decl
)
337 fprintf (dfile
, "%s:%d:%d: note: ",
338 DECL_SOURCE_FILE (current_function_decl
),
339 DECL_SOURCE_LINE (current_function_decl
),
340 DECL_SOURCE_COLUMN (current_function_decl
));
344 /* Dump gimple statement GS with SPC indentation spaces and
345 EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. */
348 dump_gimple_stmt (int dump_kind
, int extra_dump_flags
, gimple gs
, int spc
)
350 if (dump_file
&& (dump_kind
& pflags
))
351 print_gimple_stmt (dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
353 if (alt_dump_file
&& (dump_kind
& alt_flags
))
354 print_gimple_stmt (alt_dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
357 /* Similar to dump_gimple_stmt, except additionally print source location. */
360 dump_gimple_stmt_loc (int dump_kind
, source_location loc
, int extra_dump_flags
,
363 if (dump_file
&& (dump_kind
& pflags
))
365 dump_loc (dump_kind
, dump_file
, loc
);
366 print_gimple_stmt (dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
369 if (alt_dump_file
&& (dump_kind
& alt_flags
))
371 dump_loc (dump_kind
, alt_dump_file
, loc
);
372 print_gimple_stmt (alt_dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
376 /* Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
377 DUMP_KIND is enabled. */
380 dump_generic_expr (int dump_kind
, int extra_dump_flags
, tree t
)
382 if (dump_file
&& (dump_kind
& pflags
))
383 print_generic_expr (dump_file
, t
, dump_flags
| extra_dump_flags
);
385 if (alt_dump_file
&& (dump_kind
& alt_flags
))
386 print_generic_expr (alt_dump_file
, t
, dump_flags
| extra_dump_flags
);
390 /* Similar to dump_generic_expr, except additionally print the source
394 dump_generic_expr_loc (int dump_kind
, source_location loc
,
395 int extra_dump_flags
, tree t
)
397 if (dump_file
&& (dump_kind
& pflags
))
399 dump_loc (dump_kind
, dump_file
, loc
);
400 print_generic_expr (dump_file
, t
, dump_flags
| extra_dump_flags
);
403 if (alt_dump_file
&& (dump_kind
& alt_flags
))
405 dump_loc (dump_kind
, alt_dump_file
, loc
);
406 print_generic_expr (alt_dump_file
, t
, dump_flags
| extra_dump_flags
);
410 /* Output a formatted message using FORMAT on appropriate dump streams. */
413 dump_printf (int dump_kind
, const char *format
, ...)
415 if (dump_file
&& (dump_kind
& pflags
))
418 va_start (ap
, format
);
419 vfprintf (dump_file
, format
, ap
);
423 if (alt_dump_file
&& (dump_kind
& alt_flags
))
426 va_start (ap
, format
);
427 vfprintf (alt_dump_file
, format
, ap
);
432 /* Similar to dump_printf, except source location is also printed. */
435 dump_printf_loc (int dump_kind
, source_location loc
, const char *format
, ...)
437 if (dump_file
&& (dump_kind
& pflags
))
440 dump_loc (dump_kind
, dump_file
, loc
);
441 va_start (ap
, format
);
442 vfprintf (dump_file
, format
, ap
);
446 if (alt_dump_file
&& (dump_kind
& alt_flags
))
449 dump_loc (dump_kind
, alt_dump_file
, loc
);
450 va_start (ap
, format
);
451 vfprintf (alt_dump_file
, format
, ap
);
456 /* Start a dump for PHASE. Store user-supplied dump flags in
457 *FLAG_PTR. Return the number of streams opened. Set globals
458 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
459 set dump_flags appropriately for both pass dump stream and
460 -fopt-info stream. */
464 dump_start (int phase
, int *flag_ptr
)
468 struct dump_file_info
*dfi
;
470 if (phase
== TDI_none
|| !dump_phase_enabled_p (phase
))
473 dfi
= get_dump_file_info (phase
);
474 name
= get_dump_file_name (phase
);
477 stream
= strcmp ("stderr", name
) == 0
479 : strcmp ("stdout", name
) == 0
481 : fopen (name
, dfi
->pstate
< 0 ? "w" : "a");
483 error ("could not open dump file %qs: %m", name
);
490 dfi
->pstream
= stream
;
491 dump_file
= dfi
->pstream
;
492 /* Initialize current dump flags. */
493 pflags
= dfi
->pflags
;
496 stream
= dump_open_alternate_stream (dfi
);
499 dfi
->alt_stream
= stream
;
501 alt_dump_file
= dfi
->alt_stream
;
502 /* Initialize current -fopt-info flags. */
503 alt_flags
= dfi
->alt_flags
;
507 *flag_ptr
= dfi
->pflags
;
512 /* Finish a tree dump for PHASE and close associated dump streams. Also
513 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
517 dump_finish (int phase
)
519 struct dump_file_info
*dfi
;
523 dfi
= get_dump_file_info (phase
);
524 if (dfi
->pstream
&& (!dfi
->pfilename
525 || (strcmp ("stderr", dfi
->pfilename
) != 0
526 && strcmp ("stdout", dfi
->pfilename
) != 0)))
527 fclose (dfi
->pstream
);
529 if (dfi
->alt_stream
&& strcmp ("stderr", dfi
->alt_filename
) != 0
530 && strcmp ("stdout", dfi
->alt_filename
) != 0)
531 fclose (dfi
->alt_stream
);
533 dfi
->alt_stream
= NULL
;
536 alt_dump_file
= NULL
;
537 dump_flags
= TDI_none
;
542 /* Begin a tree dump for PHASE. Stores any user supplied flag in
543 *FLAG_PTR and returns a stream to write to. If the dump is not
544 enabled, returns NULL.
545 Multiple calls will reopen and append to the dump file. */
548 dump_begin (int phase
, int *flag_ptr
)
550 return g
->get_dumps ()->dump_begin (phase
, flag_ptr
);
555 dump_begin (int phase
, int *flag_ptr
)
558 struct dump_file_info
*dfi
;
561 if (phase
== TDI_none
|| !dump_phase_enabled_p (phase
))
564 name
= get_dump_file_name (phase
);
567 dfi
= get_dump_file_info (phase
);
569 stream
= strcmp ("stderr", name
) == 0
571 : strcmp ("stdout", name
) == 0
573 : fopen (name
, dfi
->pstate
< 0 ? "w" : "a");
576 error ("could not open dump file %qs: %m", name
);
582 *flag_ptr
= dfi
->pflags
;
584 /* Initialize current flags */
585 pflags
= dfi
->pflags
;
589 /* Returns nonzero if dump PHASE is enabled for at least one stream.
590 If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
595 dump_phase_enabled_p (int phase
) const
597 if (phase
== TDI_tree_all
)
600 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
601 if (dump_files
[i
].pstate
|| dump_files
[i
].alt_state
)
603 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
604 if (m_extra_dump_files
[i
].pstate
|| m_extra_dump_files
[i
].alt_state
)
610 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
611 return dfi
->pstate
|| dfi
->alt_state
;
615 /* Returns nonzero if tree dump PHASE has been initialized. */
619 dump_initialized_p (int phase
) const
621 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
622 return dfi
->pstate
> 0 || dfi
->alt_state
> 0;
625 /* Returns the switch name of PHASE. */
628 dump_flag_name (int phase
)
630 return g
->get_dumps ()->dump_flag_name (phase
);
635 dump_flag_name (int phase
) const
637 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
641 /* Finish a tree dump for PHASE. STREAM is the stream created by
645 dump_end (int phase ATTRIBUTE_UNUSED
, FILE *stream
)
647 if (stream
!= stderr
&& stream
!= stdout
)
651 /* Enable all tree dumps with FLAGS on FILENAME. Return number of
652 enabled tree dumps. */
656 dump_enable_all (int flags
, const char *filename
)
658 int ir_dump_type
= (flags
& (TDF_TREE
| TDF_RTL
| TDF_IPA
));
662 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
664 if ((dump_files
[i
].pflags
& ir_dump_type
))
666 const char *old_filename
= dump_files
[i
].pfilename
;
667 dump_files
[i
].pstate
= -1;
668 dump_files
[i
].pflags
|= flags
;
670 /* Override the existing filename. */
673 dump_files
[i
].pfilename
= xstrdup (filename
);
674 /* Since it is a command-line provided file, which is
675 common to all the phases, use it in append mode. */
676 dump_files
[i
].pstate
= 1;
678 if (old_filename
&& filename
!= old_filename
)
679 free (CONST_CAST (char *, old_filename
));
683 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
685 if ((m_extra_dump_files
[i
].pflags
& ir_dump_type
))
687 const char *old_filename
= m_extra_dump_files
[i
].pfilename
;
688 m_extra_dump_files
[i
].pstate
= -1;
689 m_extra_dump_files
[i
].pflags
|= flags
;
691 /* Override the existing filename. */
694 m_extra_dump_files
[i
].pfilename
= xstrdup (filename
);
695 /* Since it is a command-line provided file, which is
696 common to all the phases, use it in append mode. */
697 m_extra_dump_files
[i
].pstate
= 1;
699 if (old_filename
&& filename
!= old_filename
)
700 free (CONST_CAST (char *, old_filename
));
707 /* Enable -fopt-info dumps on all dump files matching OPTGROUP_FLAGS.
708 Enable dumps with FLAGS on FILENAME. Return the number of enabled
713 opt_info_enable_passes (int optgroup_flags
, int flags
, const char *filename
)
718 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
720 if ((dump_files
[i
].optgroup_flags
& optgroup_flags
))
722 const char *old_filename
= dump_files
[i
].alt_filename
;
723 /* Since this file is shared among different passes, it
724 should be opened in append mode. */
725 dump_files
[i
].alt_state
= 1;
726 dump_files
[i
].alt_flags
|= flags
;
728 /* Override the existing filename. */
730 dump_files
[i
].alt_filename
= xstrdup (filename
);
731 if (old_filename
&& filename
!= old_filename
)
732 free (CONST_CAST (char *, old_filename
));
736 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
738 if ((m_extra_dump_files
[i
].optgroup_flags
& optgroup_flags
))
740 const char *old_filename
= m_extra_dump_files
[i
].alt_filename
;
741 /* Since this file is shared among different passes, it
742 should be opened in append mode. */
743 m_extra_dump_files
[i
].alt_state
= 1;
744 m_extra_dump_files
[i
].alt_flags
|= flags
;
746 /* Override the existing filename. */
748 m_extra_dump_files
[i
].alt_filename
= xstrdup (filename
);
749 if (old_filename
&& filename
!= old_filename
)
750 free (CONST_CAST (char *, old_filename
));
757 /* Parse ARG as a dump switch. Return nonzero if it is, and store the
758 relevant details in the dump_files array. */
762 dump_switch_p_1 (const char *arg
, struct dump_file_info
*dfi
, bool doglob
)
764 const char *option_value
;
768 if (doglob
&& !dfi
->glob
)
771 option_value
= skip_leading_substring (arg
, doglob
? dfi
->glob
: dfi
->swtch
);
775 if (*option_value
&& *option_value
!= '-' && *option_value
!= '=')
783 const struct dump_option_value_info
*option_ptr
;
790 end_ptr
= strchr (ptr
, '-');
791 eq_ptr
= strchr (ptr
, '=');
793 if (eq_ptr
&& !end_ptr
)
797 end_ptr
= ptr
+ strlen (ptr
);
798 length
= end_ptr
- ptr
;
800 for (option_ptr
= dump_options
; option_ptr
->name
; option_ptr
++)
801 if (strlen (option_ptr
->name
) == length
802 && !memcmp (option_ptr
->name
, ptr
, length
))
804 flags
|= option_ptr
->value
;
810 /* Interpret rest of the argument as a dump filename. This
811 filename overrides other command line filenames. */
813 free (CONST_CAST (char *, dfi
->pfilename
));
814 dfi
->pfilename
= xstrdup (ptr
+ 1);
818 warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
819 length
, ptr
, dfi
->swtch
);
825 dfi
->pflags
|= flags
;
827 /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
829 if (dfi
->suffix
== NULL
)
830 dump_enable_all (dfi
->pflags
, dfi
->pfilename
);
837 dump_switch_p (const char *arg
)
842 for (i
= TDI_none
+ 1; i
!= TDI_end
; i
++)
843 any
|= dump_switch_p_1 (arg
, &dump_files
[i
], false);
845 /* Don't glob if we got a hit already */
847 for (i
= TDI_none
+ 1; i
!= TDI_end
; i
++)
848 any
|= dump_switch_p_1 (arg
, &dump_files
[i
], true);
850 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
851 any
|= dump_switch_p_1 (arg
, &m_extra_dump_files
[i
], false);
854 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
855 any
|= dump_switch_p_1 (arg
, &m_extra_dump_files
[i
], true);
861 /* Parse ARG as a -fopt-info switch and store flags, optgroup_flags
862 and filename. Return non-zero if it is a recognized switch. */
865 opt_info_switch_p_1 (const char *arg
, int *flags
, int *optgroup_flags
,
868 const char *option_value
;
879 return 1; /* Handle '-fopt-info' without any additional options. */
883 const struct dump_option_value_info
*option_ptr
;
890 end_ptr
= strchr (ptr
, '-');
891 eq_ptr
= strchr (ptr
, '=');
893 if (eq_ptr
&& !end_ptr
)
897 end_ptr
= ptr
+ strlen (ptr
);
898 length
= end_ptr
- ptr
;
900 for (option_ptr
= optinfo_verbosity_options
; option_ptr
->name
;
902 if (strlen (option_ptr
->name
) == length
903 && !memcmp (option_ptr
->name
, ptr
, length
))
905 *flags
|= option_ptr
->value
;
909 for (option_ptr
= optgroup_options
; option_ptr
->name
; option_ptr
++)
910 if (strlen (option_ptr
->name
) == length
911 && !memcmp (option_ptr
->name
, ptr
, length
))
913 *optgroup_flags
|= option_ptr
->value
;
919 /* Interpret rest of the argument as a dump filename. This
920 filename overrides other command line filenames. */
921 *filename
= xstrdup (ptr
+ 1);
926 warning (0, "unknown option %q.*s in %<-fopt-info-%s%>",
937 /* Return non-zero if ARG is a recognized switch for
938 -fopt-info. Return zero otherwise. */
941 opt_info_switch_p (const char *arg
)
946 static char *file_seen
= NULL
;
947 gcc::dump_manager
*dumps
= g
->get_dumps ();
949 if (!opt_info_switch_p_1 (arg
, &flags
, &optgroup_flags
, &filename
))
953 filename
= xstrdup ("stderr");
955 /* Bail out if a different filename has been specified. */
956 if (file_seen
&& strcmp (file_seen
, filename
))
958 warning (0, "ignoring possibly conflicting option %<-fopt-info-%s%>",
963 file_seen
= xstrdup (filename
);
965 flags
= MSG_OPTIMIZED_LOCATIONS
;
967 optgroup_flags
= OPTGROUP_ALL
;
969 return dumps
->opt_info_enable_passes (optgroup_flags
, flags
, filename
);
972 /* Print basic block on the dump streams. */
975 dump_basic_block (int dump_kind
, basic_block bb
, int indent
)
977 if (dump_file
&& (dump_kind
& pflags
))
978 dump_bb (dump_file
, bb
, indent
, TDF_DETAILS
);
979 if (alt_dump_file
&& (dump_kind
& alt_flags
))
980 dump_bb (alt_dump_file
, bb
, indent
, TDF_DETAILS
);
983 /* Print information from the combine pass on dump_file. */
986 print_combine_total_stats (void)
989 dump_combine_total_stats (dump_file
);
992 /* Enable RTL dump for all the RTL passes. */
995 enable_rtl_dump_file (void)
997 gcc::dump_manager
*dumps
= g
->get_dumps ();
999 dumps
->dump_enable_all (TDF_RTL
| TDF_DETAILS
| TDF_BLOCKS
, NULL
);
1000 return num_enabled
> 0;