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: 1723605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com header.a=rsa-sha256 header.s=default header.b=IomK7joq; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NrPfl1qKdz23gB for ; Tue, 10 Jan 2023 06:49:49 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A7BE38582BC for ; Mon, 9 Jan 2023 19:49:47 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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; +} +