Hi, -fdump-lto-body=foo will dump gimple body of the function foo
foo (int a, int b) { <bb 2> [local count: 1073741825]: _3 = a_1(D) + b_2(D); return _3; } Please find the diff file attached herewith. Regards, Hrishikesh On Fri, Jun 8, 2018 at 7:15 PM, Martin Liška <mli...@suse.cz> wrote: > On 06/08/2018 03:40 PM, Martin Liška wrote: >> There's wrong declaration of the function in header file. I'll fix it soon >> on trunk. Please carry on with following patch: > > Fixed in r261327. > > Martin
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 8529c82..8d20917 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -1320,7 +1320,6 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta /* Restore decl state */ file_data->current_decl_state = file_data->global_decl_state; } - lto_data_in_delete (data_in); } diff --git a/gcc/lto/lang.opt b/gcc/lto/lang.opt index a098797..c10c662 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-body= +LTO Driver RejectNegative Joined Var(flag_lto_dump_body) + fresolution= LTO Joined The resolution file. diff --git a/gcc/lto/lto-dump.c b/gcc/lto/lto-dump.c index e0becd1..687c9c9 100644 --- a/gcc/lto/lto-dump.c +++ b/gcc/lto/lto-dump.c @@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see #include "function.h" #include "basic-block.h" #include "tree.h" +#include "tree-cfg.h" #include "gimple.h" #include "cgraph.h" #include "lto-streamer.h" @@ -36,13 +37,14 @@ along with GCC; see the file COPYING3. If not see #include "stdio.h" #include "lto.h" + /* Dump everything. */ -void +void dump () { fprintf(stderr, "\nHello World!\n"); } - + /* Dump variables and functions used in IL. */ void dump_list () @@ -53,10 +55,14 @@ dump_list () fprintf (stderr, "\t\tName \t\tType \t\tVisibility\n"); FOR_EACH_SYMBOL (node) { - fprintf (stderr, "\n%20s",(flag_lto_dump_demangle) - ? node->name (): node->dump_asm_name ()); + const char *x = strchr (node->asm_name (), '/'); + if (flag_lto_dump_demangle) + fprintf (stderr, "\n%20s", node->name ()); + else + fprintf (stderr, "\n%20s", node->asm_name (), + node->asm_name ()-x); fprintf (stderr, "%20s", node->dump_type_name ()); - fprintf (stderr, "%20s\n", node->dump_visibility ()); + fprintf (stderr, "%20s", node->dump_visibility ()); } } @@ -67,13 +73,19 @@ dump_symbol () symtab_node *node; fprintf (stderr, "\t\tName \t\tType \t\tVisibility\n"); FOR_EACH_SYMBOL (node) - { - if (!strcmp(flag_lto_dump_symbol, node->name())) + if (!strcmp (flag_lto_dump_symbol, node->name ())) + node->debug (); +} + +/* Dump gimple body of specific function. */ +void +dump_body () +{ + cgraph_node *cnode; + FOR_EACH_FUNCTION (cnode) + if (!strcmp (cnode->name (), flag_lto_dump_body)) { - fprintf (stderr, "\n%20s",(flag_lto_dump_demangle) - ? node->name (): node->dump_asm_name ()); - fprintf (stderr, "%20s", node->dump_type_name ()); - fprintf (stderr, "%20s\n", node->dump_visibility ()); + cnode->get_untransformed_body (); + debug_function (cnode->decl, 0); } - } } \ No newline at end of file diff --git a/gcc/lto/lto-dump.h b/gcc/lto/lto-dump.h index 352160c..3b6c9bc 100644 --- a/gcc/lto/lto-dump.h +++ b/gcc/lto/lto-dump.h @@ -29,4 +29,7 @@ void dump_list (); /*Dump specific variable or function used in IL. */ void dump_symbol (); +/*Dump gimple body of specific function. */ +void dump_body (); + #endif \ No newline at end of file diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index ab1eed3..88d1480 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -2170,7 +2170,7 @@ lto_file_read (lto_file *file, FILE *resolution_file, int *count) /* Finalize each lto file for each submodule in the merged object */ for (file_data = file_list.first; file_data != NULL; file_data = file_data->next) lto_create_files_from_ids (file, file_data, count); - + splay_tree_delete (file_ids); htab_delete (section_hash_table); @@ -3373,6 +3373,10 @@ lto_main (void) if (flag_lto_dump_symbol) dump_symbol (); + /* Dump gimple body of specific function. */ + if (flag_lto_dump_body) + dump_body (); + timevar_stop (TV_PHASE_STREAM_IN); if (!seen_error ()) diff --git a/gcc/symtab.c b/gcc/symtab.c index 1d2374f..0e08519 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -815,7 +815,7 @@ symtab_node::dump_visibility () const "default", "protected", "hidden", "internal" }; - return visibility_types [DECL_VISIBILITY (decl)]; + return visibility_types[DECL_VISIBILITY (decl)]; } const char * diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h index 73237a6..3e10d15 100644 --- a/gcc/tree-cfg.h +++ b/gcc/tree-cfg.h @@ -81,7 +81,7 @@ extern void fold_loop_internal_call (gimple *, tree); extern basic_block move_sese_region_to_fn (struct function *, basic_block, basic_block, tree); extern void dump_function_to_file (tree, FILE *, dump_flags_t); -extern void debug_function (tree, int) ; +extern void debug_function (tree, dump_flags_t) ; extern void print_loops_bb (FILE *, basic_block, int, int); extern void print_loops (FILE *, int); extern void debug (struct loop &ref);