From patchwork Wed Feb 8 19:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 54588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3636726wrn; Wed, 8 Feb 2023 11:14:44 -0800 (PST) X-Google-Smtp-Source: AK7set9t0kj2mI7w2DgJW+VdA+aVZ4ozz8RlUUdW343vUXoO7gIlmvxnT8BpGIxfeOYjkJovQ28D X-Received: by 2002:a50:f61b:0:b0:4a0:e237:2cef with SMTP id c27-20020a50f61b000000b004a0e2372cefmr9442646edn.4.1675883684889; Wed, 08 Feb 2023 11:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675883684; cv=none; d=google.com; s=arc-20160816; b=gVRNI45Sems5FJYUPcBaV7PjtPU3H00cuj/Cp0hE4IwomlM7lVlrqNdKnlJVkuSD6m X0LxDO9cQI6SJhI+TOafhl9vkzQ3MvL910P1kLpLrF8+I0tWK2susM1Oz4bu/aRdBmqt mbSuo3O20PPsd0ytbqyLOjh469gdFfRqxIagQgbquufuAkaLPejLg7IlzgmY6JmDvQ5J vSqpI1Nm7jHnftrPTsfH0SqKdRAd//9b57BnACfYmeBxRQ9fV2uROi8Wk38E+aBYozcW RLcsTwHxZK0ZGtBggbnQnDmQNfpPD5PiXP+pT//vBleh0nKkgbctm6NPioPOs4Em5ikx jGbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=kGAZEoS6VvZz2ODLZWf8yt6ADJ/4A3yB1Stkkp0TB8s=; b=icnofpvd9RCXHccDDH9yQ+rH0OfqYD8CifN5bhX5kOOESUNbRasAHPKKOm4WI5b33x X+L1KMNmiisPK6RxXHg7deXZWTGS4vbDfHj2wSDb5E/dDtb1DfiI0iqBxbClqdgLbPmS uVw55FOusgj7bNW19Ig4TC3IUnRV/8tCjtFAwnyIYgte/l4FZWYSSP9ymJk6hzvMBbJl F+RDGw8MevY3ywhRu1B+n/2hPHchK9QQvOT06PXkpap8NzGMKstxWqvIuZLGgK7joXHr i5IgNA4WNUvbdU7q8M7pA7Fi8FvZ5dyEpdQdV//OhtYz2ibr/F9LugX9RhYrRgyC0aD3 ACsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LV2ZTHK1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d3-20020aa7ce03000000b004ab0704677fsi3150893edv.512.2023.02.08.11.14.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 11:14:44 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LV2ZTHK1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACC643858422 for ; Wed, 8 Feb 2023 19:14:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACC643858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675883683; bh=kGAZEoS6VvZz2ODLZWf8yt6ADJ/4A3yB1Stkkp0TB8s=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LV2ZTHK1G0iUG5kqqLJYz/FfTbYkC3PHMofG6K5sQuOvzispCQebjO3w+X23+d2vq HJKvsk6UwO5bR7q7trd7dHuj6IT8ISdIkRK4WhtoGLhnBhBL6c0Yypx3EzkBLtHala P92dnhc+Jx7YzhDNop/FCK4Zr87X2yb5glIkG9HA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 2F488385842C for ; Wed, 8 Feb 2023 19:13:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F488385842C Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 318Idmph026395; Wed, 8 Feb 2023 11:13:57 -0800 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nm65kw2h8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 08 Feb 2023 11:13:57 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 8 Feb 2023 11:13:55 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Wed, 8 Feb 2023 11:13:55 -0800 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.67]) by maili.marvell.com (Postfix) with ESMTP id 1E5273F704C; Wed, 8 Feb 2023 11:13:55 -0800 (PST) To: CC: Andrew Pinski , Andrew Macleod Subject: [PATCH] tree-optimization: [PR108684] ICE in verify_ssa due to simple_dce_from_worklist Date: Wed, 8 Feb 2023 11:13:48 -0800 Message-ID: <20230208191348.1580462-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: gzdlNO7X0cSitj2yuGLWBu9ewI_Husc- X-Proofpoint-ORIG-GUID: gzdlNO7X0cSitj2yuGLWBu9ewI_Husc- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-08_09,2023-02-08_02,2022-06-22_01 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757291410745422450?= X-GMAIL-MSGID: =?utf-8?q?1757291410745422450?= In simple_dce_from_worklist, we were removing an inline-asm which had a vdef (due to clobbering memory) but not unlinking the statement's vdef. This fixes that oversight. This was a latent bug exposed recently by both VRP and removal of stores to static starting to use simple_dce_from_worklist. OK for trunk (and for GCC 12 after a week)? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/108684 gcc/ChangeLog: * tree-ssa-dce.cc (simple_dce_from_worklist): Call unlink_stmt_vdef on the statement before removing it. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/dce-inline-asm-1.c: New test. * gcc.c-torture/compile/dce-inline-asm-2.c: New test. co-authored-by: Andrew Macleod --- .../gcc.c-torture/compile/dce-inline-asm-1.c | 15 +++++++++++++++ .../gcc.c-torture/compile/dce-inline-asm-2.c | 16 ++++++++++++++++ gcc/tree-ssa-dce.cc | 1 + 3 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c create mode 100644 gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c diff --git a/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c new file mode 100644 index 00000000000..a9f02e44bd7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/108684 */ +/* This used to ICE as when we remove the store to + `t`, we also would remove the inline-asm which + had a VDEF on it but we didn't update the + VUSE that was later on. */ +static int t; + +int f (int *a) +{ + int t1; + asm (" " : "=X" (t1) : : "memory"); + t = t1; + return *a; +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c new file mode 100644 index 00000000000..a41b16e4bd0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/108684 */ +/* This used to ICE as when we removed the + __builtin_unreachable in VRP, as we + would also remove the branch and the + inline-asm. The inline-asm had a VDEF on it, + which we didn't update further along and + not have the VDEF on the return statement + updated. */ + +int f (int a) +{ + asm (" " : "=X" (a) : : "memory"); + if (a) + return 0; + __builtin_unreachable(); +} diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc index b2fe9f4f55e..752785541e4 100644 --- a/gcc/tree-ssa-dce.cc +++ b/gcc/tree-ssa-dce.cc @@ -2140,6 +2140,7 @@ simple_dce_from_worklist (bitmap worklist) remove_phi_node (&gsi, true); else { + unlink_stmt_vdef (t); gsi_remove (&gsi, true); release_defs (t); }