From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1012) id 61D343858D35; Fri, 16 Jun 2023 15:17:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61D343858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686928626; bh=ONIKdm67WS3YMpYPowHW5ZxRdukadJ94LlPHCv+wqRM=; h=From:To:Subject:Date:From; b=eGbWPkSytkmVD6tNLL/yHJVuJlS2P+x73doQAX5xSQ5RuQtOuIjqpD+m5g6BYAtHu QKb7DhzO8DkKr0nYzQX1Nvo05IP2WzDZchL3zsa+L3Z4ud7LgNPd778m1RBlpdn88M N80+QXIn4OEzgrtF++GNMiLNLEc7hD95etr3YNQA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Vladimir Makarov To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1891] RA: Ignore conflicts for some pseudos from insns throwing a final exception X-Act-Checkin: gcc X-Git-Author: Vladimir N. Makarov X-Git-Refname: refs/heads/master X-Git-Oldrev: b106f11dc6adb8df15cc5c268896d314c76ca35f X-Git-Newrev: 154c69039571c66b3a6d16ecfa9e6ff22942f59f Message-Id: <20230616151706.61D343858D35@sourceware.org> Date: Fri, 16 Jun 2023 15:17:06 +0000 (GMT) List-Id: https://gcc.gnu.org/g:154c69039571c66b3a6d16ecfa9e6ff22942f59f commit r14-1891-g154c69039571c66b3a6d16ecfa9e6ff22942f59f Author: Vladimir N. Makarov Date: Fri Jun 16 11:12:32 2023 -0400 RA: Ignore conflicts for some pseudos from insns throwing a final exception IRA adds conflicts to the pseudos from insns can throw exceptions internally even if the exception code is final for the function and the pseudo value is not used in the exception code. This results in spilling a pseudo in a loop (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110215). The following patch fixes the problem. PR rtl-optimization/110215 gcc/ChangeLog: * ira-lives.cc: Include except.h. (process_bb_node_lives): Ignore conflicts from cleanup exceptions when the pseudo does not live at the exception landing pad. Diff: --- gcc/ira-lives.cc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gcc/ira-lives.cc b/gcc/ira-lives.cc index 6a3901ee234..bc8493856a4 100644 --- a/gcc/ira-lives.cc +++ b/gcc/ira-lives.cc @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "ira-int.h" #include "sparseset.h" #include "function-abi.h" +#include "except.h" /* The code in this file is similar to one in global but the code works on the allocno basis and creates live ranges instead of @@ -1383,14 +1384,24 @@ process_bb_node_lives (ira_loop_tree_node_t loop_tree_node) SET_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj)); SET_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj)); } - if (can_throw_internal (insn)) + eh_region r; + eh_landing_pad lp; + rtx_code_label *landing_label; + basic_block landing_bb; + if (can_throw_internal (insn) + && (r = get_eh_region_from_rtx (insn)) != NULL + && (lp = gen_eh_landing_pad (r)) != NULL + && (landing_label = lp->landing_pad) != NULL + && (landing_bb = BLOCK_FOR_INSN (landing_label)) != NULL + && (r->type != ERT_CLEANUP + || bitmap_bit_p (df_get_live_in (landing_bb), + ALLOCNO_REGNO (a)))) { - OBJECT_CONFLICT_HARD_REGS (obj) - |= callee_abi.mode_clobbers (ALLOCNO_MODE (a)); - OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) - |= callee_abi.mode_clobbers (ALLOCNO_MODE (a)); + HARD_REG_SET new_conflict_regs + = callee_abi.mode_clobbers (ALLOCNO_MODE (a)); + OBJECT_CONFLICT_HARD_REGS (obj) |= new_conflict_regs; + OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) |= new_conflict_regs; } - if (sparseset_bit_p (allocnos_processed, num)) continue; sparseset_set_bit (allocnos_processed, num);