From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 196593858406 for ; Sat, 9 Jul 2022 01:26:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 196593858406 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 268KSK5o010914 for ; Fri, 8 Jul 2022 18:26:40 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h635w62c5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 08 Jul 2022 18:26:40 -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; Fri, 8 Jul 2022 18:26:38 -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; Fri, 8 Jul 2022 18:26:38 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 5C5A43F706F; Fri, 8 Jul 2022 18:26:38 -0700 (PDT) From: To: CC: Andrew Pinski Subject: [COMMITTED] Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars Date: Fri, 8 Jul 2022 18:26:33 -0700 Message-ID: <1657329993-24376-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: X5nqOlr7rPD_VJ0-xSxcWLdgA3uNgnla X-Proofpoint-ORIG-GUID: X5nqOlr7rPD_VJ0-xSxcWLdgA3uNgnla 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_20,2022-07-08_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: Sat, 09 Jul 2022 01:26:42 -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. Committed as approved after a 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 | 7 +++++++ 2 files changed, 21 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..daf0782b0e1 100644 --- a/gcc/tree-ssa-dce.cc +++ b/gcc/tree-ssa-dce.cc @@ -2061,6 +2061,13 @@ simple_dce_from_worklist (bitmap worklist) if (gimple_has_side_effects (t)) continue; + /* The defining statement needs to be defining only this name. + ASM is the only statement that can define more than one + (non-virtual) 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