From patchwork Thu Nov 11 15:32:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix var-tracking ICE (PR debug/46387) Date: Thu, 11 Nov 2010 05:32:28 -0000 From: Alexander Monakov X-Patchwork-Id: 70825 Message-Id: To: Richard Guenther Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org Jakub, Richard, This is what we need from the selective scheduler side (the part of the sel-sched.c patch actually needs to be more complicated to work properly, but the alias.c change is what we have in mind to fix PR45652). Thanks for your help. diff --git a/gcc/alias.c b/gcc/alias.c index 2e0ac06..0e65d66 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1291,6 +1291,27 @@ record_set (rtx dest, const_rtx set, void *data ATTRIBUTE_UNUSED) reg_seen[regno] = 1; } +/* Set REG_BASE_VALUE of DEST to that of SRC if unset, + or set it to NULL if DEST and SRC have conflicting REG_BASE_VALUEs. */ +void +inherit_reg_base_value (rtx dest, rtx src) +{ + unsigned dest_regno = REGNO (dest), src_regno = REGNO (src); + + if (! VEC_index (rtx, reg_base_value, dest_regno)) + { + if (!reg_seen[dest_regno] + && (dest_regno >= FIRST_PSEUDO_REGISTER || !fixed_regs[dest_regno])) + VEC_replace (rtx, reg_base_value, dest_regno, + VEC_index (rtx, reg_base_value, src_regno)); + } + else if (VEC_index (rtx, reg_base_value, src_regno) + != VEC_index (rtx, reg_base_value, dest_regno)) + VEC_replace (rtx, reg_base_value, dest_regno, NULL_RTX); + + reg_seen[dest_regno] = 1; +} + /* If a value is known for REGNO, return it. */ rtx @@ -2901,14 +2922,14 @@ init_alias_analysis (void) /* Clean up. */ free (new_reg_base_value); new_reg_base_value = 0; - free (reg_seen); - reg_seen = 0; timevar_pop (TV_ALIAS_ANALYSIS); } void end_alias_analysis (void) { + free (reg_seen); + reg_seen = 0; old_reg_base_value = reg_base_value; ggc_free (reg_known_value); reg_known_value = 0; diff --git a/gcc/rtl.h b/gcc/rtl.h index 3e1df2c..8cc6c5c 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2508,6 +2508,7 @@ extern rtx find_base_term (rtx); extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int); extern rtx get_reg_known_value (unsigned int); extern bool get_reg_known_equiv_p (unsigned int); +extern void inherit_reg_base_value (rtx, rtx); #ifdef STACK_REGS extern int stack_regs_mentioned (const_rtx insn); diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index 70e831d..ab7c708 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -5856,6 +5856,7 @@ maybe_emit_renaming_copy (rtx insn, insn); EXPR_SPEC_DONE_DS (INSN_EXPR (reg_move_insn)) = 0; replace_dest_with_reg_in_expr (params->c_expr, params->dest); + inherit_reg_base_value (params->dest, cur_reg); insn_emitted = true; params->was_renamed = true;