From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 4E5823850204 for ; Fri, 8 Jul 2022 04:32:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E5823850204 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2681tIH3031273 for ; Thu, 7 Jul 2022 21:32:53 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3h6bay8dvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 07 Jul 2022 21:32:53 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jul 2022 21:32:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 7 Jul 2022 21:32:51 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id A29463F7074; Thu, 7 Jul 2022 21:32:47 -0700 (PDT) From: To: CC: Andrew Pinski Subject: [PATCH] Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars Date: Thu, 7 Jul 2022 21:32:15 -0700 Message-ID: <1657254735-24296-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: LkIgUKU90BQeXs_2ocCIhypAWCDanrRD X-Proofpoint-ORIG-GUID: LkIgUKU90BQeXs_2ocCIhypAWCDanrRD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-08_02,2022-06-28_01,2022-06-22_01 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Fri, 08 Jul 2022 04:32:56 -0000 From: Andrew Pinski The problem here is that when we mark the ssa name that was referenced in the now removed dead store (to a write only static variable), the inline-asm would also be removed even though it was defining another ssa name. This fixes the problem by checking to make sure that the statement was only defining one ssa name. OK? Bootstrapped and tested on x86_64 with no regressions. PR tree-optimization/106087 gcc/ChangeLog: * tree-ssa-dce.cc (simple_dce_from_worklist): Check to make sure the statement is only defining one operand. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/inline-asm-1.c: New test. --- gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c | 14 ++++++++++++++ gcc/tree-ssa-dce.cc | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c diff --git a/gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c b/gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c new file mode 100644 index 00000000000..0044cb761b6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/inline-asm-1.c @@ -0,0 +1,14 @@ +/* PR tree-opt/106087, + simple_dce_from_worklist would delete the + inline-asm when it was still being referenced + by the other ssa name. */ + +static int t; + +int f(void) +{ + int tt, tt1; + asm("":"=r"(tt), "=r"(tt1)); + t = tt1; + return tt; +} diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc index bc533582673..602cdb30ceb 100644 --- a/gcc/tree-ssa-dce.cc +++ b/gcc/tree-ssa-dce.cc @@ -2061,6 +2061,11 @@ simple_dce_from_worklist (bitmap worklist) if (gimple_has_side_effects (t)) continue; + /* The defining statement needs to be defining one this name. */ + if (!is_a(t) + && !single_ssa_def_operand (t, SSA_OP_DEF)) + continue; + /* Don't remove statements that are needed for non-call eh to work. */ if (stmt_unremovable_because_of_non_call_eh_p (cfun, t)) -- 2.17.1