Hi, Please find the diff file for dumping tree type stats attached here with.
example: $ ../stage1-build/gcc/lto1 test_hello.o -fdump-lto-tree-type-stats Reading object files: test_hello.o integer_type 3 pointer_type 3 array_type 1 function_type 4 I have pushed the changes on Github repo. Regards, Hrishikesh On Mon, Jun 18, 2018 at 2:15 PM, Martin Jambor <mjam...@suse.cz> wrote: > Hi, > > On Sun, Jun 17 2018, Hrishikesh Kulkarni wrote: >> Hi, >> >> I am trying to isolate the dump tool into real lto-dump tool. I have >> started with the copy&paste of lto.c into lto-dump.c and done the >> changes to Make-lang.in and config-lang.in suggested by Martin (patch >> attached). However when I try to build, I get the following error: >> >> In file included from ../../gcc/gcc/lto/lto-dump.c:24:0: >> >> ../../gcc/gcc/coretypes.h:397:24: fatal error: insn-modes.h: No such >> >> file or directory >> >> compilation terminated. >> >> >> I am unable to find the missing dependencies and would be grateful for >> suggestions on how to resolve the issue. > > insn-modes.h is one of header files which are generated at build time, > you will find it in the gcc subdirectory of your build directory (as > opposed to the source directory). > > Martin
diff --git a/gcc/lto/lang.opt b/gcc/lto/lang.opt index c10c662..dd506c0 100644 --- a/gcc/lto/lang.opt +++ b/gcc/lto/lang.opt @@ -77,6 +77,9 @@ LTO Driver RejectNegative Joined Var(flag_lto_dump_symbol) demangle LTO Var(flag_lto_dump_demangle) +fdump-lto-tree-type-stats +LTO Var(flag_lto_dump_tree_type_stats) + fdump-lto-body= LTO Driver RejectNegative Joined Var(flag_lto_dump_body) diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index afdb76a..760a796 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1799,9 +1799,6 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, data_in->location_cache.accept_location_cache (); bool seen_type = false; - - - for (unsigned i = 0; i < len; ++i) { tree t = streamer_tree_cache_get_tree (data_in->reader_cache, @@ -1810,14 +1807,14 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, chains. */ if (TYPE_P (t)) { - itr = stats.find(TREE_CODE(t)); - if (itr == stats.end()) + if (flag_lto_dump_tree_type_stats) { - stats.insert(std :: pair <tree_code, int> (TREE_CODE(t), 1)); - } - else - itr->second++; - + itr = stats.find(TREE_CODE(t)); + if (itr == stats.end()) + stats.insert(std :: pair <tree_code, int> (TREE_CODE(t), 1)); + else + itr->second++; + } seen_type = true; num_prevailing_types++; lto_fixup_prevailing_type (t); @@ -1865,10 +1862,9 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, } } fprintf(stderr, "\n"); - for (itr = stats.begin(); itr != stats.end(); ++itr) - { - fprintf(stderr, "\t%s\t%d\n", get_tree_code_name(itr->first), itr->second ); - } + if (flag_lto_dump_tree_type_stats) + for (itr = stats.begin(); itr != stats.end(); ++itr) + fprintf(stderr, "\t%s\t%d\n", get_tree_code_name(itr->first), itr->second ); data_in->location_cache.apply_location_cache ();