From patchwork Thu Mar 24 04:05:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1608882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=fJts02tu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KPBV25T37z9sBy for ; Thu, 24 Mar 2022 15:06:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4FDFF3888C58 for ; Thu, 24 Mar 2022 04:05:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FDFF3888C58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648094756; bh=w8pVQW6H64cilkwZfFdA/NQXRDFxqbikqL7c20FVzVI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fJts02tuenMUaWv2vg5lqXnqS4UF1O2ZrtDEKxklhWlZp+evTnxUhy8qxI09B/sKU SvVPvscem38dhtP7yjJ8w6uUkNxNajm538Bl5WBnc94YnEfnGuZ/sQvsGOzLoVjBDm q2pRvJy1LMPOl8fSdyylQxg2+IGGXZ++HB2RQfc4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 5CCBF3858C2C for ; Thu, 24 Mar 2022 04:05:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CCBF3858C2C Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 292E41161F6; Thu, 24 Mar 2022 00:05:34 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8B350f8AIY19; Thu, 24 Mar 2022 00:05:34 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id E6CFE1161B9; Thu, 24 Mar 2022 00:05:33 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 22O45QYM1492674 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Mar 2022 01:05:27 -0300 To: gcc-patches@gcc.gnu.org Subject: hardened conditionals: drop copied identifiers Organization: Free thinker, does not speak for AdaCore Date: Thu, 24 Mar 2022 01:05:26 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The copies of identifiers, indended to associate hardening SSA temporaries to the original variables they refer to, end up causing -fcompare-debug to fail, because DECL_UIDs are not identical, and the nouid flag used in compare-debug dumps doesn't affect the uids in naked identifiers, so the divergence becomes apparent. This patch drops the naked identifiers. Though somewhat desirable, they're not necessary. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog PR debug/104564 * gimple-harden-conditionals.cc (detach_value): Keep temps anonymous. for gcc/testsuite/ChangeLog PR debug/104564 * c-c++-common/torture/harden-comp.c: Adjust. * c-c++-common/torture/harden-cond.c: Adjust. --- gcc/gimple-harden-conditionals.cc | 11 ++++------- gcc/testsuite/c-c++-common/torture/harden-comp.c | 2 +- gcc/testsuite/c-c++-common/torture/harden-cond.c | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc index be01f3ea8c44a..c7e5e077a74f6 100644 --- a/gcc/gimple-harden-conditionals.cc +++ b/gcc/gimple-harden-conditionals.cc @@ -126,14 +126,11 @@ detach_value (location_t loc, gimple_stmt_iterator *gsip, tree val) return val; } - /* Create a SSA "copy" of VAL. This could be an anonymous - temporary, but it's nice to have it named after the corresponding - variable. Alas, when VAL is a DECL_BY_REFERENCE RESULT_DECL, - setting (a copy of) it would be flagged by checking, so we don't - use copy_ssa_name: we create an anonymous SSA name, and then give - it the same identifier (rather than decl) as VAL. */ + /* Create a SSA "copy" of VAL. It would be nice to have it named + after the corresponding variable, but sharing the same decl is + problematic when VAL is a DECL_BY_REFERENCE RESULT_DECL, and + copying just the identifier hits -fcompare-debug failures. */ tree ret = make_ssa_name (TREE_TYPE (val)); - SET_SSA_NAME_VAR_OR_IDENTIFIER (ret, SSA_NAME_IDENTIFIER (val)); /* Some modes won't fit in general regs, so we fall back to memory for them. ??? It would be ideal to try to identify an alternate, diff --git a/gcc/testsuite/c-c++-common/torture/harden-comp.c b/gcc/testsuite/c-c++-common/torture/harden-comp.c index 1ee0b3663443d..502f52e25be24 100644 --- a/gcc/testsuite/c-c++-common/torture/harden-comp.c +++ b/gcc/testsuite/c-c++-common/torture/harden-comp.c @@ -11,4 +11,4 @@ f (int i, int j) /* { dg-final { scan-tree-dump-times "Adding reversed compare" 1 "hardcmp" } } */ /* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "hardcmp" } } */ /* { dg-final { scan-tree-dump-times "_\[0-9\]* = i_\[0-9\]*\[(\]D\[)\] < j_\[0-9\]*\[(\]D\[)\];" 1 "hardcmp" } } */ -/* { dg-final { scan-tree-dump-times "_\[0-9\]* = i_\[0-9\]* >= j_\[0-9\]*;" 1 "hardcmp" } } */ +/* { dg-final { scan-tree-dump-times "_\[0-9\]* = _\[0-9\]* >= _\[0-9\]*;" 1 "hardcmp" } } */ diff --git a/gcc/testsuite/c-c++-common/torture/harden-cond.c b/gcc/testsuite/c-c++-common/torture/harden-cond.c index 86de8e155ed38..213b048b25af5 100644 --- a/gcc/testsuite/c-c++-common/torture/harden-cond.c +++ b/gcc/testsuite/c-c++-common/torture/harden-cond.c @@ -15,4 +15,4 @@ f (int i, int j) /* { dg-final { scan-tree-dump-times "Adding reversed compare" 2 "hardcbr" } } */ /* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "hardcbr" } } */ /* { dg-final { scan-tree-dump-times "if \[(\]i_\[0-9\]*\[(\]D\[)\] < j_\[0-9\]*\[(\]D\[)\]\[)\]" 1 "hardcbr" } } */ -/* { dg-final { scan-tree-dump-times "if \[(\]i_\[0-9\]* >= j_\[0-9\]*\[)\]" 2 "hardcbr" } } */ +/* { dg-final { scan-tree-dump-times "if \[(\]_\[0-9\]* >= _\[0-9\]*\[)\]" 2 "hardcbr" } } */