1 /* Dump infrastructure for optimizations and intermediate representation.
2 Copyright (C) 2012-2017 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"
25 #include "gimple-pretty-print.h"
26 #include "diagnostic-core.h"
30 /* If non-NULL, return one past-the-end of the matching SUBPART of
32 #define skip_leading_substring(whole, part) \
33 (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
35 static int pflags
; /* current dump_flags */
36 static int alt_flags
; /* current opt_info flags */
38 static void dump_loc (int, FILE *, source_location
);
39 static FILE *dump_open_alternate_stream (struct dump_file_info
*);
41 /* These are currently used for communicating between passes.
42 However, instead of accessing them directly, the passes can use
43 dump_printf () for dumps. */
44 FILE *dump_file
= NULL
;
45 FILE *alt_dump_file
= NULL
;
46 const char *dump_file_name
;
49 /* Table of tree dump switches. This must be consistent with the
50 TREE_DUMP_INDEX enumeration in dumpfile.h. */
51 static struct dump_file_info dump_files
[TDI_end
] =
53 {NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, false, false},
54 {".cgraph", "ipa-cgraph", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
55 0, 0, 0, 0, 0, false, false},
56 {".type-inheritance", "ipa-type-inheritance", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
57 0, 0, 0, 0, 0, false, false},
58 {".ipa-clones", "ipa-clones", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
59 0, 0, 0, 0, 0, false, false},
60 {".tu", "translation-unit", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
61 0, 0, 0, 0, 1, false, false},
62 {".class", "class-hierarchy", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
63 0, 0, 0, 0, 2, false, false},
64 {".original", "tree-original", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
65 0, 0, 0, 0, 3, false, false},
66 {".gimple", "tree-gimple", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
67 0, 0, 0, 0, 4, false, false},
68 {".nested", "tree-nested", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
69 0, 0, 0, 0, 5, false, false},
70 #define FIRST_AUTO_NUMBERED_DUMP 6
72 {NULL
, "tree-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_TREE
,
73 0, 0, 0, 0, 0, false, false},
74 {NULL
, "rtl-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_RTL
,
75 0, 0, 0, 0, 0, false, false},
76 {NULL
, "ipa-all", NULL
, NULL
, NULL
, NULL
, NULL
, TDF_IPA
,
77 0, 0, 0, 0, 0, false, false},
80 /* Define a name->number mapping for a dump flag value. */
81 struct dump_option_value_info
83 const char *const name
; /* the name of the value */
84 const int value
; /* the value of the name */
87 /* Table of dump options. This must be consistent with the TDF_* flags
88 in dumpfile.h and opt_info_options below. */
89 static const struct dump_option_value_info dump_options
[] =
91 {"address", TDF_ADDRESS
},
92 {"asmname", TDF_ASMNAME
},
96 {"details", (TDF_DETAILS
| MSG_OPTIMIZED_LOCATIONS
97 | MSG_MISSED_OPTIMIZATION
99 {"cselib", TDF_CSELIB
},
100 {"stats", TDF_STATS
},
101 {"blocks", TDF_BLOCKS
},
103 {"lineno", TDF_LINENO
},
105 {"stmtaddr", TDF_STMTADDR
},
106 {"memsyms", TDF_MEMSYMS
},
107 {"verbose", TDF_VERBOSE
},
109 {"alias", TDF_ALIAS
},
110 {"nouid", TDF_NOUID
},
111 {"enumerate_locals", TDF_ENUMERATE_LOCALS
},
113 {"gimple", TDF_GIMPLE
},
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
125 /* A subset of the dump_options table which is used for -fopt-info
126 types. This must be consistent with the MSG_* flags in dumpfile.h.
128 static const struct dump_option_value_info optinfo_verbosity_options
[] =
130 {"optimized", MSG_OPTIMIZED_LOCATIONS
},
131 {"missed", MSG_MISSED_OPTIMIZATION
},
137 /* Flags used for -fopt-info groups. */
138 static const struct dump_option_value_info optgroup_options
[] =
140 {"ipa", OPTGROUP_IPA
},
141 {"loop", OPTGROUP_LOOP
},
142 {"inline", OPTGROUP_INLINE
},
143 {"openmp", OPTGROUP_OPENMP
},
144 {"vec", OPTGROUP_VEC
},
145 {"optall", OPTGROUP_ALL
},
149 gcc::dump_manager::dump_manager ():
150 m_next_dump (FIRST_AUTO_NUMBERED_DUMP
),
151 m_extra_dump_files (NULL
),
152 m_extra_dump_files_in_use (0),
153 m_extra_dump_files_alloced (0)
157 gcc::dump_manager::~dump_manager ()
159 for (size_t i
= 0; i
< m_extra_dump_files_in_use
; i
++)
161 dump_file_info
*dfi
= &m_extra_dump_files
[i
];
162 /* suffix, swtch, glob are statically allocated for the entries
163 in dump_files, and for statistics, but are dynamically allocated
164 for those for passes. */
165 if (dfi
->owns_strings
)
167 XDELETEVEC (const_cast <char *> (dfi
->suffix
));
168 XDELETEVEC (const_cast <char *> (dfi
->swtch
));
169 XDELETEVEC (const_cast <char *> (dfi
->glob
));
171 /* These, if non-NULL, are always dynamically allocated. */
172 XDELETEVEC (const_cast <char *> (dfi
->pfilename
));
173 XDELETEVEC (const_cast <char *> (dfi
->alt_filename
));
175 XDELETEVEC (m_extra_dump_files
);
180 dump_register (const char *suffix
, const char *swtch
, const char *glob
,
181 int flags
, int optgroup_flags
,
184 int num
= m_next_dump
++;
186 size_t count
= m_extra_dump_files_in_use
++;
188 if (count
>= m_extra_dump_files_alloced
)
190 if (m_extra_dump_files_alloced
== 0)
191 m_extra_dump_files_alloced
= 32;
193 m_extra_dump_files_alloced
*= 2;
194 m_extra_dump_files
= XRESIZEVEC (struct dump_file_info
,
196 m_extra_dump_files_alloced
);
199 memset (&m_extra_dump_files
[count
], 0, sizeof (struct dump_file_info
));
200 m_extra_dump_files
[count
].suffix
= suffix
;
201 m_extra_dump_files
[count
].swtch
= swtch
;
202 m_extra_dump_files
[count
].glob
= glob
;
203 m_extra_dump_files
[count
].pflags
= flags
;
204 m_extra_dump_files
[count
].optgroup_flags
= optgroup_flags
;
205 m_extra_dump_files
[count
].num
= num
;
206 m_extra_dump_files
[count
].owns_strings
= take_ownership
;
208 return count
+ TDI_end
;
212 /* Return the dump_file_info for the given phase. */
214 struct dump_file_info
*
216 get_dump_file_info (int phase
) const
219 return &dump_files
[phase
];
220 else if ((size_t) (phase
- TDI_end
) >= m_extra_dump_files_in_use
)
223 return m_extra_dump_files
+ (phase
- TDI_end
);
226 /* Locate the dump_file_info with swtch equal to SWTCH,
227 or return NULL if no such dump_file_info exists. */
229 struct dump_file_info
*
231 get_dump_file_info_by_switch (const char *swtch
) const
233 for (unsigned i
= 0; i
< m_extra_dump_files_in_use
; i
++)
234 if (0 == strcmp (m_extra_dump_files
[i
].swtch
, swtch
))
235 return &m_extra_dump_files
[i
];
242 /* Return the name of the dump file for the given phase.
243 The caller is responsible for calling free on the returned
245 If the dump is not enabled, returns NULL. */
249 get_dump_file_name (int phase
) const
251 struct dump_file_info
*dfi
;
253 if (phase
== TDI_none
)
256 dfi
= get_dump_file_info (phase
);
258 return get_dump_file_name (dfi
);
261 /* Return the name of the dump file for the given dump_file_info.
262 The caller is responsible for calling free on the returned
264 If the dump is not enabled, returns NULL. */
268 get_dump_file_name (struct dump_file_info
*dfi
) const
274 if (dfi
->pstate
== 0)
277 /* If available, use the command line dump filename. */
279 return xstrdup (dfi
->pfilename
);
286 if (dfi
->pflags
& TDF_TREE
)
288 else if (dfi
->pflags
& TDF_IPA
)
293 if (snprintf (dump_id
, sizeof (dump_id
), ".%03d%c", dfi
->num
, suffix
) < 0)
297 return concat (dump_base_name
, dump_id
, dfi
->suffix
, NULL
);
300 /* For a given DFI, open an alternate dump filename (which could also
301 be a standard stream such as stdout/stderr). If the alternate dump
302 file cannot be opened, return NULL. */
305 dump_open_alternate_stream (struct dump_file_info
*dfi
)
308 if (!dfi
->alt_filename
)
312 return dfi
->alt_stream
;
314 stream
= strcmp ("stderr", dfi
->alt_filename
) == 0
316 : strcmp ("stdout", dfi
->alt_filename
) == 0
318 : fopen (dfi
->alt_filename
, dfi
->alt_state
< 0 ? "w" : "a");
321 error ("could not open dump file %qs: %m", dfi
->alt_filename
);
328 /* Print source location on DFILE if enabled. */
331 dump_loc (int dump_kind
, FILE *dfile
, source_location loc
)
335 if (LOCATION_LOCUS (loc
) > BUILTINS_LOCATION
)
336 fprintf (dfile
, "%s:%d:%d: note: ", LOCATION_FILE (loc
),
337 LOCATION_LINE (loc
), LOCATION_COLUMN (loc
));
338 else if (current_function_decl
)
339 fprintf (dfile
, "%s:%d:%d: note: ",
340 DECL_SOURCE_FILE (current_function_decl
),
341 DECL_SOURCE_LINE (current_function_decl
),
342 DECL_SOURCE_COLUMN (current_function_decl
));
346 /* Dump gimple statement GS with SPC indentation spaces and
347 EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. */
350 dump_gimple_stmt (int dump_kind
, int extra_dump_flags
, gimple
*gs
, int spc
)
352 if (dump_file
&& (dump_kind
& pflags
))
353 print_gimple_stmt (dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
355 if (alt_dump_file
&& (dump_kind
& alt_flags
))
356 print_gimple_stmt (alt_dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
359 /* Similar to dump_gimple_stmt, except additionally print source location. */
362 dump_gimple_stmt_loc (int dump_kind
, source_location loc
, int extra_dump_flags
,
365 if (dump_file
&& (dump_kind
& pflags
))
367 dump_loc (dump_kind
, dump_file
, loc
);
368 print_gimple_stmt (dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
371 if (alt_dump_file
&& (dump_kind
& alt_flags
))
373 dump_loc (dump_kind
, alt_dump_file
, loc
);
374 print_gimple_stmt (alt_dump_file
, gs
, spc
, dump_flags
| extra_dump_flags
);
378 /* Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
379 DUMP_KIND is enabled. */
382 dump_generic_expr (int dump_kind
, int extra_dump_flags
, tree t
)
384 if (dump_file
&& (dump_kind
& pflags
))
385 print_generic_expr (dump_file
, t
, dump_flags
| extra_dump_flags
);
387 if (alt_dump_file
&& (dump_kind
& alt_flags
))
388 print_generic_expr (alt_dump_file
, t
, dump_flags
| extra_dump_flags
);
392 /* Similar to dump_generic_expr, except additionally print the source
396 dump_generic_expr_loc (int dump_kind
, source_location loc
,
397 int extra_dump_flags
, tree t
)
399 if (dump_file
&& (dump_kind
& pflags
))
401 dump_loc (dump_kind
, dump_file
, loc
);
402 print_generic_expr (dump_file
, t
, dump_flags
| extra_dump_flags
);
405 if (alt_dump_file
&& (dump_kind
& alt_flags
))
407 dump_loc (dump_kind
, alt_dump_file
, loc
);
408 print_generic_expr (alt_dump_file
, t
, dump_flags
| extra_dump_flags
);
412 /* Output a formatted message using FORMAT on appropriate dump streams. */
415 dump_printf (int dump_kind
, const char *format
, ...)
417 if (dump_file
&& (dump_kind
& pflags
))
420 va_start (ap
, format
);
421 vfprintf (dump_file
, format
, ap
);
425 if (alt_dump_file
&& (dump_kind
& alt_flags
))
428 va_start (ap
, format
);
429 vfprintf (alt_dump_file
, format
, ap
);
434 /* Similar to dump_printf, except source location is also printed. */
437 dump_printf_loc (int dump_kind
, source_location loc
, const char *format
, ...)
439 if (dump_file
&& (dump_kind
& pflags
))
442 dump_loc (dump_kind
, dump_file
, loc
);
443 va_start (ap
, format
);
444 vfprintf (dump_file
, format
, ap
);
448 if (alt_dump_file
&& (dump_kind
& alt_flags
))
451 dump_loc (dump_kind
, alt_dump_file
, loc
);
452 va_start (ap
, format
);
453 vfprintf (alt_dump_file
, format
, ap
);
458 /* Start a dump for PHASE. Store user-supplied dump flags in
459 *FLAG_PTR. Return the number of streams opened. Set globals
460 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
461 set dump_flags appropriately for both pass dump stream and
462 -fopt-info stream. */
466 dump_start (int phase
, int *flag_ptr
)
470 struct dump_file_info
*dfi
;
472 if (phase
== TDI_none
|| !dump_phase_enabled_p (phase
))
475 dfi
= get_dump_file_info (phase
);
476 name
= get_dump_file_name (phase
);
479 stream
= strcmp ("stderr", name
) == 0
481 : strcmp ("stdout", name
) == 0
483 : fopen (name
, dfi
->pstate
< 0 ? "w" : "a");
485 error ("could not open dump file %qs: %m", name
);
492 dfi
->pstream
= stream
;
493 dump_file
= dfi
->pstream
;
494 /* Initialize current dump flags. */
495 pflags
= dfi
->pflags
;
498 stream
= dump_open_alternate_stream (dfi
);
501 dfi
->alt_stream
= stream
;
503 alt_dump_file
= dfi
->alt_stream
;
504 /* Initialize current -fopt-info flags. */
505 alt_flags
= dfi
->alt_flags
;
509 *flag_ptr
= dfi
->pflags
;
514 /* Finish a tree dump for PHASE and close associated dump streams. Also
515 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
519 dump_finish (int phase
)
521 struct dump_file_info
*dfi
;
525 dfi
= get_dump_file_info (phase
);
526 if (dfi
->pstream
&& (!dfi
->pfilename
527 || (strcmp ("stderr", dfi
->pfilename
) != 0
528 && strcmp ("stdout", dfi
->pfilename
) != 0)))
529 fclose (dfi
->pstream
);
531 if (dfi
->alt_stream
&& strcmp ("stderr", dfi
->alt_filename
) != 0
532 && strcmp ("stdout", dfi
->alt_filename
) != 0)
533 fclose (dfi
->alt_stream
);
535 dfi
->alt_stream
= NULL
;
538 alt_dump_file
= NULL
;
539 dump_flags
= TDI_none
;
544 /* Begin a tree dump for PHASE. Stores any user supplied flag in
545 *FLAG_PTR and returns a stream to write to. If the dump is not
546 enabled, returns NULL.
547 Multiple calls will reopen and append to the dump file. */
550 dump_begin (int phase
, int *flag_ptr
)
552 return g
->get_dumps ()->dump_begin (phase
, flag_ptr
);
557 dump_begin (int phase
, int *flag_ptr
)
560 struct dump_file_info
*dfi
;
563 if (phase
== TDI_none
|| !dump_phase_enabled_p (phase
))
566 name
= get_dump_file_name (phase
);
569 dfi
= get_dump_file_info (phase
);
571 stream
= strcmp ("stderr", name
) == 0
573 : strcmp ("stdout", name
) == 0
575 : fopen (name
, dfi
->pstate
< 0 ? "w" : "a");
578 error ("could not open dump file %qs: %m", name
);
584 *flag_ptr
= dfi
->pflags
;
586 /* Initialize current flags */
587 pflags
= dfi
->pflags
;
591 /* Returns nonzero if dump PHASE is enabled for at least one stream.
592 If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
597 dump_phase_enabled_p (int phase
) const
599 if (phase
== TDI_tree_all
)
602 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
603 if (dump_files
[i
].pstate
|| dump_files
[i
].alt_state
)
605 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
606 if (m_extra_dump_files
[i
].pstate
|| m_extra_dump_files
[i
].alt_state
)
612 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
613 return dfi
->pstate
|| dfi
->alt_state
;
617 /* Returns nonzero if tree dump PHASE has been initialized. */
621 dump_initialized_p (int phase
) const
623 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
624 return dfi
->pstate
> 0 || dfi
->alt_state
> 0;
627 /* Returns the switch name of PHASE. */
630 dump_flag_name (int phase
)
632 return g
->get_dumps ()->dump_flag_name (phase
);
637 dump_flag_name (int phase
) const
639 struct dump_file_info
*dfi
= get_dump_file_info (phase
);
643 /* Finish a tree dump for PHASE. STREAM is the stream created by
647 dump_end (int phase ATTRIBUTE_UNUSED
, FILE *stream
)
649 if (stream
!= stderr
&& stream
!= stdout
)
653 /* Enable all tree dumps with FLAGS on FILENAME. Return number of
654 enabled tree dumps. */
658 dump_enable_all (int flags
, const char *filename
)
660 int ir_dump_type
= (flags
& (TDF_TREE
| TDF_RTL
| TDF_IPA
));
664 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
666 if ((dump_files
[i
].pflags
& ir_dump_type
))
668 const char *old_filename
= dump_files
[i
].pfilename
;
669 dump_files
[i
].pstate
= -1;
670 dump_files
[i
].pflags
|= flags
;
672 /* Override the existing filename. */
675 dump_files
[i
].pfilename
= xstrdup (filename
);
676 /* Since it is a command-line provided file, which is
677 common to all the phases, use it in append mode. */
678 dump_files
[i
].pstate
= 1;
680 if (old_filename
&& filename
!= old_filename
)
681 free (CONST_CAST (char *, old_filename
));
685 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
687 if ((m_extra_dump_files
[i
].pflags
& ir_dump_type
))
689 const char *old_filename
= m_extra_dump_files
[i
].pfilename
;
690 m_extra_dump_files
[i
].pstate
= -1;
691 m_extra_dump_files
[i
].pflags
|= flags
;
693 /* Override the existing filename. */
696 m_extra_dump_files
[i
].pfilename
= xstrdup (filename
);
697 /* Since it is a command-line provided file, which is
698 common to all the phases, use it in append mode. */
699 m_extra_dump_files
[i
].pstate
= 1;
701 if (old_filename
&& filename
!= old_filename
)
702 free (CONST_CAST (char *, old_filename
));
709 /* Enable -fopt-info dumps on all dump files matching OPTGROUP_FLAGS.
710 Enable dumps with FLAGS on FILENAME. Return the number of enabled
715 opt_info_enable_passes (int optgroup_flags
, int flags
, const char *filename
)
720 for (i
= TDI_none
+ 1; i
< (size_t) TDI_end
; i
++)
722 if ((dump_files
[i
].optgroup_flags
& optgroup_flags
))
724 const char *old_filename
= dump_files
[i
].alt_filename
;
725 /* Since this file is shared among different passes, it
726 should be opened in append mode. */
727 dump_files
[i
].alt_state
= 1;
728 dump_files
[i
].alt_flags
|= flags
;
730 /* Override the existing filename. */
732 dump_files
[i
].alt_filename
= xstrdup (filename
);
733 if (old_filename
&& filename
!= old_filename
)
734 free (CONST_CAST (char *, old_filename
));
738 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
740 if ((m_extra_dump_files
[i
].optgroup_flags
& optgroup_flags
))
742 const char *old_filename
= m_extra_dump_files
[i
].alt_filename
;
743 /* Since this file is shared among different passes, it
744 should be opened in append mode. */
745 m_extra_dump_files
[i
].alt_state
= 1;
746 m_extra_dump_files
[i
].alt_flags
|= flags
;
748 /* Override the existing filename. */
750 m_extra_dump_files
[i
].alt_filename
= xstrdup (filename
);
751 if (old_filename
&& filename
!= old_filename
)
752 free (CONST_CAST (char *, old_filename
));
759 /* Parse ARG as a dump switch. Return nonzero if it is, and store the
760 relevant details in the dump_files array. */
764 dump_switch_p_1 (const char *arg
, struct dump_file_info
*dfi
, bool doglob
)
766 const char *option_value
;
770 if (doglob
&& !dfi
->glob
)
773 option_value
= skip_leading_substring (arg
, doglob
? dfi
->glob
: dfi
->swtch
);
777 if (*option_value
&& *option_value
!= '-' && *option_value
!= '=')
785 const struct dump_option_value_info
*option_ptr
;
792 end_ptr
= strchr (ptr
, '-');
793 eq_ptr
= strchr (ptr
, '=');
795 if (eq_ptr
&& !end_ptr
)
799 end_ptr
= ptr
+ strlen (ptr
);
800 length
= end_ptr
- ptr
;
802 for (option_ptr
= dump_options
; option_ptr
->name
; option_ptr
++)
803 if (strlen (option_ptr
->name
) == length
804 && !memcmp (option_ptr
->name
, ptr
, length
))
806 flags
|= option_ptr
->value
;
812 /* Interpret rest of the argument as a dump filename. This
813 filename overrides other command line filenames. */
815 free (CONST_CAST (char *, dfi
->pfilename
));
816 dfi
->pfilename
= xstrdup (ptr
+ 1);
820 warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
821 length
, ptr
, dfi
->swtch
);
827 dfi
->pflags
|= flags
;
829 /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
831 if (dfi
->suffix
== NULL
)
832 dump_enable_all (dfi
->pflags
, dfi
->pfilename
);
839 dump_switch_p (const char *arg
)
844 for (i
= TDI_none
+ 1; i
!= TDI_end
; i
++)
845 any
|= dump_switch_p_1 (arg
, &dump_files
[i
], false);
847 /* Don't glob if we got a hit already */
849 for (i
= TDI_none
+ 1; i
!= TDI_end
; i
++)
850 any
|= dump_switch_p_1 (arg
, &dump_files
[i
], true);
852 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
853 any
|= dump_switch_p_1 (arg
, &m_extra_dump_files
[i
], false);
856 for (i
= 0; i
< m_extra_dump_files_in_use
; i
++)
857 any
|= dump_switch_p_1 (arg
, &m_extra_dump_files
[i
], true);
863 /* Parse ARG as a -fopt-info switch and store flags, optgroup_flags
864 and filename. Return non-zero if it is a recognized switch. */
867 opt_info_switch_p_1 (const char *arg
, int *flags
, int *optgroup_flags
,
870 const char *option_value
;
881 return 1; /* Handle '-fopt-info' without any additional options. */
885 const struct dump_option_value_info
*option_ptr
;
892 end_ptr
= strchr (ptr
, '-');
893 eq_ptr
= strchr (ptr
, '=');
895 if (eq_ptr
&& !end_ptr
)
899 end_ptr
= ptr
+ strlen (ptr
);
900 length
= end_ptr
- ptr
;
902 for (option_ptr
= optinfo_verbosity_options
; option_ptr
->name
;
904 if (strlen (option_ptr
->name
) == length
905 && !memcmp (option_ptr
->name
, ptr
, length
))
907 *flags
|= option_ptr
->value
;
911 for (option_ptr
= optgroup_options
; option_ptr
->name
; option_ptr
++)
912 if (strlen (option_ptr
->name
) == length
913 && !memcmp (option_ptr
->name
, ptr
, length
))
915 *optgroup_flags
|= option_ptr
->value
;
921 /* Interpret rest of the argument as a dump filename. This
922 filename overrides other command line filenames. */
923 *filename
= xstrdup (ptr
+ 1);
928 warning (0, "unknown option %q.*s in %<-fopt-info-%s%>",
939 /* Return non-zero if ARG is a recognized switch for
940 -fopt-info. Return zero otherwise. */
943 opt_info_switch_p (const char *arg
)
948 static char *file_seen
= NULL
;
949 gcc::dump_manager
*dumps
= g
->get_dumps ();
951 if (!opt_info_switch_p_1 (arg
, &flags
, &optgroup_flags
, &filename
))
955 filename
= xstrdup ("stderr");
957 /* Bail out if a different filename has been specified. */
958 if (file_seen
&& strcmp (file_seen
, filename
))
960 warning (0, "ignoring possibly conflicting option %<-fopt-info-%s%>",
965 file_seen
= xstrdup (filename
);
967 flags
= MSG_OPTIMIZED_LOCATIONS
;
969 optgroup_flags
= OPTGROUP_ALL
;
971 return dumps
->opt_info_enable_passes (optgroup_flags
, flags
, filename
);
974 /* Print basic block on the dump streams. */
977 dump_basic_block (int dump_kind
, basic_block bb
, int indent
)
979 if (dump_file
&& (dump_kind
& pflags
))
980 dump_bb (dump_file
, bb
, indent
, TDF_DETAILS
);
981 if (alt_dump_file
&& (dump_kind
& alt_flags
))
982 dump_bb (alt_dump_file
, bb
, indent
, TDF_DETAILS
);
985 /* Print information from the combine pass on dump_file. */
988 print_combine_total_stats (void)
991 dump_combine_total_stats (dump_file
);
994 /* Enable RTL dump for all the RTL passes. */
997 enable_rtl_dump_file (void)
999 gcc::dump_manager
*dumps
= g
->get_dumps ();
1001 dumps
->dump_enable_all (TDF_RTL
| TDF_DETAILS
| TDF_BLOCKS
, NULL
);
1002 return num_enabled
> 0;