[llvm] [SandboxIR][NFC] Added getTopmostLLVMInstruction() where needed (PR #102266)
Julius Alexandre via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 20:23:48 PDT 2024
https://github.com/medievalghoul created https://github.com/llvm/llvm-project/pull/102266
`getTopmostLLVMInstruction()` was missing in a couple of places, this patch made sure to add them.
cc: @vporpo
>From dd4edb030481ec3f90ee19c25fd26e8a1401a033 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalghoul at users.noreply.github.com>
Date: Tue, 6 Aug 2024 23:18:33 -0400
Subject: [PATCH] [SandboxIR][NFC] Added getTopmostLLVMInstruction() where
needed
---
llvm/lib/SandboxIR/SandboxIR.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/SandboxIR/SandboxIR.cpp b/llvm/lib/SandboxIR/SandboxIR.cpp
index 00abee48821ff1..c2506eddfafcce 100644
--- a/llvm/lib/SandboxIR/SandboxIR.cpp
+++ b/llvm/lib/SandboxIR/SandboxIR.cpp
@@ -546,7 +546,8 @@ void SelectInst::dump() const {
BranchInst *BranchInst::create(BasicBlock *IfTrue, Instruction *InsertBefore,
Context &Ctx) {
auto &Builder = Ctx.getLLVMIRBuilder();
- Builder.SetInsertPoint(cast<llvm::Instruction>(InsertBefore->Val));
+ llvm::Instruction *LLVMBefore = InsertBefore->getTopmostLLVMInstruction();
+ Builder.SetInsertPoint(cast<llvm::Instruction>(LLVMBefore));
llvm::BranchInst *NewBr =
Builder.CreateBr(cast<llvm::BasicBlock>(IfTrue->Val));
return Ctx.createBranchInst(NewBr);
@@ -565,7 +566,8 @@ BranchInst *BranchInst::create(BasicBlock *IfTrue, BasicBlock *IfFalse,
Value *Cond, Instruction *InsertBefore,
Context &Ctx) {
auto &Builder = Ctx.getLLVMIRBuilder();
- Builder.SetInsertPoint(cast<llvm::Instruction>(InsertBefore->Val));
+ llvm::Instruction *LLVMBefore = InsertBefore->getTopmostLLVMInstruction();
+ Builder.SetInsertPoint(LLVMBefore);
llvm::BranchInst *NewBr =
Builder.CreateCondBr(Cond->Val, cast<llvm::BasicBlock>(IfTrue->Val),
cast<llvm::BasicBlock>(IfFalse->Val));
More information about the llvm-commits
mailing list