From patchwork Tue Jan 9 09:16:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 186297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1535832dyq; Tue, 9 Jan 2024 01:28:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmn5SBC5SttjA+bfyjrwlSjwii4v9tt3AceDGPIkNSQU/excHzHwqilBjBQV9xAxiW10jR X-Received: by 2002:a05:620a:111b:b0:781:c142:8cd0 with SMTP id o27-20020a05620a111b00b00781c1428cd0mr5190469qkk.77.1704792497420; Tue, 09 Jan 2024 01:28:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704792497; cv=pass; d=google.com; s=arc-20160816; b=cgPbkyW85H4smsOuRSKoPh7gircZmQVORKMhDvzGlQY1uoJLgUE2xSWikBpdgL3YnU 3dnu6JvUrFwTGIh/VRXLC5lXSOiK0FTLUwf4i4Q5pXCkiqzoVsqr7f8RGtPeOjzZ23PS rCyVDEhSJpJoxABc5D52Kx6YJHb8WAS3FooKNupikDn+iG7KEbR8l5t2A6dMCLHNhE4+ xei/LWwWx9zZZZU7fwntvyJ1lhdG9fRCHulHYWl43YL4iDGTxpdigQMWrZTy4mEcb2Bd 8AkQnQQHn44gPoUeJRDLvch5HW0XNRrXKtuWMNyI7zY/Azrdu7yuWCMBa3IcPb8UALD3 XSrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=xwrrenu6SE5TO6147oy9BUFOD2tLnBSC/9O9RC9gUi0=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=ac6bT7/GXDJGksSM6i71nMAO1uqki5yni8lJ8VL3BvMEPBu/KYW4Y/8LBfaN9yUVVU AJppHvLGUc7G/UcJzBck2VV1pbGJvh5kwUmiPS9dUaCZRYE5DI7IGGi9dSpNBrGprxQF YLxtvVgFyG59x16U37uz4sMouGs4xa8wQCz6MEmHNp2J6rsUVf3LoMH0bhogydJQ1Zwx wj6oniJ9Ed/aV8AuPv5Q0qid0q5TawRwJldnNE73A0Os6yH9WYz/EPqMviNFaPx0yRgk yRyhvHrU3WtSebyCCCVkHchpx1wnzswvazQxElhw8ge+VRG1M+KIdumADLUBff29Pkxz zkEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=EoKeUKOP; arc=pass (i=1); 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"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x7-20020a05620a448700b007832549cf01si1677906qkp.643.2024.01.09.01.28.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:28:17 -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=pass header.i=@adacore.com header.s=google header.b=EoKeUKOP; arc=pass (i=1); 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"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B2967385E02A for ; Tue, 9 Jan 2024 09:28:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id AE0DD38582BD for ; Tue, 9 Jan 2024 09:26:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE0DD38582BD Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE0DD38582BD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704792410; cv=none; b=ONP30u7doGTExufoob6n76hQfAOtgXZr+x6BgIclgJNTTCyB3uEFC4AWDJfmOJr5MU/l74HqfFSLtoqdfrUxOOkXHYSXiFI/Ua5Y5zbSS2yvlehV0zDumecoj7q2PcbdYdESkRyxT7OWTBCi2AEuD+OiekV3O1syYc0EF4xoPbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704792410; c=relaxed/simple; bh=WVc6Zkb0MNz2tRiNRlG4BEYemI1s2lT2Mf+gK72cC0c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DKDaqzdJCuV8hbpmVqFkrS+s4kXUyhnTZGLEer+BV6QBMRQPCrjTF85GT+pfYKX+euSiFDV6tjV3TYDhz7R8el58SsKhS3Gxfq5A6aNapKxjFM0maIcee84D783aKFWi4U6p3yMxdxB/CamHw75CUO21O8Z16wjKJZmeAXFjuH0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40e4f1f519aso4201055e9.0 for ; Tue, 09 Jan 2024 01:26:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1704792402; x=1705397202; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=xwrrenu6SE5TO6147oy9BUFOD2tLnBSC/9O9RC9gUi0=; b=EoKeUKOPo4ORbMX6lwFogfdB+ToNkzNjmgfS3zj1hs/e78GL0HKh6qasNFxy9rDFcF i7DcrBcm/xOH5QBiRU5GuWQ9AiU1Df2pgkEjb5ezZ2THDeBTsjEJFFtjKByQC5jQNoHI IkxUvViwv8wb95RFw0bMDpJ73HJs8CGLuDrt94995JsIIw6p1nZUSB4TTnZ6A26HcNZL WwSX5RUU9ihrX4CwUdjOGDCyrEYur6bBRBY5VeC8QJ1M0ESB+TC2qz5kBROOSYTrn/WR gy/U3s2ChC+GOBwTeyTGIuu7UTog0HxXWQ9ivybyOWYQqzKwByYKXUDw0t5vl+gVNbBu 6+jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704792402; x=1705397202; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xwrrenu6SE5TO6147oy9BUFOD2tLnBSC/9O9RC9gUi0=; b=eg30d+1SoSg+oMpmX14/pM52wam7Bye3cpab7o4CuQWy6wve0OHXyCgbHaAzIKhqeN BdEtbbLOEfjG/Km2FFjD8VkxucSKCr7funDH+XIAgATLf6uoB08ShVvmmCLAcj9nIMM3 myWIto6sfUQLA05/6HLMaPDrhRkNOhzZRb85V+lF4UMyYCyRj8sQHp2evosN0CHpE1jN BmASz9ctDMZBJkVAz9TiIhVKWd3wGEghsK3Sn0grF6E66XkvW6JpjcbnLaT7lnoxNNzS 8zKOmRHyN0YAIczRIyimWJ4FcSgdooEbVwu0TT0m8+FQWNJdT3dLFXwsrz5iKQWQ9v+o u82w== X-Gm-Message-State: AOJu0YyKkPzY+zh9lTadRJknNcl+lZ/wN4zpyb1qX1uUxRKMUkY6yj58 Ov9Y85UtS9Cewg0i5BYSZe/JuxCUrICoLifAN2yUHSoOLA== X-Received: by 2002:a05:600c:4453:b0:40e:47df:3d18 with SMTP id v19-20020a05600c445300b0040e47df3d18mr1285694wmn.79.1704792402414; Tue, 09 Jan 2024 01:26:42 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id w5-20020a05600c474500b0040d7b340e07sm2767096wmo.45.2024.01.09.01.26.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:26:41 -0800 (PST) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR rtl-optimization/113140 Date: Tue, 09 Jan 2024 10:16:22 +0100 Message-ID: <3275505.44csPzL39Z@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787604495594021739 X-GMAIL-MSGID: 1787604498029474749 This is a small regression present on the mainline and 13 branch, although the underlying problem has probably been there for ages, in the form of a segfault during the delay slot scheduling pass, for a function that falls through to exit without any RTL instruction generated for the end of function. Tested on SPARC64/Linux, applied on the mainline and 13 branch. 2024-01-09 Eric Botcazou PR rtl-optimization/113140 * reorg.cc (fill_slots_from_thread): If we are to branch after the last instruction of the function, create an end label. 2024-01-09 Eric Botcazou * g++.dg/opt/delay-slot-2.C: New test. diff --git a/gcc/reorg.cc b/gcc/reorg.cc index e85af7134f4..99228a22c69 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -2641,7 +2641,8 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, arithmetic insn after the jump insn and put the arithmetic insn in the delay slot. If we can't do this, return. */ if (delay_list->is_empty () && likely - && new_thread && !ANY_RETURN_P (new_thread) + && new_thread + && !ANY_RETURN_P (new_thread) && NONJUMP_INSN_P (new_thread) && !RTX_FRAME_RELATED_P (new_thread) && GET_CODE (PATTERN (new_thread)) != ASM_INPUT @@ -2729,14 +2730,16 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, gcc_assert (thread_if_true); - if (new_thread && simplejump_or_return_p (new_thread) + if (new_thread + && simplejump_or_return_p (new_thread) && redirect_with_delay_list_safe_p (insn, JUMP_LABEL (new_thread), *delay_list)) - new_thread = follow_jumps (JUMP_LABEL (new_thread), insn, - &crossing); + new_thread = follow_jumps (JUMP_LABEL (new_thread), insn, &crossing); - if (ANY_RETURN_P (new_thread)) + if (!new_thread) + label = find_end_label (simple_return_rtx); + else if (ANY_RETURN_P (new_thread)) label = find_end_label (new_thread); else if (LABEL_P (new_thread)) label = new_thread;