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: 186296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1535813dyq; Tue, 9 Jan 2024 01:28:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCMRL38GPLqnO6rbnYAz9ejF4CSYMG8F9Ok4XAUp1zRa2Svfc0i1PK0Lx6kDWelAeZuIX0 X-Received: by 2002:ac8:59c1:0:b0:429:8cec:ec91 with SMTP id f1-20020ac859c1000000b004298cecec91mr4051813qtf.31.1704792495392; Tue, 09 Jan 2024 01:28:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704792495; cv=pass; d=google.com; s=arc-20160816; b=UfT0EMDD7O1O/siDjiAbnnonqT0+xE3ty6EfARfp3/g2D7C6KDXJLbnnpPEVxeagHS bx+XSjfJjHs8UUlDdLdLmo55nlCmGuzVdIxYrNL5CVv1xJFiVZ+VYvHF38tE+UTSg0uu w+C8bI5/vU13Zh4ejGotbJHV942brcKfrL1KAu7kNWt6J3xx7St6ry67CR/pgwIfLOUH bcUEX4y2K6NSbgzn5T7Vhc/gu4ZDrVGE6oJav84RSMLUONxNocb/IG6JZtv3cA6+K8ZD CbZC0t4fFr3LEL9i3ffLMsY03su116zEyb2QyDM/RdsQrdROblmYAguQep9DTM1EkrM6 ETyQ== 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=8nOQKVOCsx2PiIUsiTVaUxxfoQnBKY0VnynImhq+JK4=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=hVyvTGXzYJslMw36guYYI6jzvK4WmnUUo7OrhHAoO7B4y0dhyb/d+MfbLjuwyvtBjZ aoOfw31GvO7IVZ64KT+UF40C+e369cbktbKAFi++znlPSqScDXGkDLkwaaGgJ4N2rHBT iKh2e0MPO432YxhZAgm2wtwAGyoBGSIK0hOlLL/CiyDlQ/PUVh/ajdnkDs4jehqX5siy D+94SBKZtsaE0e1oZ+lLgxYyArden9O5yRiLJWOie0BDcBI/Hf/GrdE/Vl/brX1FOt4O zawhgJJS0RQZfFDJ8dfLivjNn2okNNQd4nV92gVk1Ew7S5TcuGVCRsZ4zgCzjS793tpm 09hg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=PjZCHOo9; 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 c5-20020ac87dc5000000b00429a91eb526si492780qte.177.2024.01.09.01.28.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:28:15 -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=PjZCHOo9; 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 13993385C6EE for ; Tue, 9 Jan 2024 09:28:15 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787604495594021739 X-GMAIL-MSGID: 1787604495594021739 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;