From patchwork Mon Jan 9 19:49:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 41084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2347143wrt; Mon, 9 Jan 2023 11:50:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXvjHtVkp5LaWYpkfRKiFvwd2BM1a/PTb9McmFOs3OpZmnwXla2MhJC0EB/cD6weyCintsy1 X-Received: by 2002:a17:906:f282:b0:84d:16d0:717 with SMTP id gu2-20020a170906f28200b0084d16d00717mr12071461ejb.65.1673293804669; Mon, 09 Jan 2023 11:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673293804; cv=none; d=google.com; s=arc-20160816; b=Mb9yh8JidZXikQlco2TsBTstiv5e0WZq1UDLpyFOOa1Sgi/Uvn7RCYIwXSzrAtfGZc ARbtswVO8WXbbI/Cc9mt5ujhUYG3NVOdJHCa8GTeY3uIx5naQh9lOIZGUR1dorfehiFk G/bnxGsFPiHDsDauccB1TlYoO6iEobmquvRQ0UfBhF6do1v8OSXV7PpCoMoXI63tWI3a hlAYMzQxmFcN8vJZjn3gZWO06WVc2EzZohwqeGprSRwgWVBkDFiZRUCQp7NNqGhtKjdj Ii7zcP2y3OU+VIJg27aBoJ8+ahnKWRVdZOALqNbCtXiKjy7OCvoXzZZjIp6lYi7UlZS0 gXgA== 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=ej6k90WmH1DDAToRUQh3AkLzovbSQAwmUhHtRQD5R3M=; b=AtSlbMakd8piTIjnKTMK4FiHL6IBnL9pbkguXNr8zGcVy5kdmZ2uxms9cJIjhegH1P mBvymLqqHU7MUQ6ldQ1qxn3rYrkGeUpTGthB74tzj8WyfXx68zt3/9wMULJn6zq+UGEE QlsxgB9daTwoh1tuL4csBLgsuY0arieE8RZPR9Mmd09pWmKRiHpk/bt8zSteWfBO2kyO /R/XmrynyM0Tuc0ytn6KUB9Vd9/eRAwrzJb/0IZW1P8sSFWrTY4yFTPipqBts5ucJFra UUOPZjMeHbzSoA5UA+KYKynor5HD56JUbDfVpBhBEAWLfse4Bya1tmsnWLTMDjD3UzCo woAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=IomK7joq; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dd16-20020a1709069b9000b0084d4707b516si3704929ejc.851.2023.01.09.11.50.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 11:50:04 -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=fail header.i=@nextmovesoftware.com header.s=default header.b=IomK7joq; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77C39385843D for ; Mon, 9 Jan 2023 19:49:59 +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 6B65D3858D37 for ; Mon, 9 Jan 2023 19:49:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B65D3858D37 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=ej6k90WmH1DDAToRUQh3AkLzovbSQAwmUhHtRQD5R3M=; b=IomK7joqtNa5ulAMUqu5oCKBAM THLeId+voLCBuSdkA+0d4TV7dhQknQwt4qMlKyJXU6Z6GE0wnSGUHAymvwfqS+B2Z5xo09cHmfmEL +ZaeWHx4FaLyVZZpZdnvanIGBYzyTti9p0/7dJ7KR0vz1NqxoVU2+X5TMIIOGAuePYLEMUMq+Iv2E l7/7e4/PVj/y2KyTKlvbooCcnOqWTLTVBlI2e/q26L7kPe44wTdt2EQw/3emEsnVt558jV6fAQ9Gi XKUzzYdyrmC+FCzA/Dib2AZ0+MmMl0pf8QOBoAx0B8FBfDrw4eFyvgxDDBbLOSVEFUDvUFHEgyR0B tUvy3T+Q==; Received: from host86-163-35-31.range86-163.btcentralplus.com ([86.163.35.31]:53116 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 1pEy9F-0002SF-5F for gcc-patches@gcc.gnu.org; Mon, 09 Jan 2023 14:49:33 -0500 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] PR rtl-optimization/106421: ICE in bypass_block from non-local goto. Date: Mon, 9 Jan 2023 19:49:31 -0000 Message-ID: <004e01d92463$7eca2700$7c5e7500$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdkkYylHuBlQ3uDMSSyWKzXDSmsVUg== 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.0 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 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?1754575724602098846?= X-GMAIL-MSGID: =?utf-8?q?1754575724602098846?= This patch fixes PR rtl-optimization/106421, an ICE-on-valid (but undefined) regression. The fix, as proposed by Richard Biener, is to defend against BLOCK_FOR_INSN returning NULL in cprop's bypass_block. 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? 2023-01-09 Roger Sayle gcc/ChangeLog PR rtl-optimization/106421 * cprop.cc (bypass_block): Check that DEST is local to this function (non-NULL) before calling find_edge. gcc/testsuite/ChangeLog PR rtl-optimization/106421 * gcc.dg/pr106421.c: New test case. Thanks in advance, Roger diff --git a/gcc/cprop.cc b/gcc/cprop.cc index 5b203ec..6ec0bda 100644 --- a/gcc/cprop.cc +++ b/gcc/cprop.cc @@ -1622,9 +1622,12 @@ bypass_block (basic_block bb, rtx_insn *setcc, rtx_insn *jump) { dest = BLOCK_FOR_INSN (XEXP (new_rtx, 0)); /* Don't bypass edges containing instructions. */ - edest = find_edge (bb, dest); - if (edest && edest->insns.r) - dest = NULL; + if (dest) + { + edest = find_edge (bb, dest); + if (edest && edest->insns.r) + dest = NULL; + } } else dest = NULL; diff --git a/gcc/testsuite/gcc.dg/pr106421.c b/gcc/testsuite/gcc.dg/pr106421.c new file mode 100644 index 0000000..73e522a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106421.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int main(int argc, char **argv) +{ + __label__ loop, end; + void jmp(int c) { goto *(c ? &&loop : &&end); } +loop: + jmp(argc < 0); +end: + return 0; +} +