On 5/11/2022 7:48 PM, Alexandre Oliva via Gcc-patches wrote:
There is an assumption in force_edge_cold that, if any edge out of the
same src block has uninitialized probability, then a conditional
branch out of src won't have REG_BR_PROB set.

This assumption is supposed to hold, but buggy gimple passes may turn
unconditional edges into conditional ones, adding edges with
uninitialized probability out of blocks that retain originally
unconditional edges with precise always probability.  Expand may then
copy the formerly-unconditional edge's probability to REG_BR_PROB, and
if that edge ends up forced cold, the probability in the edge will be
modified without adjusting the note, and rtl_verify_edges complains
about that.

This patch adds checking that REG_BR_PROB is absent to the path taken
by force_cold_edge for uninitialized probabilities, so that the
problem is caught earlier and fixed sooner.

I'm not sure it buys us much, but...  Regstrapped on x86_64-linux-gnu.
Ok to install?


for  gcc/ChangeLog

        * predict.cc (force_edge_cold): Check for no REG_BR_PROB in
        the uninitialized probability case.
Should that be a runtime test (flag_checking) rather than a compile/configure time test (#if CHECKING_P)?  I think we generally perfer the former these days.   If you strongly think it should be a #if CHECKING_P, that's fine.  I just want you to ponder if the runtime test is more appropriate or not and change if you think it's warranted.

OK either way.

Jeff


Reply via email to