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: 83601 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 BA19D385DC27 for ; Tue, 9 Jan 2024 09:27:59 +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-Google-Smtp-Source: AGHT+IGlrVcosF9uipkuloMdEEd2siykgjE0LnjXFgS2RItFk/8oi8AUqgMfFYPnQIaqDGIhCpWNfA== 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+patchwork=sourceware.org@gcc.gnu.org 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;