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"
28 #include "double-int.h"
37 #include "gimple-pretty-print.h"
40 /* If non-NULL, return one past-the-end of the matching SUBPART of
42 #define skip_leading_substring(whole, part) \
43 (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
45 static int pflags
; /* current dump_flags */
46 static int alt_flags
; /* current opt_info flags */
48 static void dump_loc (int, FILE *, source_location
);
49 static FILE *dump_open_alternate_stream (struct dump_file_info
*);
51 /* These are currently used for communicating between passes.
52 However, instead of accessing them directly, the passes can use
53 dump_printf () for dumps. */
54 FILE *dump_file
= NULL
;
55 FILE *alt_dump_file
= NULL
;
56 const char *dump_file_name
;
59 /* Table of tree dump switches. This must be consistent with the
60 TREE_DUMP_INDEX enumeration in dumpfile.h. */
61 static struct dump_file_info dump_files
[TDI_end
] =
63 {NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, false},
64 {".cgraph", "ipa-cgraph", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
65 0, 0, 0, 0, 0, false},
66 {".type-inheritance", "ipa-type-inheritance", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
67 0, 0, 0, 0, 0, false},
68 {".tu", "translation-unit", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
69 0, 0, 0, 0, 1, false},
70 {".class", "class-hierarchy", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
71 0, 0, 0, 0, 2, false},
72 {".original", "tree-original", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
73 0, 0, 0, 0, 3, false},
74 {".gimple", "tree-gimple", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
75 0, 0, 0, 0, 4, false},
76 {".nested", "tree-nested", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
77 0, 0, 0, 0, 5, false},
78 #define FIRST_AUTO_NUMBERED_DUMP 6
80 {NULL
, "tree-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
81 0, 0, 0, 0, 0, false},
82 {NULL
, "rtl-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_RTL
,
83 0, 0, 0, 0, 0, false},
84 {NULL
, "ipa-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
85 0, 0, 0, 0, 0, false},
88 /* Define a name->number mapping for a dump flag value. */
89 struct dump_option_value_info
91 const char *const name
; /* the name of the value */
92 const int value
; /* the value of the name */
95 /* Table of dump options. This must be consistent with the TDF_* flags
96 in dumpfile.h and opt_info_options below. */
97 static const struct dump_option_value_info dump_options
[] =
99 {"address", TDF_ADDRESS
},
100 {"asmname", TDF_ASMNAME
},
103 {"graph", TDF_GRAPH
},
104 {"details", (TDF_DETAILS
| MSG_OPTIMIZED_LOCATIONS
105 | MSG_MISSED_OPTIMIZATION
107 {"cselib", TDF_CSELIB
},
108 {"stats", TDF_STATS
},
109 {"blocks", TDF_BLOCKS
},
111 {"lineno", TDF_LINENO
},
113 {"stmtaddr", TDF_STMTADDR
},
114 {"memsyms", TDF_MEMSYMS
},
115 {"verbose", TDF_VERBOSE
},
117 {"alias", TDF_ALIAS
},
118 {"nouid", TDF_NOUID
},
119 {"enumerate_locals", TDF_ENUMERATE_LOCALS
},
121 {"optimized", MSG_OPTIMIZED_LOCATIONS
},
122 {"missed", MSG_MISSED_OPTIMIZATION
},
125 {"all", ~(TDF_RAW
| TDF_SLIM
| TDF_LINENO
| TDF_TREE
| TDF_RTL
| TDF_IPA
126 | TDF_STMTADDR
| TDF_GRAPH
| TDF_DIAGNOSTIC
| TDF_VERBOSE
127 | TDF_RHS_ONLY
| TDF_NOUID
| TDF_ENUMERATE_LOCALS
| TDF_SCEV
)},
131 /* A subset of the dump_options table which is used for -fopt-info
132 types. This must be consistent with the MSG_* flags in dumpfile.h.
134 static const struct dump_option_value_info optinfo_verbosity_options
[] =
136 {"optimized", MSG_OPTIMIZED_LOCATIONS
},
137 {"missed", MSG_MISSED_OPTIMIZATION
},
143 /* Flags used for -fopt-info groups. */
144 static const struct dump_option_value_info optgroup_options
[] =
146 {"ipa", OPTGROUP_IPA
},
147 {"loop", OPTGROUP_LOOP
},
148 {"inline", OPTGROUP_INLINE
},
149 {"vec", OPTGROUP_VEC
},
150 {"optall", OPTGROUP_ALL
},
154 gcc::dump_manager::dump_manager ():
155 m_next_dump (FIRST_AUTO_NUMBERED_DUMP
),
156 m_extra_dump_files (NULL
),
157 m_extra_dump_files_in_use (0),
158 m_extra_dump_files_alloced (0)
162 gcc::dump_manager::~dump_manager ()
164 for (size_t i
= 0; i
< m_extra_dump_files_in_use
; i
++)
166 dump_file_info
*dfi
= &m_extra_dump_files
[i
];
167 /* suffix, swtch, glob are statically allocated for the entries
168 in dump_files, and for statistics, but are dynamically allocated
169 for those for passes. */
170 if (dfi
->owns_strings
)
172 XDELETEVEC (const_cast <char *> (dfi
->suffix
));
173 XDELETEVEC (const_cast <char *> (dfi
->swtch
));
174 XDELETEVEC (const_cast <char *> (dfi
->glob
));
176 /* These, if non-NULL, are always dynamically allocated. */
177 XDELETEVEC (const_cast <char *> (dfi
->pfilename
));
178 XDELETEVEC (const_cast <char *> (dfi
->alt_filename
));
180 XDELETEVEC (m_extra_dump_files
);
185 dump_register (const char *suffix
, const char *swtch
, const char *glob
,
186 int flags
, int optgroup_flags
,
189 int num
= m_next_dump
++;
191 size_t count
= m_extra_dump_files_in_use
++;
193 if (count
>= m_extra_dump_files_alloced
)
195 if (m_extra_dump_files_alloced
== 0)
196 m_extra_dump_files_alloced
= 32;
198 m_extra_dump_files_alloced
*= 2;
199 m_extra_dump_files
= XRESIZEVEC (struct dump_file_info
,
201 m_extra_dump_files_alloced
);
204 memset (&m_extra_dump_files
[count
], 0, sizeof (struct dump_file_info
));
205 m_extra_dump_files
[count
].suffix
= suffix
;
206 m_extra_dump_files
[count
].swtch
= swtch
;
207 m_extra_dump_files
[count
].glob
= glob
;
208 m_extra_dump_files
[count
].pflags
= flags
;
209 m_extra_dump_files
[count
].optgroup_flags
= optgroup_flags
;
210 m_extra_dump_files
[count
].num
= num
;
211 m_extra_dump_files
[count
].owns_strings
= take_ownership
;
213 return count
+ TDI_end
;
217 /* Return the dump_file_info for the given phase. */
219 struct dump_file_info
*
221 get_dump_file_info (int phase
) const
224 return &dump_files
[phase
];
225 else if ((size_t) (phase
- TDI_end
) >= m_extra_dump_files_in_use
)
228 return m_extra_dump_files
+ (phase
- TDI_end
);
231 /* Locate the dump_file_info with swtch equal to SWTCH,
232 or return NULL if no such dump_file_info exists. */
234 struct dump_file_info
*
236 get_dump_file_info_by_switch (const char *swtch
) const
238 for (unsigned i
= 0; i
< m_extra_dump_files_in_use
; i
++)
239 if (0 == strcmp (m_extra_dump_files
[i
].swtch
, swtch
))
240 return &m_extra_dump_files
[i
];
247 /* Return the name of the dump file for the given phase.
248 The caller is responsible for calling free on the returned
250 If the dump is not enabled, returns NULL. */
254 get_dump_file_name (int phase
) const
256 struct dump_file_info
*dfi
;
258 if (phase
== TDI_none
)
261 dfi
= get_dump_file_info (phase
);
263 return get_dump_file_name (dfi
);
266 /* Return the name of the dump file for the given dump_file_info.
267 The caller is responsible for calling free on the returned
269 If the dump is not enabled, returns NULL. */
273 get_dump_file_name (struct dump_file_info
*dfi
) const
279 if (dfi
->pstate
== 0)
282 /* If available, use the command line dump filename. */
284 return xstrdup (dfi
->pfilename
);
291 if (dfi
->pflags
& TDF_TREE
)
293 else if (dfi
->pflags
& TDF_IPA
)
298 if (snprintf (dump_id
, sizeof (dump_id
), ".%03d%c", dfi
->num
, suffix
) < 0)
302 return concat (dump_base_name
, dump_id
, dfi
->suffix
, NULL
);
305 /* For a given DFI, open an alternate dump filename (which could also
306 be a standard stream such as stdout/stderr). If the alternate dump
307 file cannot be opened, return NULL. */
310 dump_open_alternate_stream (struct dump_file_info
*dfi
)
313 if (!dfi
->alt_filename
)
317 return dfi
->alt_stream
;
319 stream
= strcmp ("stderr", dfi
->alt_filename
) == 0
321 : strcmp ("stdout", dfi
->alt_filename
) == 0
323 : fopen (dfi
->alt_filename
, dfi
->alt_state
< 0 ? "w" : "a");
326 error ("could not open dump file %qs: %m", dfi
->alt_filename
);
333 /* Print source location on DFILE if enabled. */
336 dump_loc (int dump_kind
, FILE *dfile
, source_location loc
)
340 if (LOCATION_LOCUS (loc
) > BUILTINS_LOCATION
)
341 fprintf (dfile
, "%s:%d:%d: note: ", LOCATION_FILE (loc
),
342 LOCATION_LINE (loc
), LOCATION_COLUMN (loc
));
343 else if (current_function_decl
)
344 fprintf (dfile
, "%s:%d:%d: note: ",
345 DECL_SOURCE_FILE (current_function_decl
),
346 DECL_SOURCE_LINE (current_function_decl
),
347 DECL_SOURCE_COLUMN (current_function_decl
));
351 /* Dump gimple statement GS with SPC indentation spaces and
352 EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. */
355 dump_gimple_stmt (int dump_kind
, int extra_dump_flags
, gimple gs
, int spc
)
357 if (dump_file
&& (dump_kind
& pflags
))
358 print_gimple_stmt (dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
360 if (alt_dump_file
&& (dump_kind
& alt_flags
))
361 print_gimple_stmt (alt_dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
364 /* Similar to dump_gimple_stmt, except additionally print source location. */
367 dump_gimple_stmt_loc (int dump_kind
, source_location loc
, int extra_dump_flags
,
370 if (dump_file
&& (dump_kind
& pflags
))
372 dump_loc (dump_kind
, dump_file
, loc
);
373 print_gimple_stmt (dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
376 if (alt_dump_file
&& (dump_kind
& alt_flags
))
378 dump_loc (dump_kind
, alt_dump_file
, loc
);
379 print_gimple_stmt (alt_dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
383 /* Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
384 DUMP_KIND is enabled. */
387 dump_generic_expr (int dump_kind
, int extra_dump_flags
, tree t
)
389 if (dump_file
&& (dump_kind
& pflags
))
390 print_generic_expr (dump_file
, t
, dump_flags
| extra_dump_flags
);
392 if (alt_dump_file
&& (dump_kind
& alt_flags
))
393 print_generic_expr (alt_dump_file
, t
, dump_flags
| extra_dump_flags
);
397 /* Similar to dump_generic_expr, except additionally print the source
401 dump_generic_expr_loc (int dump_kind
, source_location loc
,
402 int extra_dump_flags
, tree t
)
404 if (dump_file
&& (dump_kind
& pflags
))
406 dump_loc (dump_kind
, dump_file
, loc
);
407 print_generic_expr (dump_file
, t
, dump_flags
| extra_dump_flags
);
410 if (alt_dump_file
&& (dump_kind
& alt_flags
))
412 dump_loc (dump_kind
, alt_dump_file
, loc
);
413 print_generic_expr (alt_dump_file
, t
, dump_flags
| extra_dump_flags
);
417 /* Output a formatted message using FORMAT on appropriate dump streams. */
420 dump_printf (int dump_kind
, const char *format
, ...)
422 if (dump_file
&& (dump_kind
& pflags
))
425 va_start (ap
, format
);
426 vfprintf (dump_file
, format
, ap
);
430 if (alt_dump_file
&& (dump_kind
& alt_flags
))
433 va_start (ap
, format
);
434 vfprintf (alt_dump_file
, format
, ap
);
439 /* Similar to dump_printf, except source location is also printed. */
442 dump_printf_loc (int dump_kind
, source_location loc
, const char *format
, ...)
444 if (dump_file
&& (dump_kind
& pflags
))
447 dump_loc (dump_kind
, dump_file
, loc
);
448 va_start (ap
, format
);
449 vfprintf (dump_file
, format
, ap
);
453 if (alt_dump_file
&& (dump_kind
& alt_flags
))
456 dump_loc (dump_kind
, alt_dump_file
, loc
);
457 va_start (ap
, format
);
458 vfprintf (alt_dump_file
, format
, ap
);
463 /* Start a dump for PHASE. Store user-supplied dump flags in
464 *FLAG_PTR. Return the number of streams opened. Set globals
465 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
466 set dump_flags appropriately for both pass dump stream and
467 -fopt-info stream. */
471 dump_start (int phase
, int *flag_ptr
)
475 struct dump_file_info
*dfi
;
477 if (phase
== TDI_none
|| !dump_phase_enabled_p (phase
))
480 dfi
= get_dump_file_info (phase
);
481 name
= get_dump_file_name (phase
);
484 stream
= strcmp ("stderr", name
) == 0
486 : strcmp ("stdout", name
) == 0
488 : fopen (name
, dfi
->pstate
< 0 ? "w" : "a");
490 error ("could not open dump file %qs: %m", name
);
497 dfi
->pstream
= stream
;
498 dump_file
= dfi
->pstream
;
499 /* Initialize current dump flags. */
500 pflags
= dfi
->pflags
;
503 stream
= dump_open_alternate_stream (dfi
);
506 dfi
->alt_stream
= stream
;
508 alt_dump_file
= dfi
->alt_stream
;
509 /* Initialize current -fopt-info flags. */
510 alt_flags
= dfi
->alt_flags
;
514 *flag_ptr
= dfi
->pflags
;
519 /* Finish a tree dump for PHASE and close associated dump streams. Also
520 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
524 dump_finish (int phase
)
526 struct dump_file_info
*dfi
;
530 dfi
= get_dump_file_info (phase
);
531 if (dfi
->pstream
&& (!dfi
->pfilename
532 || (strcmp ("stderr", dfi
->pfilename
) != 0
533 && strcmp ("stdout", dfi
->pfilename
) != 0)))
534 fclose (dfi
->pstream
);
536 if (dfi
->alt_stream
&& strcmp ("stderr", dfi
->alt_filename
) != 0
537 && strcmp ("stdout", dfi
->alt_filename
) != 0)
538 fclose (dfi
->alt_stream
);
540 dfi
->alt_stream
= NULL
;
543 alt_dump_file
= NULL
;
544 dump_flags
= TDI_none
;
549 /* Begin a tree dump for PHASE. Stores any user supplied flag in
550 *FLAG_PTR and returns a stream to write to. If the dump is not
551 enabled, returns NULL.
552 Multiple calls will reopen and append to the dump file. */
555 dump_begin (int phase
, int *flag_ptr
)
557 return g
->get_dumps ()->dump_begin (phase
, flag_ptr
);
562 dump_begin (int phase
, int *flag_ptr
)
565 struct dump_file_info
*dfi
;
568 if (phase
== TDI_none
|| !dump_phase_enabled_p (phase
))
571 name
= get_dump_file_name (phase
);
574 dfi
= get_dump_file_info (phase
);
576 stream
= strcmp ("stderr", name
) == 0
578 : strcmp ("stdout", name
) == 0
580 : fopen (name
, dfi
->pstate
< 0 ? "w" : "a");
583 error ("could not open dump file %qs: %m", name
);
589 *flag_ptr
= dfi
->pflags
;
591 /* Initialize current flags */
592 pflags
= dfi
->pflags
;
596 /* Returns nonzero if dump PHASE is enabled for at least one stream.
597 If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
602 dump_phase_enabled_p (int phase
) const
604 if (phase
== TDI_tree_all
)
607 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
608 if (dump_files
[i
].pstate
|| dump_files
[i
].alt_state
)
610 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
611 if (m_extra_dump_files
[i
].pstate
|| m_extra_dump_files
[i
].alt_state
)
617 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
618 return dfi
->pstate
|| dfi
->alt_state
;
622 /* Returns nonzero if tree dump PHASE has been initialized. */
626 dump_initialized_p (int phase
) const
628 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
629 return dfi
->pstate
> 0 || dfi
->alt_state
> 0;
632 /* Returns the switch name of PHASE. */
635 dump_flag_name (int phase
)
637 return g
->get_dumps ()->dump_flag_name (phase
);
642 dump_flag_name (int phase
) const
644 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
648 /* Finish a tree dump for PHASE. STREAM is the stream created by
652 dump_end (int phase ATTRIBUTE_UNUSED
, FILE *stream
)
654 if (stream
!= stderr
&& stream
!= stdout
)
658 /* Enable all tree dumps with FLAGS on FILENAME. Return number of
659 enabled tree dumps. */
663 dump_enable_all (int flags
, const char *filename
)
665 int ir_dump_type
= (flags
& (TDF_TREE
| TDF_RTL
| TDF_IPA
));
669 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
671 if ((dump_files
[i
].pflags
& ir_dump_type
))
673 const char *old_filename
= dump_files
[i
].pfilename
;
674 dump_files
[i
].pstate
= -1;
675 dump_files
[i
].pflags
|= flags
;
677 /* Override the existing filename. */
680 dump_files
[i
].pfilename
= xstrdup (filename
);
681 /* Since it is a command-line provided file, which is
682 common to all the phases, use it in append mode. */
683 dump_files
[i
].pstate
= 1;
685 if (old_filename
&& filename
!= old_filename
)
686 free (CONST_CAST (char *, old_filename
));
690 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
692 if ((m_extra_dump_files
[i
].pflags
& ir_dump_type
))
694 const char *old_filename
= m_extra_dump_files
[i
].pfilename
;
695 m_extra_dump_files
[i
].pstate
= -1;
696 m_extra_dump_files
[i
].pflags
|= flags
;
698 /* Override the existing filename. */
701 m_extra_dump_files
[i
].pfilename
= xstrdup (filename
);
702 /* Since it is a command-line provided file, which is
703 common to all the phases, use it in append mode. */
704 m_extra_dump_files
[i
].pstate
= 1;
706 if (old_filename
&& filename
!= old_filename
)
707 free (CONST_CAST (char *, old_filename
));
714 /* Enable -fopt-info dumps on all dump files matching OPTGROUP_FLAGS.
715 Enable dumps with FLAGS on FILENAME. Return the number of enabled
720 opt_info_enable_passes (int optgroup_flags
, int flags
, const char *filename
)
725 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
727 if ((dump_files
[i
].optgroup_flags
& optgroup_flags
))
729 const char *old_filename
= dump_files
[i
].alt_filename
;
730 /* Since this file is shared among different passes, it
731 should be opened in append mode. */
732 dump_files
[i
].alt_state
= 1;
733 dump_files
[i
].alt_flags
|= flags
;
735 /* Override the existing filename. */
737 dump_files
[i
].alt_filename
= xstrdup (filename
);
738 if (old_filename
&& filename
!= old_filename
)
739 free (CONST_CAST (char *, old_filename
));
743 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
745 if ((m_extra_dump_files
[i
].optgroup_flags
& optgroup_flags
))
747 const char *old_filename
= m_extra_dump_files
[i
].alt_filename
;
748 /* Since this file is shared among different passes, it
749 should be opened in append mode. */
750 m_extra_dump_files
[i
].alt_state
= 1;
751 m_extra_dump_files
[i
].alt_flags
|= flags
;
753 /* Override the existing filename. */
755 m_extra_dump_files
[i
].alt_filename
= xstrdup (filename
);
756 if (old_filename
&& filename
!= old_filename
)
757 free (CONST_CAST (char *, old_filename
));
764 /* Parse ARG as a dump switch. Return nonzero if it is, and store the
765 relevant details in the dump_files array. */
769 dump_switch_p_1 (const char *arg
, struct dump_file_info
*dfi
, bool doglob
)
771 const char *option_value
;
775 if (doglob
&& !dfi
->glob
)
778 option_value
= skip_leading_substring (arg
, doglob
? dfi
->glob
: dfi
->swtch
);
782 if (*option_value
&& *option_value
!= '-' && *option_value
!= '=')
790 const struct dump_option_value_info
*option_ptr
;
797 end_ptr
= strchr (ptr
, '-');
798 eq_ptr
= strchr (ptr
, '=');
800 if (eq_ptr
&& !end_ptr
)
804 end_ptr
= ptr
+ strlen (ptr
);
805 length
= end_ptr
- ptr
;
807 for (option_ptr
= dump_options
; option_ptr
->name
; option_ptr
++)
808 if (strlen (option_ptr
->name
) == length
809 && !memcmp (option_ptr
->name
, ptr
, length
))
811 flags
|= option_ptr
->value
;
817 /* Interpret rest of the argument as a dump filename. This
818 filename overrides other command line filenames. */
820 free (CONST_CAST (char *, dfi
->pfilename
));
821 dfi
->pfilename
= xstrdup (ptr
+ 1);
825 warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
826 length
, ptr
, dfi
->swtch
);
832 dfi
->pflags
|= flags
;
834 /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
836 if (dfi
->suffix
== NULL
)
837 dump_enable_all (dfi
->pflags
, dfi
->pfilename
);
844 dump_switch_p (const char *arg
)
849 for (i
= TDI_none
+ 1; i
!= TDI_end
; i
++)
850 any
|= dump_switch_p_1 (arg
, &dump_files
[i
], false);
852 /* Don't glob if we got a hit already */
854 for (i
= TDI_none
+ 1; i
!= TDI_end
; i
++)
855 any
|= dump_switch_p_1 (arg
, &dump_files
[i
], true);
857 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
858 any
|= dump_switch_p_1 (arg
, &m_extra_dump_files
[i
], false);
861 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
862 any
|= dump_switch_p_1 (arg
, &m_extra_dump_files
[i
], true);
868 /* Parse ARG as a -fopt-info switch and store flags, optgroup_flags
869 and filename. Return non-zero if it is a recognized switch. */
872 opt_info_switch_p_1 (const char *arg
, int *flags
, int *optgroup_flags
,
875 const char *option_value
;
886 return 1; /* Handle '-fopt-info' without any additional options. */
890 const struct dump_option_value_info
*option_ptr
;
897 end_ptr
= strchr (ptr
, '-');
898 eq_ptr
= strchr (ptr
, '=');
900 if (eq_ptr
&& !end_ptr
)
904 end_ptr
= ptr
+ strlen (ptr
);
905 length
= end_ptr
- ptr
;
907 for (option_ptr
= optinfo_verbosity_options
; option_ptr
->name
;
909 if (strlen (option_ptr
->name
) == length
910 && !memcmp (option_ptr
->name
, ptr
, length
))
912 *flags
|= option_ptr
->value
;
916 for (option_ptr
= optgroup_options
; option_ptr
->name
; option_ptr
++)
917 if (strlen (option_ptr
->name
) == length
918 && !memcmp (option_ptr
->name
, ptr
, length
))
920 *optgroup_flags
|= option_ptr
->value
;
926 /* Interpret rest of the argument as a dump filename. This
927 filename overrides other command line filenames. */
928 *filename
= xstrdup (ptr
+ 1);
933 warning (0, "unknown option %q.*s in %<-fopt-info-%s%>",
944 /* Return non-zero if ARG is a recognized switch for
945 -fopt-info. Return zero otherwise. */
948 opt_info_switch_p (const char *arg
)
953 static char *file_seen
= NULL
;
954 gcc::dump_manager
*dumps
= g
->get_dumps ();
956 if (!opt_info_switch_p_1 (arg
, &flags
, &optgroup_flags
, &filename
))
960 filename
= xstrdup ("stderr");
962 /* Bail out if a different filename has been specified. */
963 if (file_seen
&& strcmp (file_seen
, filename
))
965 warning (0, "ignoring possibly conflicting option %<-fopt-info-%s%>",
970 file_seen
= xstrdup (filename
);
972 flags
= MSG_OPTIMIZED_LOCATIONS
;
974 optgroup_flags
= OPTGROUP_ALL
;
976 return dumps
->opt_info_enable_passes (optgroup_flags
, flags
, filename
);
979 /* Print basic block on the dump streams. */
982 dump_basic_block (int dump_kind
, basic_block bb
, int indent
)
984 if (dump_file
&& (dump_kind
& pflags
))
985 dump_bb (dump_file
, bb
, indent
, TDF_DETAILS
);
986 if (alt_dump_file
&& (dump_kind
& alt_flags
))
987 dump_bb (alt_dump_file
, bb
, indent
, TDF_DETAILS
);
990 /* Print information from the combine pass on dump_file. */
993 print_combine_total_stats (void)
996 dump_combine_total_stats (dump_file
);
999 /* Enable RTL dump for all the RTL passes. */
1002 enable_rtl_dump_file (void)
1004 gcc::dump_manager
*dumps
= g
->get_dumps ();
1006 dumps
->dump_enable_all (TDF_RTL
| TDF_DETAILS
| TDF_BLOCKS
, NULL
);
1007 return num_enabled
> 0;