From patchwork Mon Feb 28 07:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 51423 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 471D93858038 for ; Mon, 28 Feb 2022 07:53:15 +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 8732F3858C83 for ; Mon, 28 Feb 2022 07:52:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8732F3858C83 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=pLysKlosoZ5BgYk74PTUi06D6M7fM4WbW3z9iYcdNY4=; b=CCSjpC6DhcgO47EDqrg0FFmMB3 zNp1wwHOPsYKEcjmqkRwkKwXrIbUQ84uIk95L4cRnlr8EeIO9Vq1TxVVVg54nSvlDoo4rJuLYyvhh 41tawvXJhmZ/38Ax78EY8G1gCoiE5XDsbZD/G6C7Y0RPdsZvfbFHZcV47AtTx+KslkzBLpYg33nh0 F1HP/MxN4XBVzjTprl2MqH4wJ2EnsUcIT//B+oY1WoYTk0IrSTWTbQIPktnfTe98qsaVKEifAOnuH TwLYm4+kzE7+BzeZ39LGn9Zo4Ef5dhB1lC8lxXagO/ceYF9qg/Jx8wdYdTIbecQ+eQY+PwXiFvSDE f8SqoUvA==; Received: from host86-186-213-42.range86-186.btcentralplus.com ([86.186.213.42]:55959 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nOaq1-0008Lx-Rk for gcc-patches@gcc.gnu.org; Mon, 28 Feb 2022 02:52:58 -0500 From: "Roger Sayle" To: Subject: [PATCH] PR c++/84964: Middle-end patch to expand_call for ICE after sorry. Date: Mon, 28 Feb 2022 07:52:56 -0000 Message-ID: <000901d82c78$33860b30$9a922190$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adgsd7LFQs6LqcUsQ0GWoPugGvf4Ag== 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.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch resolves PR c++/84964 which is an ICE in the middle-end after emitting a "sorry, unimplemented" message, and is a regression from earlier releases of GCC. This issue is that after encountering a function call requiring an unreasonable amount of stack space, the code continues and falls foul of an assert checking that stack pointer has been correctly updated. The fix is to (locally) consider aborted function calls as "no return", which skips this downstream sanity check. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check with no new failures. Ok for mainline? 2022-02-28 Roger Sayle gcc/ChangeLog PR c++/84964 * calls.cc (expand_call): Ignore stack adjustments after sorry. gcc/testsuite/ChangeLog PR c++/84964 * g++.dg/pr84964.C: New test case. Thanks in advance, Roger diff --git a/gcc/calls.cc b/gcc/calls.cc index e64a937..d4ee015 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -3447,6 +3447,8 @@ expand_call (tree exp, rtx target, int ignore) >= (1 << (HOST_BITS_PER_INT - 2))) { sorry ("passing too large argument on stack"); + /* Don't worry about stack clean-up. */ + flags |= ECF_NORETURN; continue; } diff --git a/gcc/testsuite/g++.dg/pr84964.C b/gcc/testsuite/g++.dg/pr84964.C new file mode 100644 index 0000000..1d0ff20 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr84964.C @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct a { + short b : -1ULL; // { dg-warning "exceeds its type" } +}; +void c(...) { c(a()); } // { dg-message "sorry, unimplemented" } +