This is a regression present on the mainline in the form of -fcompare-debug
failure at -O3 on a compiler-generated testcase. Fixed by disregarding a
debug statement in the last position of a basic block to reset the current
location for the outgoing edges.
gcc/
PR middle-end/102764
* cfgexpand.c (expand_gimple_basic_block): Disregard a final debug
statement to reset the current location for the outgoing edges.