From patchwork Wed Mar 16 10:57:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 598258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3qQ7kq6hTZz9sRB for ; Wed, 16 Mar 2016 21:58:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=T4voww9N; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=qfWIq5epA2jaroBnx3HTFQfkYSBrmW4vj5eUhKMlNmWuuSY0Pi Opl76NyJDyYzJWYuiId2PiGF/LuzgZTNxKnKsAp/7J2zU81rdc9I3lh7IO2uo/Qk tLKT2WJ5oPdMK95POOEFcvM0TZhQg1YkV5qgchXJsSb/P6f2dZVKbPTkw= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=9xIDjMejmWJuSPvpBtjeKX+x/J4=; b=T4voww9NjnZ6Z95XRhvg juUCOiL54R/wRJL2rkUm2QXUe8YbFEhTkEea4oN41krIBRufWqVxGoIsm1mVRvPr wRVBvAgzPvAtB98m3jrE9P0IxXfEUvlSR5Un9peOW+EGUzEJgBeJGOcCX8QsXHA6 CckVIPm9puxzHKW2tqWYdqU= Received: (qmail 73633 invoked by alias); 16 Mar 2016 10:58:20 -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 73618 invoked by uid 89); 16 Mar 2016 10:58:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=finalize, 010, 007, 1057 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Mar 2016 10:58:07 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ag99P-0001VJ-Ug from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Wed, 16 Mar 2016 03:58:04 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Wed, 16 Mar 2016 10:58:02 +0000 To: GCC Patches From: Tom de Vries Subject: [PATCH, PR70185] Only finalize dot files that have been initialized Message-ID: <56E93C26.7070400@mentor.com> Date: Wed, 16 Mar 2016 11:57:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Hi, Atm, using fdump-tree-all-graph produces invalid dot files: ... $ rm *.c.* ; gcc test.c -O2 -S -fdump-tree-all-graph $ for f in *.dot; do dot -Tpdf $f -o dot.pdf; done Warning: test.c.006t.omplower.dot: syntax error in line 1 near '}' Warning: test.c.007t.lower.dot: syntax error in line 1 near '}' Warning: test.c.010t.eh.dot: syntax error in line 1 near '}' Warning: test.c.292t.statistics.dot: syntax error in line 1 near '}' $ cat test.c.006t.omplower.dot } $ ... These dot files are finalized, but never initialized or used. The 006/007/010 files are not used because '(fn->curr_properties & PROP_cfg) == 0' at the corresponding passes. And the file test.c.292t.statistics.dot is not used, because it doesn't belong to a single pass. The current finalization code doesn't handle these cases: ... /* Do whatever is necessary to finish printing the graphs. */ for (i = TDI_end; (dfi = dumps->get_dump_file_info (i)) != NULL; ++i) if (dumps->dump_initialized_p (i) && (dfi->pflags & TDF_GRAPH) != 0 && (name = dumps->get_dump_file_name (i)) != NULL) { finish_graph_dump_file (name); free (name); } ... The patch fixes this by simply testing for pass->graph_dump_initialized instead. [ That fix exposes the lack of initialization of graph_dump_initialized. It seems to be initialized for static passes, but for dynamically added passes, such as f.i. vzeroupper the value is uninitialized. The patch also fixes this. ] Bootstrapped and reg-tested on x86_64. OK for stage1? Thanks, - Tom Only finalize dot files that have been initialized 2016-03-16 Tom de Vries PR other/70185 * passes.c (opt_pass::opt_pass): Add missing initialization of graph_dump_initialized. (finish_optimization_passes): Only call finish_graph_dump_file if pass->graph_dump_initialized. --- gcc/passes.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gcc/passes.c b/gcc/passes.c index 9d90251..5aa2b32 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -105,6 +105,7 @@ opt_pass::opt_pass (const pass_data &data, context *ctxt) sub (NULL), next (NULL), static_pass_number (0), + graph_dump_initialized (false), m_ctxt (ctxt) { } @@ -363,14 +364,18 @@ finish_optimization_passes (void) } /* Do whatever is necessary to finish printing the graphs. */ + gcc::pass_manager *passes = g->get_passes (); for (i = TDI_end; (dfi = dumps->get_dump_file_info (i)) != NULL; ++i) - if (dumps->dump_initialized_p (i) - && (dfi->pflags & TDF_GRAPH) != 0 - && (name = dumps->get_dump_file_name (i)) != NULL) - { - finish_graph_dump_file (name); - free (name); - } + { + opt_pass *pass = passes->get_pass_for_id (i); + if (pass == NULL + || !pass->graph_dump_initialized) + continue; + + name = dumps->get_dump_file_name (i); + finish_graph_dump_file (name); + free (name); + } timevar_pop (TV_DUMP); }