[llvm-dev] DebugLoc info is invalid after pass 'simplifycfg'
Jeremy Morse via llvm-dev
llvm-dev at lists.llvm.org
Wed Apr 24 03:38:28 PDT 2019
Hi Fangqing,
On Wed, Apr 24, 2019 at 12:14 AM Fangqing Du via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I'm not sure it's a bug or not.
> After pass 'simplifycfg', some DebugLoc info is changed, and become invalid.
> I use the bugpoint to reduce the case, and paste it here:
[...]
> And after pass 'simplifycfg', the DebugLoc info attached to the call instruction will be changed into '!7 = !DILocation(line: 0, scope: !3)', which is invalid.
The use of a zero line number here is deliberate, as implemented by
getMergedLocation [0]. It signifies that the location is compiler
generated, and doesn't correspond to a specific line number in the
original program.
> So can we just keep the original DebugLoc info for the call instruction?
SimplifyCFG is merging two call instructions into one -- however they
have two different DebugLocs, so we would have to pick one of them. If
a debugger then breaks on that call instruction, the line number will
suggest to the developer that the branch condition was either true or
false, which would be misleading because the call instruction now
executes regardless of the branch condition. Using a zero line number
avoids misleading the developer; it isn't ideal, but avoids mistruths.
[0] https://github.com/llvm/llvm-project/blob/4e6b8579221c67b83901bcc621d330e7e99a9294/llvm/lib/IR/DebugInfoMetadata.cpp#L75
--
Thanks,
Jeremy
More information about the llvm-dev
mailing list