From patchwork Wed Jun 13 10:44:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 928794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479625-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="pC19N+g/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415NgF3D83z9s1R for ; Wed, 13 Jun 2018 20:44:55 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=YoIjM4jWzU3BXLtVyE1sz0pLEaR9WM4rdXyKBeNoGo5JyhL7REtw8 Ev/zupB0aw+7Ptvta4DJku9WzJXUIf2Zx4ikw/n6XEw5rNh3e7R0vJgjDqOihoyb GxEE0VxdAcnEz3XAOY0Y8MDU99g2cjhf84moM+RtH82mq1LvK5KbdU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=3zJFohLLH/YmGjWWzNeVTsPXH+Y=; b=pC19N+g/HZ4KgGhGVZxF msrgP575y3IUV1NA6oyJjL8dpZ4nVANpPgli09OTlNMhguyjxTE51JXscRU1gz3O X+k+LJ+JgWCQrhaLLhMgCuq13uIlbbZ76kvjwwMB593Tnpxo49eyxaSjU0B9jYJJ txtN/aTCBcgCvAkiEjryBYQ= Received: (qmail 74248 invoked by alias); 13 Jun 2018 10:44:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 74228 invoked by uid 89); 13 Jun 2018 10:44:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-14.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=streaming, compressed, icf, journal X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jun 2018 10:44:42 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A3A43548738; Wed, 13 Jun 2018 12:44:39 +0200 (CEST) Date: Wed, 13 Jun 2018 12:44:39 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, mliska@suse.cz, rguenther@suse.de Subject: Add lto-streamer-out dump file Message-ID: <20180613104439.GB99335@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Hi, this patch adds lto-streamer-out dump file which journal what is streamed into the output file and why. For example compiling: #include main() { fprintf (stderr, "Error\n"); } We get Creating compressed section .gnu.lto_.profile.3e57b5d44bc7b5b7 Creating output block for icf Creating compressed section .gnu.lto_.icf.3e57b5d44bc7b5b7 Creating output block for jmpfuncs Streaming SCC of Streaming to jmpfuncs Streaming to jmpfuncs Encoding indexable as 0 Encoding indexable as 1 Finished SCC of Streaming SCC of Finished SCC of Streaming SCC of Encoding indexable as 2 Finished SCC of Creating compressed section .gnu.lto_.jmpfuncs.3e57b5d44bc7b5b7 Creating output block for inline Creating compressed section .gnu.lto_.inline.3e57b5d44bc7b5b7 Creating compressed section .gnu.lto_.pureconst.3e57b5d44bc7b5b7 Streaming body of main Creating output block for function_body Streaming SCC of Streaming to function_body Encoding indexable as 0 Encoding indexable as 1 Encoding indexable as 2 Encoding indexable as 0 Finished SCC of Streaming SCC of Streaming to function_body Finished SCC of Encoding indexable as 3 Streaming gimple stmt stderr.0_1 = stderr; Streaming SCC of Streaming to function_body Encoding indexable as 4 Streaming to function_body Encoding indexable as 0 Finished SCC of Streaming gimple stmt fwrite ("Error\n", 1, 6, stderr.0_1); Streaming SCC of Streaming to function_body Encoding indexable as 5 Encoding indexable as 1 Finished SCC of Streaming SCC of Streaming to function_body Streaming to function_body Encoding indexable as 6 Encoding indexable as 7 Finished SCC of Streaming SCC of Encoding indexable as 8 Finished SCC of Encoding indexable as 9 Streaming gimple stmt return 0; Creating compressed section .gnu.lto_main.3e57b5d44bc7b5b7 Finished streaming main Encoding indexable as 0 Encoding indexable as 0 Encoding indexable as 1 Creating compressed section .gnu.lto_.symbol_nodes.3e57b5d44bc7b5b7 Creating compressed section .gnu.lto_.refs.3e57b5d44bc7b5b7 Creating output block for decls Creating compressed section .gnu.lto_.decls.3e57b5d44bc7b5b7 Outputting global stream 0: Streaming SCC of Streaming to decls Streaming to decls Streaming to decls Streaming to decls Finished SCC of 1: Streaming SCC of Streaming to decls Finished SCC of 2: 0: Streaming SCC of Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Finished SCC of 1: Streaming SCC of Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Finished SCC of 0: Streaming SCC of Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Streaming to decls Finished SCC of Outputting stream for main 0: 1: 2: 3: 4: Streaming SCC of Streaming to decls Finished SCC of 5: Streaming SCC of Streaming to decls Finished SCC of 6: 7: 8: 9: 0: 1: 0: Creating section .gnu.lto_.symtab.3e57b5d44bc7b5b7 Creating section .gnu.lto_.opts Bootstrapped/regtested x86_64-linux, plan to commit it later today if there are no complains. * cgraph.c (cgraph_node::get_untransformed_body): Dump function bodies streamed in with -Q. * dumpfile.c (dump_files): Add lto-stream-out dump file. * dumpfile.h (tree_dump_index): Add lto_stream_out. * gimple-streamer-out.c: Include gimple-pretty-print.h (output_bb): Dump stmts streamed. * lto-section-out.c: Include print-tree.h (lto_begin_section): Dump sections created. (lto_output_decl_index): Dump decl encoded. * lto-streamer-out.c: Include print-tree.h (create_output_block): Dump output block created. (DFS::DFS_write_tree_body): Dump DFS SCCs streamed. (output_function): Dump function output. (output_constructor): Dump constructor streamed. (write_global_stream): Output indexes encoded. (produce_asm_for_decls): Dump streams encoded. * lto-streamer.c (streamer_dump_file): New global var. * lto-streamer.h (streamer_dump_file): Declare. * passes.c (ipa_write_summaries): Initialize streamer dump. * varpool.c (varpool_node::get_constructor): Dump constructors streamed in. Index: cgraph.c =================================================================== --- cgraph.c (revision 261542) +++ cgraph.c (working copy) @@ -3543,6 +3543,8 @@ cgraph_node::get_untransformed_body (voi gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL); + if (!quiet_flag) + fprintf (stderr, " in:%s", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); lto_input_function_body (file_data, this, data); lto_stats.num_function_bodies++; lto_free_section_data (file_data, LTO_section_function_body, name, Index: dumpfile.c =================================================================== --- dumpfile.c (revision 261542) +++ dumpfile.c (working copy) @@ -64,6 +64,7 @@ static struct dump_file_info dump_files[ DUMP_FILE_INFO (".original", "tree-original", DK_tree, 0), DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 0), DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 0), + DUMP_FILE_INFO (".lto-stream-out", "ipa-lto-stream-out", DK_ipa, 0), #define FIRST_AUTO_NUMBERED_DUMP 1 #define FIRST_ME_AUTO_NUMBERED_DUMP 4 Index: dumpfile.h =================================================================== --- dumpfile.h (revision 261542) +++ dumpfile.h (working copy) @@ -33,6 +33,7 @@ enum tree_dump_index TDI_original, /* dump each function before optimizing it */ TDI_gimple, /* dump each function after gimplifying it */ TDI_nested, /* dump each function after unnesting it */ + TDI_lto_stream_out, /* dump information about lto streaming */ TDI_lang_all, /* enable all the language dumps. */ TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */ Index: gimple-streamer-out.c =================================================================== --- gimple-streamer-out.c (revision 261542) +++ gimple-streamer-out.c (working copy) @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. #include "gimple-iterator.h" #include "cgraph.h" #include "value-prof.h" +#include "gimple-pretty-print.h" /* Output PHI function PHI to the main stream in OB. */ @@ -220,6 +221,11 @@ output_bb (struct output_block *ob, basi { int region; gimple *stmt = gsi_stmt (bsi); + if (streamer_dump_file) + { + fprintf (streamer_dump_file, " Streaming gimple stmt "); + print_gimple_stmt (streamer_dump_file, stmt, 0, TDF_SLIM); + } output_gimple_stmt (ob, stmt); Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 261542) +++ lto-streamer-out.c (working copy) @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. #include "gomp-constants.h" #include "debug.h" #include "omp-offload.h" +#include "print-tree.h" static void lto_write_tree (struct output_block*, tree, bool); @@ -65,6 +66,9 @@ struct output_block * create_output_block (enum lto_section_type section_type) { struct output_block *ob = XCNEW (struct output_block); + if (streamer_dump_file) + fprintf (streamer_dump_file, "Creating output block for %s\n", + lto_section_name [section_type]); ob->section_type = section_type; ob->decl_state = lto_get_out_decl_state (); @@ -738,6 +742,14 @@ DFS::DFS_write_tree_body (struct output_ enum tree_code code; + if (streamer_dump_file) + { + print_node_brief (streamer_dump_file, " Streaming ", + expr, 4); + fprintf (streamer_dump_file, " to %s\n", + lto_section_name [ob->section_type]); + } + code = TREE_CODE (expr); if (CODE_CONTAINS_STRUCT (code, TS_TYPED)) @@ -1635,6 +1647,13 @@ lto_output_tree (struct output_block *ob we stream out. */ gcc_assert (!in_dfs_walk); + if (streamer_dump_file) + { + print_node_brief (streamer_dump_file, " Streaming SCC of ", + expr, 4); + fprintf (streamer_dump_file, "\n"); + } + /* Start the DFS walk. */ /* Save ob state ... */ /* let's see ... */ @@ -1651,6 +1670,12 @@ lto_output_tree (struct output_block *ob streamer_write_uhwi (ob, ix); streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS, lto_tree_code_to_tag (TREE_CODE (expr))); + if (streamer_dump_file) + { + print_node_brief (streamer_dump_file, " Finished SCC of ", + expr, 4); + fprintf (streamer_dump_file, "\n\n"); + } lto_stats.num_pickle_refs_output++; } } @@ -2072,6 +2097,10 @@ output_function (struct cgraph_node *nod basic_block bb; struct output_block *ob; + if (streamer_dump_file) + fprintf (streamer_dump_file, "\nStreaming body of %s\n", + node->name ()); + function = node->decl; fn = DECL_STRUCT_FUNCTION (function); ob = create_output_block (LTO_section_function_body); @@ -2190,6 +2219,9 @@ output_function (struct cgraph_node *nod produce_asm (ob, function); destroy_output_block (ob); + if (streamer_dump_file) + fprintf (streamer_dump_file, "Finished streaming %s\n", + node->name ()); } /* Output the body of function NODE->DECL. */ @@ -2200,6 +2232,10 @@ output_constructor (struct varpool_node tree var = node->decl; struct output_block *ob; + if (streamer_dump_file) + fprintf (streamer_dump_file, "\nStreaming constructor of %s\n", + node->name ()); + ob = create_output_block (LTO_section_function_body); clear_line_info (ob); @@ -2216,6 +2252,9 @@ output_constructor (struct varpool_node produce_asm (ob, var); destroy_output_block (ob); + if (streamer_dump_file) + fprintf (streamer_dump_file, "Finished streaming %s\n", + node->name ()); } @@ -2485,6 +2524,12 @@ write_global_stream (struct output_block for (index = 0; index < size; index++) { t = lto_tree_ref_encoder_get_tree (encoder, index); + if (streamer_dump_file) + { + fprintf (streamer_dump_file, " %i:", (int)index); + print_node_brief (streamer_dump_file, "", t, 4); + fprintf (streamer_dump_file, "\n"); + } if (!streamer_tree_cache_lookup (ob->writer_cache, t, NULL)) stream_write_tree (ob, t, false); } @@ -2860,12 +2905,18 @@ produce_asm_for_decls (void) } /* Write the global symbols. */ + if (streamer_dump_file) + fprintf (streamer_dump_file, "Outputting global stream\n"); lto_output_decl_state_streams (ob, out_state); num_fns = lto_function_decl_states.length (); for (idx = 0; idx < num_fns; idx++) { fn_out_state = lto_function_decl_states[idx]; + if (streamer_dump_file) + fprintf (streamer_dump_file, "Outputting stream for %s\n", + IDENTIFIER_POINTER + (DECL_ASSEMBLER_NAME (fn_out_state->fn_decl))); lto_output_decl_state_streams (ob, fn_out_state); } Index: lto-streamer.c =================================================================== --- lto-streamer.c (revision 261542) +++ lto-streamer.c (working copy) @@ -44,6 +44,8 @@ const char *section_name_prefix = LTO_SE /* Set when streaming LTO for offloading compiler. */ bool lto_stream_offload_p; +FILE *streamer_dump_file; + /* Return a string representing LTO tag TAG. */ const char * Index: lto-streamer.h =================================================================== --- lto-streamer.h (revision 261542) +++ lto-streamer.h (working copy) @@ -1221,5 +1221,6 @@ struct dref_entry { extern vec dref_queue; +extern FILE *streamer_dump_file; #endif /* GCC_LTO_STREAMER_H */ Index: passes.c =================================================================== --- passes.c (revision 261542) +++ passes.c (working copy) @@ -2641,6 +2641,9 @@ ipa_write_summaries (void) if ((!flag_generate_lto && !flag_generate_offload) || seen_error ()) return; + gcc_assert (!dump_file); + streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL); + select_what_to_stream (); encoder = lto_symtab_encoder_new (false); @@ -2683,6 +2686,11 @@ ipa_write_summaries (void) ipa_write_summaries_1 (compute_ltrans_boundary (encoder)); free (order); + if (streamer_dump_file) + { + dump_end (TDI_lto_stream_out, streamer_dump_file); + streamer_dump_file = NULL; + } } /* Same as execute_pass_list but assume that subpasses of IPA passes Index: varpool.c =================================================================== --- varpool.c (revision 261542) +++ varpool.c (working copy) @@ -307,6 +307,8 @@ varpool_node::get_constructor (void) file_data->file_name, name); + if (!quiet_flag) + fprintf (stderr, " in:%s", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); lto_input_variable_constructor (file_data, this, data); gcc_assert (DECL_INITIAL (decl) != error_mark_node); lto_stats.num_function_bodies++; Index: lto-section-out.c =================================================================== --- lto-section-out.c (revision 261542) +++ lto-section-out.c (working copy) @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. #include "data-streamer.h" #include "langhooks.h" #include "lto-compress.h" +#include "print-tree.h" static vec decl_state_stack; @@ -66,6 +67,9 @@ lto_begin_section (const char *name, boo { lang_hooks.lto.begin_section (name); + if (streamer_dump_file) + fprintf (streamer_dump_file, "Creating %ssection %s\n", + compress ? "compressed " : "", name); gcc_assert (compression_stream == NULL); if (compress) compression_stream = lto_start_compression (lto_append_data, NULL); @@ -158,6 +162,12 @@ lto_output_decl_index (struct lto_output if (!existed_p) { index = encoder->trees.length (); + if (streamer_dump_file) + { + print_node_brief (streamer_dump_file, " Encoding indexable ", + name, 4); + fprintf (streamer_dump_file, " as %i \n", index); + } encoder->trees.safe_push (name); new_entry_p = TRUE; }