From patchwork Tue May 21 09:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1937308 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vk7l04vYJz1ynR for ; Tue, 21 May 2024 19:03:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BF6DC3858C39 for ; Tue, 21 May 2024 09:03:21 +0000 (GMT) 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 3E0923858CD1 for ; Tue, 21 May 2024 09:02:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E0923858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3E0923858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716282167; cv=none; b=EXl/kYA9uy9HqAIoT/lJqmx1MHhz9xSiJxrFw2zUYjDvo6VEcpDMuE69sn2+WEp0xbl4sXBMQjBHer9h/ANu/UDPePMZVvuY83AyjwtNl3EsPHQJemIlS6/zGPp2Veql+HvHorSw1kvdUTNAdZiaYXWaQ8JyS8KLvjuNrdOpoBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716282167; c=relaxed/simple; bh=C/g88B09s3lZRq15yJhsSOZFyHv7frzYhOaHMeee99Y=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ZUBPfSh7o0dTvW7nz58Lvb9/VdbhqXxjUtf7i5oRA6s6tP3QQLYVGJYp39j+2D4Ah2BSKJZk4oPx2CraRgUWYwZwjwZQKdpfZ+UwhdX086yNEue05yMiFYdnOQb9NchkQVcavnM466ZoXu44YYFjRnb4Cj3BOzQNFBnARaUfbu8= ARC-Authentication-Results: i=1; server2.sourceware.org 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 AA23ADA7 for ; Tue, 21 May 2024 02:03:00 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 522E13F641 for ; Tue, 21 May 2024 02:02:36 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] Cache the set of EH_RETURN_DATA_REGNOs Date: Tue, 21 May 2024 10:02:35 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-20.4 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org While reviewing Andrew's fix for PR114843, it seemed like it would be convenient to have a HARD_REG_SET of EH_RETURN_DATA_REGNOs. This patch adds one and uses it to simplify a couple of use sites. Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? Richard gcc/ * hard-reg-set.h (target_hard_regs::x_eh_return_data_regs): New field. (eh_return_data_regs): New macro. * reginfo.cc (init_reg_sets_1): Initialize x_eh_return_data_regs. * df-scan.cc (df_get_exit_block_use_set): Use it. * ira-lives.cc (process_out_of_region_eh_regs): Likewise. --- gcc/df-scan.cc | 8 +------- gcc/hard-reg-set.h | 5 +++++ gcc/ira-lives.cc | 10 ++-------- gcc/reginfo.cc | 10 ++++++++++ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gcc/df-scan.cc b/gcc/df-scan.cc index 1bade2cd71e..c8ab3c09cee 100644 --- a/gcc/df-scan.cc +++ b/gcc/df-scan.cc @@ -3702,13 +3702,7 @@ df_get_exit_block_use_set (bitmap exit_block_uses) /* Mark the registers that will contain data for the handler. */ if (reload_completed && crtl->calls_eh_return) - for (i = 0; ; ++i) - { - unsigned regno = EH_RETURN_DATA_REGNO (i); - if (regno == INVALID_REGNUM) - break; - bitmap_set_bit (exit_block_uses, regno); - } + IOR_REG_SET_HRS (exit_block_uses, eh_return_data_regs); #ifdef EH_RETURN_STACKADJ_RTX if ((!targetm.have_epilogue () || ! epilogue_completed) diff --git a/gcc/hard-reg-set.h b/gcc/hard-reg-set.h index 8c1d1512ca2..340eb425c10 100644 --- a/gcc/hard-reg-set.h +++ b/gcc/hard-reg-set.h @@ -421,6 +421,9 @@ struct target_hard_regs { with the local stack frame are safe, but scant others. */ HARD_REG_SET x_regs_invalidated_by_call; + /* The set of registers that are used by EH_RETURN_DATA_REGNO. */ + HARD_REG_SET x_eh_return_data_regs; + /* Table of register numbers in the order in which to try to use them. */ int x_reg_alloc_order[FIRST_PSEUDO_REGISTER]; @@ -485,6 +488,8 @@ extern struct target_hard_regs *this_target_hard_regs; #define call_used_or_fixed_regs \ (regs_invalidated_by_call | fixed_reg_set) #endif +#define eh_return_data_regs \ + (this_target_hard_regs->x_eh_return_data_regs) #define reg_alloc_order \ (this_target_hard_regs->x_reg_alloc_order) #define inv_reg_alloc_order \ diff --git a/gcc/ira-lives.cc b/gcc/ira-lives.cc index e07d3dc3e89..958eabb9708 100644 --- a/gcc/ira-lives.cc +++ b/gcc/ira-lives.cc @@ -1260,14 +1260,8 @@ process_out_of_region_eh_regs (basic_block bb) for (int n = ALLOCNO_NUM_OBJECTS (a) - 1; n >= 0; n--) { ira_object_t obj = ALLOCNO_OBJECT (a, n); - for (int k = 0; ; k++) - { - unsigned int regno = EH_RETURN_DATA_REGNO (k); - if (regno == INVALID_REGNUM) - break; - SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno); - SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), regno); - } + OBJECT_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs; + OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs; } } } diff --git a/gcc/reginfo.cc b/gcc/reginfo.cc index a0baeb90e12..73121365c47 100644 --- a/gcc/reginfo.cc +++ b/gcc/reginfo.cc @@ -420,6 +420,16 @@ init_reg_sets_1 (void) } } + /* Recalculate eh_return_data_regs. */ + CLEAR_HARD_REG_SET (eh_return_data_regs); + for (i = 0; ; ++i) + { + unsigned int regno = EH_RETURN_DATA_REGNO (i); + if (regno == INVALID_REGNUM) + break; + SET_HARD_REG_BIT (eh_return_data_regs, regno); + } + memset (have_regs_of_mode, 0, sizeof (have_regs_of_mode)); memset (contains_reg_of_mode, 0, sizeof (contains_reg_of_mode)); for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++)