From patchwork Wed Feb 4 05:56:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 436138 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 D3F9D140216 for ; Wed, 4 Feb 2015 16:57:40 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=GAT72KTc2DUXOW+8 Zt0/f2umAZnTxqNmRFPNgkGbi+oEBIWMre4ta1PiNKCZHoJ50CYpyYqUNAVYO5xg 3zqdFZS/bro7HIiUGr6DJz6NvZaJyLDpZLQ7u4Ic3YrKc/vQSuQvdYeiPSB0w/g0 Ur3+BweIiJko8XcfiedXrUANcnk= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=bVJPMgHDLJGbyly7jm3yYh OMR+A=; b=MpyqQ2y9QOw+53f38qxEzIA2d9hkhCfrFP4ZAUFrgUrTu5fSWkv3bK 8aHVwqZpv3Lwx1eZkAvFPXFZPfb7A+FaZyutZJHfyAuoxUj/5i+PNcURgsfVK5/W FP+K0JjvJAj53uXTraxPP5mhYidpMwkIhImoNHtV/dz7AgSnDipTM= Received: (qmail 23482 invoked by alias); 4 Feb 2015 05:57:12 -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 23468 invoked by uid 89); 4 Feb 2015 05:57:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD 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, 04 Feb 2015 05:57:10 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t145v7J3030952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 4 Feb 2015 00:57:07 -0500 Received: from freie.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t145v5PN002843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 4 Feb 2015 00:57:06 -0500 Received: from livre.home (livre.home [172.31.160.2]) by freie.home (8.14.8/8.14.8) with ESMTP id t145uuNq020424; Wed, 4 Feb 2015 03:56:56 -0200 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PR64817-related 1/3] fix debug expr expand of compares Date: Wed, 04 Feb 2015 03:56:56 -0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 PR64817 is lucky that the compare in the testcase was <0 rather than >0. expand_debug_expr used to take the signedness of the expr from the result type, rather than from the operand types, so it the a < 0 test was expanded as LTU rather than LT, and LTU compares with zero are always false, so we short-circuited the most complex debug exprs out. Reversing the sense of the test is enough to expose them. Even though Jakub's earlier patch for PR64817 avoided the simplify-rtx problems during cfgexpand, var-track still runs afoul of it once the sense of the compare is reversed, as in the testcase below. This patch makes the situation with a<0 as bad as with a>0. Fixing the is left for patch 2 of this series; maybe the testcase should be installed along with it. In my series, this patch was actually #3, that's why I had the testcase with it. However, I found it easier to explain the problem starting out with this one, and including the testcase. I can split out the testcase into a separate patch or install it along with the second patch in the series, if that makes more sense. While staring at the code, I found a couple of typos in comments in cfgexpand, that I fixed as part of this patch. I can split that out too, if I must. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/ChangeLog PR debug/64817 * cfgexpand.c (expand_debug_expr): Compute unsignedp from operands for tcc_comparison exprs. Fix typos. for gcc/testsuite/ChangeLog PR debug/64817 * gcc.dg/pr64817-3.c: New. --- gcc/cfgexpand.c | 9 ++++++--- gcc/testsuite/gcc.dg/pr64817-3.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr64817-3.c diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 12021de0..7dfe1f6 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3911,7 +3911,6 @@ expand_debug_expr (tree exp) binary: case tcc_binary: - case tcc_comparison: op1 = expand_debug_expr (TREE_OPERAND (exp, 1)); if (!op1) return NULL_RTX; @@ -3925,6 +3924,10 @@ expand_debug_expr (tree exp) return NULL_RTX; break; + case tcc_comparison: + unsignedp = TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))); + goto binary; + case tcc_type: case tcc_statement: gcc_unreachable (); @@ -4006,7 +4009,7 @@ expand_debug_expr (tree exp) op0 = copy_rtx (op0); if (GET_MODE (op0) == BLKmode - /* If op0 is not BLKmode, but BLKmode is, adjust_mode + /* If op0 is not BLKmode, but mode is, adjust_mode below would ICE. While it is likely a FE bug, try to be robust here. See PR43166. */ || mode == BLKmode @@ -5285,7 +5288,7 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) if (have_debug_uses) { - /* OP is a TERed SSA name, with DEF it's defining + /* OP is a TERed SSA name, with DEF its defining statement, and where OP is used in further debug instructions. Generate a debug temporary, and replace all uses of OP in debug insns with that diff --git a/gcc/testsuite/gcc.dg/pr64817-3.c b/gcc/testsuite/gcc.dg/pr64817-3.c new file mode 100644 index 0000000..3fe0117 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr64817-3.c @@ -0,0 +1,13 @@ +/* PR debug/64817 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a; + +void +foo (void) +{ + int e; + a = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) ^ 1; + e = (a > 0); +}