As FastISel groups local values at the top of each block or after call
instructions and doesn't attach any debug location to them (it's
intentionally cleared to prevent jumping back and forth in debuggers),
the following situation is possible:
BB#0: .loc 1 2 3 call ... <constant load> .loc 1 5 6 ... BB#1: <constant load> .loc 1 3 4 ...
Here <constant load> in both cases "accidentally" gets wrong debug location
from the preceding set of instructions, which is wrong.
This patch adds basic block post-processing for FastISel, which will look for
first instruction with non-null debug location and assign the location to first
local value (if one exists), producing the following:
BB#0: .loc 1 2 3 call ... .loc 1 5 6 <constant load> ... BB#1: .loc 1 3 4 <constant load> .loc 1 3 4 ...
I don't see anything EH related in your test cases - is this exercised/verified? (perhaps without this existing tests regress? I'm not sure)