[llvm] [OMPIRBuilder] Avoid crash in BasicBlock::splice. (PR #154987)
Abid Qadeer via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 27 04:14:44 PDT 2025
abidh wrote:
> Thank you for the unittest, it helps me understand the issue.
>
> It seems that `spliceDebugInfoEmptyBlock` wants to move "trailing DbgRecords" to the last instruction of the destination block. Since it is degenerate, such last instruction does not exist.
>
> I think that `spliceDebugInfoEmptyBlock` is at fault here. If it wants to move "trailing DbgRecords" to an empty Dest, then it should append those DebugRecords also to the trailing DbgRecords of Dest (setTrailingDbgRecords).
I agree that `spliceDebugInfoEmptyBlock` probably needs to improve but we also have a `llvm::spliceBB` specific behavior that we want to preserve. If the unit test code was run with old debug info format, the `Old` block will look like this before `spliceBB` is called.
```
Old:
call void @llvm.dbg.declare(...)
```
The call to `spliceBB` would **not** move the `llvm.dbg.declare` into the `New` BasicBlock.
In the new scheme, there are no intrinsics so the the `Old` is empty but it has trailing debug records. We want those records to remain in the `Old` to match the debug information that get generated. So not calling `BasicBlock::splice` in this case seems the right thing to me.
https://github.com/llvm/llvm-project/pull/154987
More information about the llvm-commits
mailing list