[llvm] 4f3a095 - [SandboxIR] Switch more Instruction::create() to InsertPosition (#111187)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 13:30:56 PDT 2024
Author: vporpo
Date: 2024-10-04T13:30:53-07:00
New Revision: 4f3a0959d62c81146a02dab80f761ccb921291e6
URL: https://github.com/llvm/llvm-project/commit/4f3a0959d62c81146a02dab80f761ccb921291e6
DIFF: https://github.com/llvm/llvm-project/commit/4f3a0959d62c81146a02dab80f761ccb921291e6.diff
LOG: [SandboxIR] Switch more Instruction::create() to InsertPosition (#111187)
Added:
Modified:
llvm/include/llvm/SandboxIR/Instruction.h
llvm/lib/SandboxIR/Instruction.cpp
llvm/unittests/SandboxIR/SandboxIRTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/SandboxIR/Instruction.h b/llvm/include/llvm/SandboxIR/Instruction.h
index a6dc0dbcdfc284..82356f282e141c 100644
--- a/llvm/include/llvm/SandboxIR/Instruction.h
+++ b/llvm/include/llvm/SandboxIR/Instruction.h
@@ -1619,8 +1619,7 @@ class CatchReturnInst
public:
static CatchReturnInst *create(CatchPadInst *CatchPad, BasicBlock *BB,
- BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx);
+ InsertPosition Pos, Context &Ctx);
CatchPadInst *getCatchPad() const;
void setCatchPad(CatchPadInst *CatchPad);
BasicBlock *getSuccessor() const;
@@ -1643,8 +1642,8 @@ class CleanupReturnInst
public:
static CleanupReturnInst *create(CleanupPadInst *CleanupPad,
- BasicBlock *UnwindBB, BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx);
+ BasicBlock *UnwindBB, InsertPosition Pos,
+ Context &Ctx);
bool hasUnwindDest() const {
return cast<llvm::CleanupReturnInst>(Val)->hasUnwindDest();
}
@@ -1678,13 +1677,7 @@ class GetElementPtrInst final
public:
static Value *create(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
- BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx,
- const Twine &NameStr = "");
- static Value *create(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &NameStr = "");
- static Value *create(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
- BasicBlock *InsertAtEnd, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
const Twine &NameStr = "");
static bool classof(const Value *From) {
@@ -1756,9 +1749,8 @@ class CatchSwitchInst
CSI, Ctx) {}
static CatchSwitchInst *create(Value *ParentPad, BasicBlock *UnwindBB,
- unsigned NumHandlers, BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
- const Twine &Name = "");
+ unsigned NumHandlers, InsertPosition Pos,
+ Context &Ctx, const Twine &Name = "");
Value *getParentPad() const;
void setParentPad(Value *ParentPad);
@@ -1844,8 +1836,7 @@ class ResumeInst : public SingleLLVMInstructionImpl<llvm::ResumeInst> {
ResumeInst(llvm::ResumeInst *CSI, Context &Ctx)
: SingleLLVMInstructionImpl(ClassID::Resume, Opcode::Resume, CSI, Ctx) {}
- static ResumeInst *create(Value *Exn, BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx);
+ static ResumeInst *create(Value *Exn, InsertPosition Pos, Context &Ctx);
Value *getValue() const;
unsigned getNumSuccessors() const {
return cast<llvm::ResumeInst>(Val)->getNumSuccessors();
@@ -1864,8 +1855,8 @@ class SwitchInst : public SingleLLVMInstructionImpl<llvm::SwitchInst> {
llvm::SwitchInst::DefaultPseudoIndex;
static SwitchInst *create(Value *V, BasicBlock *Dest, unsigned NumCases,
- BasicBlock::iterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx, const Twine &Name = "");
+ InsertPosition Pos, Context &Ctx,
+ const Twine &Name = "");
Value *getCondition() const;
void setCondition(Value *V);
@@ -1955,25 +1946,10 @@ class UnaryOperator : public UnaryInstruction {
Ctx) {}
friend Context; // for constructor.
public:
- static Value *create(Instruction::Opcode Op, Value *OpV, BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
- const Twine &Name = "");
- static Value *create(Instruction::Opcode Op, Value *OpV,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &Name = "");
- static Value *create(Instruction::Opcode Op, Value *OpV,
- BasicBlock *InsertAtEnd, Context &Ctx,
- const Twine &Name = "");
- static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *OpV,
- Value *CopyFrom, BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
- const Twine &Name = "");
- static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *OpV,
- Value *CopyFrom,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &Name = "");
+ static Value *create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos,
+ Context &Ctx, const Twine &Name = "");
static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *OpV,
- Value *CopyFrom, BasicBlock *InsertAtEnd,
+ Value *CopyFrom, InsertPosition Pos,
Context &Ctx, const Twine &Name = "");
/// For isa/dyn_cast.
static bool classof(const Value *From) {
@@ -2034,26 +2010,12 @@ class BinaryOperator : public SingleLLVMInstructionImpl<llvm::BinaryOperator> {
public:
static Value *create(Instruction::Opcode Op, Value *LHS, Value *RHS,
- BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx,
- const Twine &Name = "");
- static Value *create(Instruction::Opcode Op, Value *LHS, Value *RHS,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &Name = "");
- static Value *create(Instruction::Opcode Op, Value *LHS, Value *RHS,
- BasicBlock *InsertAtEnd, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
const Twine &Name = "");
static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *LHS,
Value *RHS, Value *CopyFrom,
- BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx, const Twine &Name = "");
- static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *LHS,
- Value *RHS, Value *CopyFrom,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &Name = "");
- static Value *createWithCopiedFlags(Instruction::Opcode Op, Value *LHS,
- Value *RHS, Value *CopyFrom,
- BasicBlock *InsertAtEnd, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
const Twine &Name = "");
/// For isa/dyn_cast.
static bool classof(const Value *From) {
@@ -2133,18 +2095,7 @@ class AtomicRMWInst : public SingleLLVMInstructionImpl<llvm::AtomicRMWInst> {
static AtomicRMWInst *create(BinOp Op, Value *Ptr, Value *Val,
MaybeAlign Align, AtomicOrdering Ordering,
- BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx,
- SyncScope::ID SSID = SyncScope::System,
- const Twine &Name = "");
- static AtomicRMWInst *create(BinOp Op, Value *Ptr, Value *Val,
- MaybeAlign Align, AtomicOrdering Ordering,
- Instruction *InsertBefore, Context &Ctx,
- SyncScope::ID SSID = SyncScope::System,
- const Twine &Name = "");
- static AtomicRMWInst *create(BinOp Op, Value *Ptr, Value *Val,
- MaybeAlign Align, AtomicOrdering Ordering,
- BasicBlock *InsertAtEnd, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
SyncScope::ID SSID = SyncScope::System,
const Twine &Name = "");
};
diff --git a/llvm/lib/SandboxIR/Instruction.cpp b/llvm/lib/SandboxIR/Instruction.cpp
index 78118613edb3c4..4fe1f54d3ec623 100644
--- a/llvm/lib/SandboxIR/Instruction.cpp
+++ b/llvm/lib/SandboxIR/Instruction.cpp
@@ -708,13 +708,8 @@ CleanupPadInst *CleanupPadInst::create(Value *ParentPad, ArrayRef<Value *> Args,
}
CatchReturnInst *CatchReturnInst::create(CatchPadInst *CatchPad, BasicBlock *BB,
- BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt != WhereBB->end())
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
- else
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ InsertPosition Pos, Context &Ctx) {
+ auto &Builder = setInsertPos(Pos);
llvm::CatchReturnInst *LLVMI = Builder.CreateCatchRet(
cast<llvm::CatchPadInst>(CatchPad->Val), cast<llvm::BasicBlock>(BB->Val));
return Ctx.createCatchReturnInst(LLVMI);
@@ -753,14 +748,8 @@ Value *CatchReturnInst::getCatchSwitchParentPad() const {
CleanupReturnInst *CleanupReturnInst::create(CleanupPadInst *CleanupPad,
BasicBlock *UnwindBB,
- BBIterator WhereIt,
- BasicBlock *WhereBB,
- Context &Ctx) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt != WhereBB->end())
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
- else
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ InsertPosition Pos, Context &Ctx) {
+ auto &Builder = setInsertPos(Pos);
auto *LLVMUnwindBB =
UnwindBB != nullptr ? cast<llvm::BasicBlock>(UnwindBB->Val) : nullptr;
llvm::CleanupReturnInst *LLVMI = Builder.CreateCleanupRet(
@@ -797,15 +786,9 @@ void CleanupReturnInst::setUnwindDest(BasicBlock *NewDest) {
}
Value *GetElementPtrInst::create(Type *Ty, Value *Ptr,
- ArrayRef<Value *> IdxList,
- BasicBlock::iterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
- const Twine &NameStr) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt != WhereBB->end())
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
- else
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ ArrayRef<Value *> IdxList, InsertPosition Pos,
+ Context &Ctx, const Twine &NameStr) {
+ auto &Builder = setInsertPos(Pos);
SmallVector<llvm::Value *> LLVMIdxList;
LLVMIdxList.reserve(IdxList.size());
for (Value *Idx : IdxList)
@@ -818,23 +801,6 @@ Value *GetElementPtrInst::create(Type *Ty, Value *Ptr,
return Ctx.getOrCreateConstant(cast<llvm::Constant>(NewV));
}
-Value *GetElementPtrInst::create(Type *Ty, Value *Ptr,
- ArrayRef<Value *> IdxList,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &NameStr) {
- return GetElementPtrInst::create(Ty, Ptr, IdxList,
- InsertBefore->getIterator(),
- InsertBefore->getParent(), Ctx, NameStr);
-}
-
-Value *GetElementPtrInst::create(Type *Ty, Value *Ptr,
- ArrayRef<Value *> IdxList,
- BasicBlock *InsertAtEnd, Context &Ctx,
- const Twine &NameStr) {
- return GetElementPtrInst::create(Ty, Ptr, IdxList, InsertAtEnd->end(),
- InsertAtEnd, Ctx, NameStr);
-}
-
Type *GetElementPtrInst::getSourceElementType() const {
return Ctx.getType(
cast<llvm::GetElementPtrInst>(Val)->getSourceElementType());
@@ -1008,14 +974,9 @@ static llvm::Instruction::UnaryOps getLLVMUnaryOp(Instruction::Opcode Opc) {
CatchSwitchInst *CatchSwitchInst::create(Value *ParentPad, BasicBlock *UnwindBB,
unsigned NumHandlers,
- BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
const Twine &Name) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt != WhereBB->end())
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
- else
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ auto &Builder = setInsertPos(Pos);
llvm::CatchSwitchInst *LLVMCSI = Builder.CreateCatchSwitch(
ParentPad->Val, cast<llvm::BasicBlock>(UnwindBB->Val), NumHandlers, Name);
return Ctx.createCatchSwitchInst(LLVMCSI);
@@ -1051,13 +1012,8 @@ void CatchSwitchInst::addHandler(BasicBlock *Dest) {
cast<llvm::BasicBlock>(Dest->Val));
}
-ResumeInst *ResumeInst::create(Value *Exn, BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt != WhereBB->end())
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
- else
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ResumeInst *ResumeInst::create(Value *Exn, InsertPosition Pos, Context &Ctx) {
+ auto &Builder = setInsertPos(Pos);
auto *LLVMI = cast<llvm::ResumeInst>(Builder.CreateResume(Exn->Val));
return Ctx.createResumeInst(LLVMI);
}
@@ -1067,14 +1023,9 @@ Value *ResumeInst::getValue() const {
}
SwitchInst *SwitchInst::create(Value *V, BasicBlock *Dest, unsigned NumCases,
- BasicBlock::iterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
const Twine &Name) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt != WhereBB->end())
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
- else
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
+ auto &Builder = setInsertPos(Pos);
llvm::SwitchInst *LLVMSwitch =
Builder.CreateSwitch(V->Val, cast<llvm::BasicBlock>(Dest->Val), NumCases);
return Ctx.createSwitchInst(LLVMSwitch);
@@ -1145,13 +1096,9 @@ void SwitchInst::setSuccessor(unsigned Idx, BasicBlock *NewSucc) {
}
Value *UnaryOperator::create(Instruction::Opcode Op, Value *OpV,
- BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx, const Twine &Name) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt == WhereBB->end())
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
- else
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
+ InsertPosition Pos, Context &Ctx,
+ const Twine &Name) {
+ auto &Builder = setInsertPos(Pos);
auto *NewLLVMV = Builder.CreateUnOp(getLLVMUnaryOp(Op), OpV->Val, Name);
if (auto *NewUnOpV = dyn_cast<llvm::UnaryOperator>(NewLLVMV)) {
return Ctx.createUnaryOperator(NewUnOpV);
@@ -1160,45 +1107,15 @@ Value *UnaryOperator::create(Instruction::Opcode Op, Value *OpV,
return Ctx.getOrCreateConstant(cast<llvm::Constant>(NewLLVMV));
}
-Value *UnaryOperator::create(Instruction::Opcode Op, Value *OpV,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &Name) {
- return create(Op, OpV, InsertBefore->getIterator(), InsertBefore->getParent(),
- Ctx, Name);
-}
-
-Value *UnaryOperator::create(Instruction::Opcode Op, Value *OpV,
- BasicBlock *InsertAfter, Context &Ctx,
- const Twine &Name) {
- return create(Op, OpV, InsertAfter->end(), InsertAfter, Ctx, Name);
-}
-
Value *UnaryOperator::createWithCopiedFlags(Instruction::Opcode Op, Value *OpV,
- Value *CopyFrom, BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
- const Twine &Name) {
- auto *NewV = create(Op, OpV, WhereIt, WhereBB, Ctx, Name);
+ Value *CopyFrom, InsertPosition Pos,
+ Context &Ctx, const Twine &Name) {
+ auto *NewV = create(Op, OpV, Pos, Ctx, Name);
if (auto *UnI = dyn_cast<llvm::UnaryOperator>(NewV->Val))
UnI->copyIRFlags(CopyFrom->Val);
return NewV;
}
-Value *UnaryOperator::createWithCopiedFlags(Instruction::Opcode Op, Value *OpV,
- Value *CopyFrom,
- Instruction *InsertBefore,
- Context &Ctx, const Twine &Name) {
- return createWithCopiedFlags(Op, OpV, CopyFrom, InsertBefore->getIterator(),
- InsertBefore->getParent(), Ctx, Name);
-}
-
-Value *UnaryOperator::createWithCopiedFlags(Instruction::Opcode Op, Value *OpV,
- Value *CopyFrom,
- BasicBlock *InsertAtEnd,
- Context &Ctx, const Twine &Name) {
- return createWithCopiedFlags(Op, OpV, CopyFrom, InsertAtEnd->end(),
- InsertAtEnd, Ctx, Name);
-}
-
/// \Returns the LLVM opcode that corresponds to \p Opc.
static llvm::Instruction::BinaryOps getLLVMBinaryOp(Instruction::Opcode Opc) {
switch (Opc) {
@@ -1243,13 +1160,9 @@ static llvm::Instruction::BinaryOps getLLVMBinaryOp(Instruction::Opcode Opc) {
}
}
Value *BinaryOperator::create(Instruction::Opcode Op, Value *LHS, Value *RHS,
- BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx, const Twine &Name) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt == WhereBB->end())
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
- else
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
+ InsertPosition Pos, Context &Ctx,
+ const Twine &Name) {
+ auto &Builder = setInsertPos(Pos);
llvm::Value *NewV =
Builder.CreateBinOp(getLLVMBinaryOp(Op), LHS->Val, RHS->Val, Name);
if (auto *NewBinOp = dyn_cast<llvm::BinaryOperator>(NewV))
@@ -1258,48 +1171,17 @@ Value *BinaryOperator::create(Instruction::Opcode Op, Value *LHS, Value *RHS,
return Ctx.getOrCreateConstant(cast<llvm::Constant>(NewV));
}
-Value *BinaryOperator::create(Instruction::Opcode Op, Value *LHS, Value *RHS,
- Instruction *InsertBefore, Context &Ctx,
- const Twine &Name) {
- return create(Op, LHS, RHS, InsertBefore->getIterator(),
- InsertBefore->getParent(), Ctx, Name);
-}
-
-Value *BinaryOperator::create(Instruction::Opcode Op, Value *LHS, Value *RHS,
- BasicBlock *InsertAtEnd, Context &Ctx,
- const Twine &Name) {
- return create(Op, LHS, RHS, InsertAtEnd->end(), InsertAtEnd, Ctx, Name);
-}
-
Value *BinaryOperator::createWithCopiedFlags(Instruction::Opcode Op, Value *LHS,
Value *RHS, Value *CopyFrom,
- BBIterator WhereIt,
- BasicBlock *WhereBB, Context &Ctx,
+ InsertPosition Pos, Context &Ctx,
const Twine &Name) {
- Value *NewV = create(Op, LHS, RHS, WhereIt, WhereBB, Ctx, Name);
+ Value *NewV = create(Op, LHS, RHS, Pos, Ctx, Name);
if (auto *NewBO = dyn_cast<BinaryOperator>(NewV))
cast<llvm::BinaryOperator>(NewBO->Val)->copyIRFlags(CopyFrom->Val);
return NewV;
}
-Value *BinaryOperator::createWithCopiedFlags(Instruction::Opcode Op, Value *LHS,
- Value *RHS, Value *CopyFrom,
- Instruction *InsertBefore,
- Context &Ctx, const Twine &Name) {
- return createWithCopiedFlags(Op, LHS, RHS, CopyFrom,
- InsertBefore->getIterator(),
- InsertBefore->getParent(), Ctx, Name);
-}
-
-Value *BinaryOperator::createWithCopiedFlags(Instruction::Opcode Op, Value *LHS,
- Value *RHS, Value *CopyFrom,
- BasicBlock *InsertAtEnd,
- Context &Ctx, const Twine &Name) {
- return createWithCopiedFlags(Op, LHS, RHS, CopyFrom, InsertAtEnd->end(),
- InsertAtEnd, Ctx, Name);
-}
-
void PossiblyDisjointInst::setIsDisjoint(bool B) {
Ctx.getTracker()
.emplaceIfTracking<GenericSetter<&PossiblyDisjointInst::isDisjoint,
@@ -1346,36 +1228,15 @@ Value *AtomicRMWInst::getValOperand() {
AtomicRMWInst *AtomicRMWInst::create(BinOp Op, Value *Ptr, Value *Val,
MaybeAlign Align, AtomicOrdering Ordering,
- BBIterator WhereIt, BasicBlock *WhereBB,
- Context &Ctx, SyncScope::ID SSID,
- const Twine &Name) {
- auto &Builder = Ctx.getLLVMIRBuilder();
- if (WhereIt == WhereBB->end())
- Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
- else
- Builder.SetInsertPoint((*WhereIt).getTopmostLLVMInstruction());
+ InsertPosition Pos, Context &Ctx,
+ SyncScope::ID SSID, const Twine &Name) {
+ auto &Builder = setInsertPos(Pos);
auto *LLVMAtomicRMW =
Builder.CreateAtomicRMW(Op, Ptr->Val, Val->Val, Align, Ordering, SSID);
LLVMAtomicRMW->setName(Name);
return Ctx.createAtomicRMWInst(LLVMAtomicRMW);
}
-AtomicRMWInst *AtomicRMWInst::create(BinOp Op, Value *Ptr, Value *Val,
- MaybeAlign Align, AtomicOrdering Ordering,
- Instruction *InsertBefore, Context &Ctx,
- SyncScope::ID SSID, const Twine &Name) {
- return create(Op, Ptr, Val, Align, Ordering, InsertBefore->getIterator(),
- InsertBefore->getParent(), Ctx, SSID, Name);
-}
-
-AtomicRMWInst *AtomicRMWInst::create(BinOp Op, Value *Ptr, Value *Val,
- MaybeAlign Align, AtomicOrdering Ordering,
- BasicBlock *InsertAtEnd, Context &Ctx,
- SyncScope::ID SSID, const Twine &Name) {
- return create(Op, Ptr, Val, Align, Ordering, InsertAtEnd->end(), InsertAtEnd,
- Ctx, SSID, Name);
-}
-
void AtomicCmpXchgInst::setSyncScopeID(SyncScope::ID SSID) {
Ctx.getTracker()
.emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::getSyncScopeID,
diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
index 5f39fdc0b91334..3e3db4fe81c8a5 100644
--- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp
+++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
@@ -3754,9 +3754,8 @@ define void @foo() {
EXPECT_EQ(CR->getCatchSwitchParentPad(),
Ctx.getValue(LLVMCR->getCatchSwitchParentPad()));
// Check create().
- auto *CRI =
- cast<sandboxir::CatchReturnInst>(sandboxir::CatchReturnInst::create(
- CP, Catch, CP->getIterator(), Catch, Ctx));
+ auto *CRI = cast<sandboxir::CatchReturnInst>(
+ sandboxir::CatchReturnInst::create(CP, Catch, CP->getIterator(), Ctx));
EXPECT_EQ(CRI->getNextNode(), CP);
EXPECT_EQ(CRI->getCatchPad(), CP);
EXPECT_EQ(CRI->getSuccessor(), Catch);
@@ -3826,8 +3825,8 @@ define void @foo() {
EXPECT_EQ(CRI->getUnwindDest(), OrigUnwindDest);
// Check create().
auto *UnwindBB = Cleanup;
- auto *NewCRI = sandboxir::CleanupReturnInst::create(
- CP2, UnwindBB, Ret->getIterator(), Ret->getParent(), Ctx);
+ auto *NewCRI = sandboxir::CleanupReturnInst::create(CP2, UnwindBB,
+ Ret->getIterator(), Ctx);
EXPECT_EQ(NewCRI->getCleanupPad(), CP2);
EXPECT_EQ(NewCRI->getUnwindDest(), UnwindBB);
EXPECT_EQ(NewCRI->getNextNode(), Ret);
@@ -3914,8 +3913,7 @@ define void @foo(ptr %ptr, <2 x ptr> %ptrs) {
auto *NewGEP0 =
cast<sandboxir::GetElementPtrInst>(sandboxir::GetElementPtrInst::create(
GEP0->getType(), GEP0->getPointerOperand(), Indices,
- /*WhereIt=*/Ret->getIterator(), /*WhereBB=*/Ret->getParent(), Ctx,
- "NewGEP0"));
+ Ret->getIterator(), Ctx, "NewGEP0"));
EXPECT_EQ(NewGEP0->getName(), "NewGEP0");
EXPECT_EQ(NewGEP0->getType(), GEP0->getType());
EXPECT_EQ(NewGEP0->getPointerOperand(), GEP0->getPointerOperand());
@@ -3933,7 +3931,7 @@ define void @foo(ptr %ptr, <2 x ptr> %ptrs) {
auto *NewGEP1 =
cast<sandboxir::GetElementPtrInst>(sandboxir::GetElementPtrInst::create(
GEP0->getType(), GEP0->getPointerOperand(), Indices,
- /*InsertBefore=*/Ret, Ctx, "NewGEP1"));
+ Ret->getIterator(), Ctx, "NewGEP1"));
EXPECT_EQ(NewGEP1->getName(), "NewGEP1");
EXPECT_EQ(NewGEP1->getType(), GEP0->getType());
EXPECT_EQ(NewGEP1->getPointerOperand(), GEP0->getPointerOperand());
@@ -3950,8 +3948,8 @@ define void @foo(ptr %ptr, <2 x ptr> %ptrs) {
// Check create() InsertAtEnd.
auto *NewGEP2 =
cast<sandboxir::GetElementPtrInst>(sandboxir::GetElementPtrInst::create(
- GEP0->getType(), GEP0->getPointerOperand(), Indices,
- /*InsertAtEnd=*/BB, Ctx, "NewGEP2"));
+ GEP0->getType(), GEP0->getPointerOperand(), Indices, BB, Ctx,
+ "NewGEP2"));
EXPECT_EQ(NewGEP2->getName(), "NewGEP2");
EXPECT_EQ(NewGEP2->getType(), GEP0->getType());
EXPECT_EQ(NewGEP2->getPointerOperand(), GEP0->getPointerOperand());
@@ -4125,7 +4123,7 @@ define void @foo(i32 %cond0, i32 %cond1) {
// Check create().
CS1->eraseFromParent();
auto *NewCSI = sandboxir::CatchSwitchInst::create(
- CS0, Cleanup, 2, BB1->begin(), BB1, Ctx, "NewCSI");
+ CS0, Cleanup, 2, BB1->begin(), Ctx, "NewCSI");
EXPECT_TRUE(isa<sandboxir::CatchSwitchInst>(NewCSI));
EXPECT_EQ(NewCSI->getParentPad(), CS0);
}
@@ -4162,8 +4160,7 @@ define void @foo() {
// Check getNumSuccessors().
EXPECT_EQ(Resume->getNumSuccessors(), LLVMResume->getNumSuccessors());
// Check create().
- auto *NewResume =
- sandboxir::ResumeInst::create(LPad, UnwindBB->end(), UnwindBB, Ctx);
+ auto *NewResume = sandboxir::ResumeInst::create(LPad, UnwindBB->end(), Ctx);
EXPECT_EQ(NewResume->getValue(), LPad);
EXPECT_EQ(NewResume->getParent(), UnwindBB);
EXPECT_EQ(NewResume->getNextNode(), nullptr);
@@ -4291,7 +4288,7 @@ define void @foo(i32 %cond0, i32 %cond1) {
EXPECT_EQ(Switch->getNumCases(), 2u);
// Check create().
auto NewSwitch = sandboxir::SwitchInst::create(
- Cond1, Default, 1, Default->begin(), Default, Ctx, "NewSwitch");
+ Cond1, Default, 1, Default->begin(), Ctx, "NewSwitch");
EXPECT_TRUE(isa<sandboxir::SwitchInst>(NewSwitch));
EXPECT_EQ(NewSwitch->getCondition(), Cond1);
EXPECT_EQ(NewSwitch->getDefaultDest(), Default);
@@ -4322,8 +4319,7 @@ define void @foo(float %arg0) {
// Check create() WhereIt, WhereBB.
auto *NewI =
cast<sandboxir::UnaryOperator>(sandboxir::UnaryOperator::create(
- sandboxir::Instruction::Opcode::FNeg, Arg0,
- /*WhereIt=*/Ret->getIterator(), /*WhereBB=*/Ret->getParent(), Ctx,
+ sandboxir::Instruction::Opcode::FNeg, Arg0, Ret->getIterator(), Ctx,
"New1"));
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::FNeg);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4336,8 +4332,8 @@ define void @foo(float %arg0) {
// Check create() InsertBefore.
auto *NewI =
cast<sandboxir::UnaryOperator>(sandboxir::UnaryOperator::create(
- sandboxir::Instruction::Opcode::FNeg, Arg0,
- /*InsertBefore=*/Ret, Ctx, "New2"));
+ sandboxir::Instruction::Opcode::FNeg, Arg0, Ret->getIterator(), Ctx,
+ "New2"));
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::FNeg);
EXPECT_EQ(NewI->getOperand(0), Arg0);
#ifndef NDEBUG
@@ -4349,8 +4345,7 @@ define void @foo(float %arg0) {
// Check create() InsertAtEnd.
auto *NewI =
cast<sandboxir::UnaryOperator>(sandboxir::UnaryOperator::create(
- sandboxir::Instruction::Opcode::FNeg, Arg0,
- /*InsertAtEnd=*/BB, Ctx, "New3"));
+ sandboxir::Instruction::Opcode::FNeg, Arg0, BB, Ctx, "New3"));
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::FNeg);
EXPECT_EQ(NewI->getOperand(0), Arg0);
#ifndef NDEBUG
@@ -4363,8 +4358,7 @@ define void @foo(float %arg0) {
// Check create() when it gets folded.
auto *FortyTwo = CopyFrom->getOperand(1);
auto *NewV = sandboxir::UnaryOperator::create(
- sandboxir::Instruction::Opcode::FNeg, FortyTwo,
- /*WhereIt=*/Ret->getIterator(), /*WhereBB=*/Ret->getParent(), Ctx,
+ sandboxir::Instruction::Opcode::FNeg, FortyTwo, Ret->getIterator(), Ctx,
"Folded");
EXPECT_TRUE(isa<sandboxir::Constant>(NewV));
}
@@ -4374,8 +4368,7 @@ define void @foo(float %arg0) {
auto *NewI = cast<sandboxir::UnaryOperator>(
sandboxir::UnaryOperator::createWithCopiedFlags(
sandboxir::Instruction::Opcode::FNeg, Arg0, CopyFrom,
- /*WhereIt=*/Ret->getIterator(), /*WhereBB=*/Ret->getParent(), Ctx,
- "NewCopyFrom1"));
+ Ret->getIterator(), Ctx, "NewCopyFrom1"));
EXPECT_EQ(NewI->hasAllowReassoc(), CopyFrom->hasAllowReassoc());
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::FNeg);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4389,7 +4382,7 @@ define void @foo(float %arg0) {
auto *NewI = cast<sandboxir::UnaryOperator>(
sandboxir::UnaryOperator::createWithCopiedFlags(
sandboxir::Instruction::Opcode::FNeg, Arg0, CopyFrom,
- /*InsertBefore=*/Ret, Ctx, "NewCopyFrom2"));
+ Ret->getIterator(), Ctx, "NewCopyFrom2"));
EXPECT_EQ(NewI->hasAllowReassoc(), CopyFrom->hasAllowReassoc());
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::FNeg);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4402,8 +4395,8 @@ define void @foo(float %arg0) {
// Check createWithCopiedFlags() InsertAtEnd,
auto *NewI = cast<sandboxir::UnaryOperator>(
sandboxir::UnaryOperator::createWithCopiedFlags(
- sandboxir::Instruction::Opcode::FNeg, Arg0, CopyFrom,
- /*InsertAtEnd=*/BB, Ctx, "NewCopyFrom3"));
+ sandboxir::Instruction::Opcode::FNeg, Arg0, CopyFrom, BB, Ctx,
+ "NewCopyFrom3"));
EXPECT_EQ(NewI->hasAllowReassoc(), CopyFrom->hasAllowReassoc());
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::FNeg);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4417,8 +4410,8 @@ define void @foo(float %arg0) {
// Check createWithCopiedFlags() when it gets folded.
auto *FortyTwo = CopyFrom->getOperand(1);
auto *NewV = sandboxir::UnaryOperator::createWithCopiedFlags(
- sandboxir::Instruction::Opcode::FNeg, FortyTwo, CopyFrom,
- /*InsertAtEnd=*/BB, Ctx, "Folded");
+ sandboxir::Instruction::Opcode::FNeg, FortyTwo, CopyFrom, BB, Ctx,
+ "Folded");
EXPECT_TRUE(isa<sandboxir::Constant>(NewV));
}
}
@@ -4501,9 +4494,8 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
// Check create() WhereIt, WhereBB.
auto *NewI =
cast<sandboxir::BinaryOperator>(sandboxir::BinaryOperator::create(
- sandboxir::Instruction::Opcode::Add, Arg0, Arg1,
- /*WhereIt=*/Ret->getIterator(), /*WhereBB=*/Ret->getParent(), Ctx,
- "New1"));
+ sandboxir::Instruction::Opcode::Add, Arg0, Arg1, Ret->getIterator(),
+ Ctx, "New1"));
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::Add);
EXPECT_EQ(NewI->getOperand(0), Arg0);
EXPECT_EQ(NewI->getOperand(1), Arg1);
@@ -4516,8 +4508,8 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
// Check create() InsertBefore.
auto *NewI =
cast<sandboxir::BinaryOperator>(sandboxir::BinaryOperator::create(
- sandboxir::Instruction::Opcode::Add, Arg0, Arg1,
- /*InsertBefore=*/Ret, Ctx, "New2"));
+ sandboxir::Instruction::Opcode::Add, Arg0, Arg1, Ret->getIterator(),
+ Ctx, "New2"));
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::Add);
EXPECT_EQ(NewI->getOperand(0), Arg0);
EXPECT_EQ(NewI->getOperand(1), Arg1);
@@ -4547,7 +4539,7 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
sandboxir::ConstantInt::get(sandboxir::Type::getInt32Ty(Ctx), 42);
auto *NewV = sandboxir::BinaryOperator::create(
sandboxir::Instruction::Opcode::Add, FortyTwo, FortyTwo,
- /*InsertBefore=*/Ret, Ctx, "Folded");
+ Ret->getIterator(), Ctx, "Folded");
EXPECT_TRUE(isa<sandboxir::Constant>(NewV));
}
@@ -4556,8 +4548,7 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
auto *NewI = cast<sandboxir::BinaryOperator>(
sandboxir::BinaryOperator::createWithCopiedFlags(
sandboxir::Instruction::Opcode::Add, Arg0, Arg1, CopyFrom,
- /*WhereIt=*/Ret->getIterator(), /*WhereBB=*/Ret->getParent(), Ctx,
- "NewNSW1"));
+ Ret->getIterator(), Ctx, "NewNSW1"));
EXPECT_EQ(NewI->hasNoSignedWrap(), CopyFrom->hasNoSignedWrap());
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::Add);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4572,7 +4563,7 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
auto *NewI = cast<sandboxir::BinaryOperator>(
sandboxir::BinaryOperator::createWithCopiedFlags(
sandboxir::Instruction::Opcode::Add, Arg0, Arg1, CopyFrom,
- /*InsertBefore=*/Ret, Ctx, "NewNSW2"));
+ Ret->getIterator(), Ctx, "NewNSW2"));
EXPECT_EQ(NewI->hasNoSignedWrap(), CopyFrom->hasNoSignedWrap());
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::Add);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4586,8 +4577,8 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
// Check createWithCopiedFlags() InsertAtEnd.
auto *NewI = cast<sandboxir::BinaryOperator>(
sandboxir::BinaryOperator::createWithCopiedFlags(
- sandboxir::Instruction::Opcode::Add, Arg0, Arg1, CopyFrom,
- /*InsertAtEnd=*/BB, Ctx, "NewNSW3"));
+ sandboxir::Instruction::Opcode::Add, Arg0, Arg1, CopyFrom, BB, Ctx,
+ "NewNSW3"));
EXPECT_EQ(NewI->hasNoSignedWrap(), CopyFrom->hasNoSignedWrap());
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::Add);
EXPECT_EQ(NewI->getOperand(0), Arg0);
@@ -4604,7 +4595,7 @@ define void @foo(i8 %arg0, i8 %arg1, float %farg0, float %farg1) {
sandboxir::ConstantInt::get(sandboxir::Type::getInt32Ty(Ctx), 42);
auto *NewV = sandboxir::BinaryOperator::createWithCopiedFlags(
sandboxir::Instruction::Opcode::Add, FortyTwo, FortyTwo, CopyFrom,
- /*InsertBefore=*/Ret, Ctx, "Folded");
+ Ret->getIterator(), Ctx, "Folded");
EXPECT_TRUE(isa<sandboxir::Constant>(NewV));
}
}
@@ -4729,8 +4720,7 @@ define void @foo(ptr %ptr, i8 %arg) {
auto *NewI =
cast<sandboxir::AtomicRMWInst>(sandboxir::AtomicRMWInst::create(
sandboxir::AtomicRMWInst::BinOp::Sub, Ptr, Arg, Align, Ordering,
- /*WhereIt=*/Ret->getIterator(),
- /*WhereBB=*/Ret->getParent(), Ctx, SSID, "NewAtomicRMW1"));
+ Ret->getIterator(), Ctx, SSID, "NewAtomicRMW1"));
// Check getOpcode().
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::AtomicRMW);
// Check getAlign().
@@ -4753,7 +4743,7 @@ define void @foo(ptr %ptr, i8 %arg) {
auto *NewI =
cast<sandboxir::AtomicRMWInst>(sandboxir::AtomicRMWInst::create(
sandboxir::AtomicRMWInst::BinOp::Sub, Ptr, Arg, Align, Ordering,
- /*InsertBefore=*/Ret, Ctx, SSID, "NewAtomicRMW2"));
+ Ret->getIterator(), Ctx, SSID, "NewAtomicRMW2"));
// Check getOpcode().
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::AtomicRMW);
// Check getAlign().
@@ -4775,8 +4765,8 @@ define void @foo(ptr %ptr, i8 %arg) {
// Check create() InsertAtEnd.
auto *NewI =
cast<sandboxir::AtomicRMWInst>(sandboxir::AtomicRMWInst::create(
- sandboxir::AtomicRMWInst::BinOp::Sub, Ptr, Arg, Align, Ordering,
- /*InsertAtEnd=*/BB, Ctx, SSID, "NewAtomicRMW3"));
+ sandboxir::AtomicRMWInst::BinOp::Sub, Ptr, Arg, Align, Ordering, BB,
+ Ctx, SSID, "NewAtomicRMW3"));
// Check getOpcode().
EXPECT_EQ(NewI->getOpcode(), sandboxir::Instruction::Opcode::AtomicRMW);
// Check getAlign().
More information about the llvm-commits
mailing list