From patchwork Wed Sep 17 18:20:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 390491 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 B92FE1400DD for ; Thu, 18 Sep 2014 04:21:02 +1000 (EST) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=q6q80sDEIK9MUVBs+wYOVRCe56uua EXQsAP4DM0QNT+plDBwZB4XeSf0dneJ3Fmo65rab6L8hwJ3g/vh8A8Ookbf+QjjT ltkDVilgJGz3ViW7xJVoPb/zTWObdP1HfoPUhEDZ6cab3bPjc/+chxOZyJHsCd6l b9i/VJ/tQUIfuI= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=mkMoz866BPvjElwK/ki1aP134fY=; b=U7X /JuuKnTiU8pmkeAHZn2/lIOIlxhzDuNpjU6JV6HXsda7aUsHHNdJMiF6T8McVSum Fs61D2hKUkoClW63sakJPnF82IwxnQo/B4Tjtq+ZAuLam7zklt/H2g+Ei29ijMSE RCzXSAT/9NKE1IOfjjC1UFHFfvlRxLYF1KvbiUHo= Received: (qmail 14747 invoked by alias); 17 Sep 2014 18:20:55 -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 14737 invoked by uid 89); 17 Sep 2014 18:20:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 17 Sep 2014 18:20:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8HIKkAC010622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Sep 2014 14:20:46 -0400 Received: from tucnak.zalov.cz (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8HIKixL024950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Sep 2014 14:20:45 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.8/8.14.7) with ESMTP id s8HIKgdV012329; Wed, 17 Sep 2014 20:20:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.8/8.14.8/Submit) id s8HIKfPk012328; Wed, 17 Sep 2014 20:20:41 +0200 Date: Wed, 17 Sep 2014 20:20:41 +0200 From: Jakub Jelinek To: Richard Biener , Jeff Law , Alexandre Oliva Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -fcompare-debug failures caused by fixup_noreturn_call (PR debug/63284) Message-ID: <20140917182041.GT17454@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! The following testcase fails on 4.9 branch (shows undesirable difference in *.optimized dump on the trunk, but doesn't report -fcompare-debug failure there, and in 4.8 is latent). The problem is that if we have a noreturn stmt followed by only debug stmt, fixup_noreturn_call will try to split_block after the noreturn call, but with -g0 there are never debug stmts and thus we would not split the block; that can lead to different order of bb predecessors, different order of PHI args etc. As nothing after noreturn call really matters, this patch if there are only debug stmts after noreturn call removes the debug stmts instead of the undesirable splitting of the block. Bootstrapped/regtested on x86_64-linux and i686-linux on the trunk and on the 4.9 branch, ok for trunk/4.9 and eventually 4.8 too? 2014-09-17 Jakub Jelinek PR debug/63284 * tree-cfgcleanup.c (fixup_noreturn_call): Don't split block if there are only debug stmts after the noreturn call, instead remove the debug stmts. * gcc.dg/pr63284.c: New test. Jakub --- gcc/tree-cfgcleanup.c.jj 2014-09-01 13:33:11.000000000 +0200 +++ gcc/tree-cfgcleanup.c 2014-09-17 11:01:53.448165423 +0200 @@ -565,7 +565,20 @@ fixup_noreturn_call (gimple stmt) /* First split basic block if stmt is not last. */ if (stmt != gsi_stmt (gsi_last_bb (bb))) - split_block (bb, stmt); + { + if (stmt == gsi_stmt (gsi_last_nondebug_bb (bb))) + { + /* Don't split if there are only debug stmts + after stmt, that can result in -fcompare-debug + failures. Remove the debug stmts instead, + they should be all unreachable anyway. */ + gimple_stmt_iterator gsi = gsi_for_stmt (stmt); + for (gsi_next (&gsi); !gsi_end_p (gsi); ) + gsi_remove (&gsi, true); + } + else + split_block (bb, stmt); + } changed |= remove_fallthru_edge (bb->succs); --- gcc/testsuite/gcc.dg/pr63284.c.jj 2014-09-17 10:56:59.699677715 +0200 +++ gcc/testsuite/gcc.dg/pr63284.c 2014-09-17 10:56:39.000000000 +0200 @@ -0,0 +1,42 @@ +/* PR debug/63284 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int a[10], *b, *d, c, f; +int fn2 (void); +void fn3 (void); +void fn4 (int); + +static int +fn1 (int x) +{ + int e = a[0]; + if (e) + return 1; + if (b) + switch (x) + { + case 1: + if (d) + e = fn2 (); + else + fn3 (); + break; + case 0: + if (d) + { + fn3 (); + if (c) + fn4 (1); + } + else + fn4 (0); + } + return e; +} + +void +fn6 (void) +{ + f = fn1 (0); +}