[llvm] [OMPIRBuilder] Avoid crash in BasicBlock::splice. (PR #154987)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 05:10:20 PDT 2025


Meinersbur wrote:

The changed behavior comes from the addition of "trailing DbgRecords" with the new scheme. If they are meant to stay at the beginning of the BB they should be called "leading DbgRecords". If the were meant to stay in the source BB then `BasicBlock::spliceBlock` should never move them. Not moving these the DbgRecords because `Old` and `New` both happen to be empty feels like an inconsistency. `spliceBB` will move them if the `New` block is not empty, and so does `llvm::SplitBlock`. Instead of using `spliceBB`, OpenMPIRBuilder often adds a temporary `UnrecheableInst` that eventually is removed again[^1] to cirvcumvent that `BasicBlock::splice`/`BasicBlock::split` do not work with degenerate blocks. This would move the trailing DbgRecords as well. 

[^1]: This is why I created `spliceBB`/`splitBB` in the first place, which unfortuntately seems to not have caught on

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


More information about the llvm-commits mailing list