From patchwork Tue Sep 13 09:56:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 1181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp2270848wrt; Tue, 13 Sep 2022 02:57:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ijeKszQHdVUUsRBSIX6+W54H4Az6s+FXyuQb1eP+nDqNkkeTTRvpeUfuZZ8NZxGUKMWTA X-Received: by 2002:a05:6402:2213:b0:451:a711:13a9 with SMTP id cq19-20020a056402221300b00451a71113a9mr8762691edb.186.1663063056871; Tue, 13 Sep 2022 02:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663063056; cv=none; d=google.com; s=arc-20160816; b=LpNfSLATscNUGLsO7v1l44CiujfVzZq4dFVtlCvuzIyakMzL5DoyVTA9IC0U4/dqSw N9vx6YnuywdMNNnKDBRCa2Yt1lzuJt/C0IFj5dClZEVp0B0mTXVyImWbsB3uIobBEbmM NVvrPOrpT4Oan6cI9D3p86Qp+AM0d6FYzdZL5HEGIm9TJ/OFmsg+kpyZ8MQO3C9DI0oi 5plK9tI7fr/vh+j7qu2yj+ke4mPb7+hatFpOXUsrUr9dAnYa27/wQnmG9OqK3VbbOIml DhYKm2Wbv4QplF66ljeHpNHvJNzOzfhCr126f/ZLaVEdodFfDwWNmCw4ruoJ6orzIRid oZoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:thread-index :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=FGHWUn7xJQeiogz5qVGkZcOHHtsWvlVTi39eoEFYrfQ=; b=b6BagJXOFsf0qF84UOrnpL7uIU++CKIWD9FNfMRCsLfsGN3ns2wSIW+6uE62krdhzN +20Emv4T0/odscX9NMh/9oHEiEKW6RPAm8XRlcIrDp7LuCpw8xxMmICZfsN/qwJZdGWD WzJmMu6INMwgALMSJGRSBSOALeIlOG3apMm7Kcsa1PPfN6eWnXk/XaCp5PTx+rP10J3L /0KYrfvJO+o1M0mGTMdo+W7sPAA+DbPV7QcsfG5+eWjmb2Zml0TZGjOZyvQPjNQfsZRu cDgFjuXRGu/cRRJZyJet1V7FkFMm3KyTAYaim5ayONooM5AMzddWNUT0FuP90UE1h7Ow w8Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=s+rxarc8; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fj4-20020a1709069c8400b007799e328e10si9501193ejc.999.2022.09.13.02.57.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 02:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=s+rxarc8; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 981F138A8148 for ; Tue, 13 Sep 2022 09:57:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 1F71A384D171 for ; Tue, 13 Sep 2022 09:57:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F71A384D171 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FGHWUn7xJQeiogz5qVGkZcOHHtsWvlVTi39eoEFYrfQ=; b=s+rxarc8UcLkHGeTFMKsnyePgk o6XLwWuRKkBv2HkBGrayZIW5HkIt+Q4Mi3TQ4qMrEsQ0KFG7kQTQf2gF4ff6/JELvBvdy6bzlQEnI oOstAJKTp+64EVhuXVBBQO/qEB83BHTQ/L0B2QoCiRdTSTW0os4T0VCiIZuN7gNnRlIRfTDEBGrxr dgVzSx84Ud7Yqe7wGdgc5IC70lxY0SW+U/+1S4HMtcdWcQbsB6MHxrWZIGoSn6TKt8hDmKuiiEYVz qd14GyeVq59XcqhL+kDB3nO4XjVf1F2N1jY9Dg6cvvfUTxzl8BKyFwgSx9T8K2dBtFCGM1I7X6ad7 m61cO/+g==; Received: from host109-154-46-66.range109-154.btcentralplus.com ([109.154.46.66]:56202 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oY2f6-0001VV-Uq for gcc-patches@gcc.gnu.org; Tue, 13 Sep 2022 05:57:01 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] PR target/106877: Robustify reg-stack to malformed asm. Date: Tue, 13 Sep 2022 10:56:58 +0100 Message-ID: <020401d8c757$2af45f10$80dd1d30$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdjHVsH/26kNlEY6QUe+H2xoIBiL/g== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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: , 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?1743848007635180869?= X-GMAIL-MSGID: =?utf-8?q?1743848007635180869?= This patch resolves PR target/106877 an ICE-on-invalid inline-asm regression. An innocent upstream change means that the test case from PR inline-asm/84683 now hits a different assert in reg-stack.cc's move_for_stack_reg. Fixed by duplicating Jakub's solution to PR 84683 https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495193.html at this second (similar) gcc_assert. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32}, with no new failures. Ok for mainline? 2022-09-13 Roger Sayle gcc/ChangeLog PR target/106877 * reg-stack.cc (move_for_stack_reg): Check for any_malformed_asm in gcc_assert. gcc/testsuite/ChangeLog PR target/106877 * g++.dg/ext/pr106877.C: New test case. Thanks, Roger diff --git a/gcc/reg-stack.cc b/gcc/reg-stack.cc index fd03250..95e0e61 100644 --- a/gcc/reg-stack.cc +++ b/gcc/reg-stack.cc @@ -1073,7 +1073,8 @@ move_for_stack_reg (rtx_insn *insn, stack_ptr regstack, rtx pat) break; /* The destination must be dead, or life analysis is borked. */ - gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG); + gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG + || any_malformed_asm); /* If the source is not live, this is yet another case of uninitialized variables. Load up a NaN instead. */ diff --git a/gcc/testsuite/g++.dg/ext/pr106877.C b/gcc/testsuite/g++.dg/ext/pr106877.C new file mode 100644 index 0000000..6bffed9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr106877.C @@ -0,0 +1,13 @@ +// PR target/106877 +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-O1 -m16 -mtune=sandybridge -flive-range-shrinkage -fno-dce" } + +void +foo (float b, double c) +{ + for (int e = 0; e < 2; e++) + { + asm volatile ("" : "+f" (c)); // { dg-error "must specify a single register" } + asm ("" : "+rm" (c = b)); + } +}