Skip to content

Commit 90e1c29

Browse files
[SandboxIR][NFC] Add missing getTopmostLLVMInstruction() (#102266)
`getTopmostLLVMInstruction()` was missing in a couple of places, this patch made sure to add them.
1 parent e546430 commit 90e1c29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/SandboxIR/SandboxIR.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ void SelectInst::dump() const {
546546
BranchInst *BranchInst::create(BasicBlock *IfTrue, Instruction *InsertBefore,
547547
Context &Ctx) {
548548
auto &Builder = Ctx.getLLVMIRBuilder();
549-
Builder.SetInsertPoint(cast<llvm::Instruction>(InsertBefore->Val));
549+
llvm::Instruction *LLVMBefore = InsertBefore->getTopmostLLVMInstruction();
550+
Builder.SetInsertPoint(cast<llvm::Instruction>(LLVMBefore));
550551
llvm::BranchInst *NewBr =
551552
Builder.CreateBr(cast<llvm::BasicBlock>(IfTrue->Val));
552553
return Ctx.createBranchInst(NewBr);
@@ -565,7 +566,8 @@ BranchInst *BranchInst::create(BasicBlock *IfTrue, BasicBlock *IfFalse,
565566
Value *Cond, Instruction *InsertBefore,
566567
Context &Ctx) {
567568
auto &Builder = Ctx.getLLVMIRBuilder();
568-
Builder.SetInsertPoint(cast<llvm::Instruction>(InsertBefore->Val));
569+
llvm::Instruction *LLVMBefore = InsertBefore->getTopmostLLVMInstruction();
570+
Builder.SetInsertPoint(LLVMBefore);
569571
llvm::BranchInst *NewBr =
570572
Builder.CreateCondBr(Cond->Val, cast<llvm::BasicBlock>(IfTrue->Val),
571573
cast<llvm::BasicBlock>(IfFalse->Val));

0 commit comments

Comments
 (0)