The following simplifies where we iterate to when TLS insertion figures
the current candidate block does not have a valid point for insertion
because there are live call clobbered regs at each point. Instead of
trying to be clever, computing a common dominator for the sets of
the hardregs, simply iterate to the immediate dominator. This does
not implement caching of blocks not deemed worthy for insertion,
this could be done as followup.
In particular a dominator of BB is BB itself which means for sets
of FLAGS_REG (of which there can be very many), we'd eventually
stop making progress (like in the testcase for the PR which iterates
from BB2 to BB2 endlessly), and we'd possibly iterate to a unnecessarily
far away block due to looking at all sets in the function.
Bootstrapped and tested (ontop of the earlier patch, otherwise we
ICE on the testcase as BB2 would not have been valid) on
x86_64-unknown-linux-gnu.
OK for trunk?
I do wonder if all this needs a failure mode? What prevents
BB2 with a cond-jump at the end and the CC setter before the
last REG_DEAD of an incoming argument? We also do not seem
to consider caller-saved registers becoming live during the
BB, like via asm(""). Only FLAGS_REG setters are tracked.
Thanks,
Richard.
PR target/123137
* config/i386/i386-features.cc (ix86_get_dominator_for_reg):
Remove.
(ix86_emit_tls_call): Iterate to the immediate dominator
instead of the nearest common dominator for all live
regs sets in the function.
---
gcc/config/i386/i386-features.cc | 48 ++++----------------------------
1 file changed, 6 insertions(+), 42 deletions(-)
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index a25f9c245d7..00f42f441e9 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3872,33 +3872,6 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns,
}
}
-/* Return the basic block which dominates all basic blocks which set
- hard register REGNO used in basic block BB. */
-
-static basic_block
-ix86_get_dominator_for_reg (unsigned int regno, basic_block bb)
-{
- basic_block set_bb;
- auto_bitmap set_bbs;
-
- /* Get all BBs which set REGNO and dominate the current BB from all
- DEFs of REGNO. */
- for (df_ref def = DF_REG_DEF_CHAIN (regno);
- def;
- def = DF_REF_NEXT_REG (def))
- if (!DF_REF_IS_ARTIFICIAL (def)
- && !DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER)
- && !DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
- {
- set_bb = DF_REF_BB (def);
- if (dominated_by_p (CDI_DOMINATORS, bb, set_bb))
- bitmap_set_bit (set_bbs, set_bb->index);
- }
-
- bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
- return bb;
-}
-
/* Mark FLAGS register as live in DATA, a bitmap of live caller-saved
registers, if DEST is FLAGS register. */
@@ -4047,10 +4020,9 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind,
basic_block bb,
|| !(LABEL_P (label) || SYMBOL_REF_P (label)))
gcc_unreachable ();
- /* Place the call before all FLAGS_REG setting BBs since
- we can't place a call before nor after a conditional
- jump. */
- bb = ix86_get_dominator_for_reg (FLAGS_REG, bb);
+ /* Continue searching since we can't place a call before nor
+ after a conditional jump. */
+ bb = get_immediate_dominator (CDI_DOMINATORS, bb);
/* Start over again. */
repeat = true;
@@ -4108,17 +4080,9 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind,
basic_block bb,
gcc_assert (!bitmap_empty_p (live_caller_saved_regs));
/* If any live caller-saved registers aren't dead at the end of
- this basic block, get the basic block which dominates all
- basic blocks which set the remaining live registers. */
- auto_bitmap set_bbs;
- bitmap_iterator bi;
- unsigned int id;
- EXECUTE_IF_SET_IN_BITMAP (live_caller_saved_regs, 0, id, bi)
- {
- basic_block set_bb = ix86_get_dominator_for_reg (id, bb);
- bitmap_set_bit (set_bbs, set_bb->index);
- }
- bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
+ this basic block, iterate to the immediate dominator as the
+ next possible place for insertion. */
+ bb = get_immediate_dominator (CDI_DOMINATORS, bb);
}
while (true);
}
--
2.51.0