[llvm] [OMPIRBuilder] Avoid crash in BasicBlock::splice. (PR #154987)
Abid Qadeer via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 07:57:09 PDT 2025
abidh wrote:
> I don't follow what is happening. Why doesn't `BasicBlock::splitBasicBlock` (where `llvm::spliceBB` was inspired by) need this check?
>
> Can you add a unittest for illustration? I don't mean a translation from MLIR, but some IRBuilder-generated LLVM-IR on which `llvm::spliceBB` is called in `OpenMPIRBuilderTest.cpp`
The BasicBlock::splitBasicBlock already expects that BasicBlock being split is not empty. Please see the asserts [here](https://github.com/llvm/llvm-project/blob/445415219708f9539801018e03282049ca33e0e2/llvm/lib/IR/BasicBlock.cpp#L560) and [here](https://github.com/llvm/llvm-project/blob/445415219708f9539801018e03282049ca33e0e2/llvm/lib/IR/BasicBlock.cpp#L590).
I added a unit test that show the scenario where the spliceBB will crash without the change in this PR.
https://github.com/llvm/llvm-project/pull/154987
More information about the llvm-commits
mailing list