From patchwork Fri Nov 11 16:19:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 60428 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 408013858434 for ; Fri, 11 Nov 2022 16:20:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 408013858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668183627; bh=WfMFwjci58sGFbs5AfNBuCvwg9Kjcqbb8ie2ESWeAAg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rEL/dRpMQBFdcx83MuKD2WyYCfQ1+n1vlqn0nohVFPpEPn1+SlFQt5qETuWw1GbT7 G3CzbUywvqhbFgrOR5p5aAB2OJe5aA/i5o/zOOSDS+VSXGpsNXtGRD7PCna0gLn/6W SukfGoPzDYJhNORE2EMiLSMggkAOYmfVHGz/S8Co= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2AD9D3858D1E for ; Fri, 11 Nov 2022 16:19:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AD9D3858D1E Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CD1D41FB for ; Fri, 11 Nov 2022 08:20:04 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 44D283F73D for ; Fri, 11 Nov 2022 08:19:58 -0800 (PST) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] Handle epilogues that contain jumps Date: Fri, 11 Nov 2022 16:19:57 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-42.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, 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: , X-Patchwork-Original-From: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The prologue/epilogue pass allows the prologue sequence to contain jumps. The sequence is then partitioned into basic blocks using find_many_sub_basic_blocks. This patch treats epilogues in the same way. It's needed for a follow-on aarch64 patch that adds conditional code to both the prologue and the epilogue. Tested on aarch64-linux-gnu (including with a follow-on patch) and x86_64-linux-gnu. OK to install? Richard gcc/ * function.cc (thread_prologue_and_epilogue_insns): Handle epilogues that contain jumps. --- gcc/function.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/function.cc b/gcc/function.cc index d3da20ede7f..b54a1d81a3b 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -6136,6 +6136,11 @@ thread_prologue_and_epilogue_insns (void) && returnjump_p (BB_END (e->src))) e->flags &= ~EDGE_FALLTHRU; } + + auto_sbitmap blocks (last_basic_block_for_fn (cfun)); + bitmap_clear (blocks); + bitmap_set_bit (blocks, BLOCK_FOR_INSN (epilogue_seq)->index); + find_many_sub_basic_blocks (blocks); } else if (next_active_insn (BB_END (exit_fallthru_edge->src))) { @@ -6234,6 +6239,11 @@ thread_prologue_and_epilogue_insns (void) set_insn_locations (seq, epilogue_location); emit_insn_before (seq, insn); + + auto_sbitmap blocks (last_basic_block_for_fn (cfun)); + bitmap_clear (blocks); + bitmap_set_bit (blocks, BLOCK_FOR_INSN (insn)->index); + find_many_sub_basic_blocks (blocks); } }