diff options
author | Hrishikesh Kulkarni <hrishikeshparag@gmail.com> | 2019-05-06 07:23:25 +0000 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-05-06 07:23:25 +0000 |
commit | 66d62d9f2e6b059be6a018397fba555147133a9a (patch) | |
tree | fab164b40d0f06c1e3b883ed151202724aa28fd7 /gcc/dumpfile.c | |
parent | a79420f995764129dc40d1abcbf8ce75a0b0f906 (diff) | |
download | gcc-66d62d9f2e6b059be6a018397fba555147133a9a.zip gcc-66d62d9f2e6b059be6a018397fba555147133a9a.tar.gz gcc-66d62d9f2e6b059be6a018397fba555147133a9a.tar.bz2 |
Add lto-dump tool.
2019-05-06 Hrishikesh Kulkarni <hrishikeshparag@gmail.com>
Martin Liska <mliska@suse.cz>
* Makefile.in: Add lto-dump.texi.
* cgraph.h: Add new functions get_visibility_string and
get_symtab_type_string.
* doc/gcc.texi: Include lto-dump section.
* doc/lto-dump.texi: New file.
* dumpfile.c (dump_switch_p_1): Use parse_dump_option.
(parse_dump_option): Factor out this function.
* dumpfile.h (enum dump_flag): Add new value TDF_ERROR.
(parse_dump_option): Export the function.
* symtab.c (symtab_node::get_visibility_string): New function.
(symtab_node::get_symtab_type_string): Likewise.
2019-05-06 Hrishikesh Kulkarni <hrishikeshparag@gmail.com>
Martin Liska <mliska@suse.cz>
* Make-lang.in: Add lto_dump-related definition.
* config-lang.in: Likewise.
* lang.opt: Add new language LTODump and options related
to LTO dump tool.
* lto-common.c (lto_read_decls): Support type statistics dump.
(lto_file_read): Likewise for object files.
* lto-dump.c: New file.
* lto-lang.c (lto_option_lang_mask): Move from ..
* lto.c (lto_option_lang_mask): .. here.
* lto.h (lto_option_lang_mask): New declaration.
Co-Authored-By: Martin Liska <mliska@suse.cz>
From-SVN: r270897
Diffstat (limited to 'gcc/dumpfile.c')
-rw-r--r-- | gcc/dumpfile.c | 85 |
1 files changed, 55 insertions, 30 deletions
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index 14b6dfe..5263d3a 100644 --- a/gcc/dumpfile.c +++ b/gcc/dumpfile.c @@ -115,6 +115,7 @@ static struct dump_file_info dump_files[TDI_end] = in dumpfile.h and opt_info_options below. */ static const kv_pair<dump_flags_t> dump_options[] = { + {"none", TDF_NONE}, {"address", TDF_ADDRESS}, {"asmname", TDF_ASMNAME}, {"slim", TDF_SLIM}, @@ -1770,28 +1771,19 @@ gcc::dump_manager::update_dfi_for_opt_info (dump_file_info *dfi) const return true; } -/* Parse ARG as a dump switch. Return nonzero if it is, and store the - relevant details in the dump_files array. */ +/* Helper routine to parse -<dump format>[=filename] + and return the corresponding dump flag. If POS_P is non-NULL, + assign start of filename into *POS_P. */ -int -gcc::dump_manager:: -dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob) +dump_flags_t +parse_dump_option (const char *option_value, const char **pos_p) { - const char *option_value; const char *ptr; dump_flags_t flags; - if (doglob && !dfi->glob) - return 0; - - option_value = skip_leading_substring (arg, doglob ? dfi->glob : dfi->swtch); - if (!option_value) - return 0; - - if (*option_value && *option_value != '-' && *option_value != '=') - return 0; - ptr = option_value; + if (pos_p) + *pos_p = NULL; /* Retain "user-facing" and "internals" messages, but filter out those from an opt_problem being re-emitted at the top level @@ -1805,14 +1797,13 @@ dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob) const char *end_ptr; const char *eq_ptr; unsigned length; - while (*ptr == '-') ptr++; end_ptr = strchr (ptr, '-'); eq_ptr = strchr (ptr, '='); if (eq_ptr && !end_ptr) - end_ptr = eq_ptr; + end_ptr = eq_ptr; if (!end_ptr) end_ptr = ptr + strlen (ptr); @@ -1821,25 +1812,59 @@ dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob) for (option_ptr = dump_options; option_ptr->name; option_ptr++) if (strlen (option_ptr->name) == length && !memcmp (option_ptr->name, ptr, length)) - { - flags |= option_ptr->value; + { + flags |= option_ptr->value; goto found; - } + } if (*ptr == '=') - { + { /* Interpret rest of the argument as a dump filename. This filename overrides other command line filenames. */ - if (dfi->pfilename) - free (CONST_CAST (char *, dfi->pfilename)); - dfi->pfilename = xstrdup (ptr + 1); - break; - } + if (pos_p) + *pos_p = ptr + 1; + break; + } else - warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>", - length, ptr, dfi->swtch); - found:; + { + warning (0, "ignoring unknown option %q.*s", + length, ptr); + flags = TDF_ERROR; + } + found: ptr = end_ptr; + } + + return flags; +} + +/* Parse ARG as a dump switch. Return nonzero if it is, and store the + relevant details in the dump_files array. */ + +int +gcc::dump_manager:: +dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob) +{ + const char *option_value; + dump_flags_t flags = TDF_NONE; + + if (doglob && !dfi->glob) + return 0; + + option_value = skip_leading_substring (arg, doglob ? dfi->glob : dfi->swtch); + if (!option_value) + return 0; + + if (*option_value && *option_value != '-' && *option_value != '=') + return 0; + + const char *filename; + flags = parse_dump_option (option_value, &filename); + if (filename) + { + if (dfi->pfilename) + free (CONST_CAST (char *, dfi->pfilename)); + dfi->pfilename = xstrdup (filename); } dfi->pstate = -1; |