[llvm] Instruction: avoid crash in getStableDebugLoc when `this` isn't a DbgInfoIntrinsic (PR #66266)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 14 04:26:26 PDT 2023


jmorse wrote:

Thanks for getting a patch together -- IMO it there's no next instruction, we should return an empty source location, i.e. `return DebugLoc();`. Presumably in a scenario where there are no debug-info intrinsics in the input, IRBuilder is inserting at end(), and thus doesn't have a source location to set on the inserted instructions? We should try fairly hard to ensure that we get the same source locations as when there are no debug intrinsics in the input.

I'm tempted to say that this isn't a legal use of IRBuilder because presumably the crashing input has no terminator instruction, however the whole point of IRBuilder is that it's dealing with incomplete/illegal basic blocks, and it'd be awkward to start making rules about different degrees of illegal blocks.

In terms of testing, would you be able to add another case to the "DebugLoc" test in `llvm/unittests/IR/IRBuilderTest.cpp`, I reckon inserting a dbg.label, erasing the terminator then creating another instruction at the dbg.label should cover this nicely.

https://github.com/llvm/llvm-project/pull/66266


More information about the llvm-commits mailing list