From patchwork Tue Jan 9 09:27:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 83600 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 6C599385DC31 for ; Tue, 9 Jan 2024 09:27:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id ADF56385841D for ; Tue, 9 Jan 2024 09:27:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ADF56385841D 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 ADF56385841D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704792436; cv=none; b=thLH7ofZMsYkMxEOaLj6RR1gplt157vvl9+oLt/xucnr+VT7gHuPYdyAHO/+J1XkOOousOB6nofLEYgdHmLdVt5xkW99snoOAo0uwVnIKcbr37IB7vrPgneKq5dX9tRMERev/aruQqIX1jp4eggHlPg+eQpPQKcpbZF+IGiNc/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704792436; c=relaxed/simple; bh=q1kVyv4/B/wGS9ZoW169uj2+9IpeHwDPOOZlcPbYMm4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WY/GcglDhms9g63RXyuafpSuISQ7D5aZChwBpII+SbivVGtz4QULS/8ZfMHqjWO2IsNPpEVyTrBfHy4oPOakZ9B/wgoxJUcwZM23BOZkQPUP/oqhIOAvVzCLqWoC0Pl6O7Gkn/CAgpra5fmxbUFc9bIhy7GTyn7mxFqKpQYX9Bs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3376555b756so1398263f8f.0 for ; Tue, 09 Jan 2024 01:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1704792432; x=1705397232; 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=8nOQKVOCsx2PiIUsiTVaUxxfoQnBKY0VnynImhq+JK4=; b=PjZCHOo9dGvRSefNYfMB+5FC4NMEJ95tvL/C7GvMqpb1RUvQX75l2E5TWMcSc+z7ID BQ5uAfFmms9jUODvWGi4XYv/XYn2S531qskT6SIr8ikCHzmrj46B8zDipGprj+SxhnnC PZY8UJKfEJWx5VbPm7TN5qMLPabsl65YEJTYGavY5RcOOnHkftCxVAtpdBF/LbdDWeUq 0yaG7sDKgbI7ZbR7WhhPUCguP5v0uqVLKjJEHap5Cd/8HSiqOnchvAo6LohxKx4SbQgA gTC8PWX2ys/jNkO+RnSZ8Iu5IxcJ64fH9fC0Uq+mSC6mw3tpGzqk+119JFj09t0wEi36 yleQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704792432; x=1705397232; 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=8nOQKVOCsx2PiIUsiTVaUxxfoQnBKY0VnynImhq+JK4=; b=R3/pOQd+1R+uxu46KFsJZ2RzZMHWIkNPQoC3T1nGIGMfoMcp6QOYW9zFBgqhy0DwC7 zTFeaGYQSqyAAgUAYjdFzFavYPrHTpLKOZuN50YidUK2ybAvYEJ4NjrUJ40bgH0giw3R U6Zr/iYvZG90dptM407PXPPwaap/uDkFoyoIkXQkS9xkaI/yBs3jIJq9NCNrIoiVtNf9 RtPp5Mbd2PkaCY/OONdoeyXM/Rpafn4SKQYYs5/NCwyNP7rjuFaxiTFd6Q00EFkLF3ze tZDBvDJDoC9FT96AUUMZwesWk3Z/3DjyqlbU2HA4H5vZbPyMOJors+I0mOWTITyRZjnF Ez7g== X-Gm-Message-State: AOJu0YzzqnzVelACpOdXedRZ+9vDp9xlbwMF2g/fExbyJtQGOh4oL1SX wwymW1yqtbgOruWyYBTAuXfrSQd/GEFCSRHPM5jAMc+mYQ== X-Google-Smtp-Source: AGHT+IFoxHjhHX1PiNCo0xoFfZRYvAxJarb0I5quRn/gZodLnTYcFUP2Gg+NhcNT396a3pJO58NT/w== X-Received: by 2002:adf:e109:0:b0:336:d8c3:105b with SMTP id t9-20020adfe109000000b00336d8c3105bmr244300wrz.36.1704792432488; Tue, 09 Jan 2024 01:27:12 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id h16-20020a05600004d000b003367ff4aadasm1885927wri.31.2024.01.09.01.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:27:12 -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:27:10 +0100 Message-ID: <5902287.MhkbZ0Pkbq@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;