[DebugInfo] Enable deprecation of iterator-insertion methods (#102608)
This is an almost-final step in eliminating debug-intrinsics -- read more about that here: https://llvm.org/docs/RemoveDIsDebugInfo.html . To correctly update variable location information in the background when inserting instructions, we need some information carried at runtime in BasicBlock::iterator, hence deprecating pointer-insertion. An immediate fix for any deprecation warnings is to call "getIterator" on the insertion position pointer. If you intend on inserting at the start of a block, use BB->begin() or similar methods to fetch the appropriate iterator.
This commit is contained in:
parent
1808fc13c8
commit
2f50b280dc
@ -158,7 +158,7 @@ static bool eliminateCondBranches_v1(Function &F) {
|
||||
// Replace the conditional branch with an unconditional one, by creating
|
||||
// a new unconditional branch to the selected successor and removing the
|
||||
// conditional one.
|
||||
BranchInst::Create(BI->getSuccessor(CI->isZero()), BI);
|
||||
BranchInst::Create(BI->getSuccessor(CI->isZero()), BI->getIterator());
|
||||
BI->eraseFromParent();
|
||||
Changed = true;
|
||||
}
|
||||
@ -195,7 +195,7 @@ static bool eliminateCondBranches_v2(Function &F, DominatorTree &DT) {
|
||||
// a new unconditional branch to the selected successor and removing the
|
||||
// conditional one.
|
||||
BranchInst *NewBranch =
|
||||
BranchInst::Create(BI->getSuccessor(CI->isZero()), BI);
|
||||
BranchInst::Create(BI->getSuccessor(CI->isZero()), BI->getIterator());
|
||||
BI->eraseFromParent();
|
||||
|
||||
// Delete the edge between BB and RemovedSucc in the DominatorTree, iff
|
||||
@ -242,7 +242,8 @@ static bool eliminateCondBranches_v3(Function &F, DominatorTree &DT) {
|
||||
// a new unconditional branch to the selected successor and removing the
|
||||
// conditional one.
|
||||
|
||||
BranchInst *NewBranch = BranchInst::Create(TakenSucc, BB.getTerminator());
|
||||
BranchInst *NewBranch =
|
||||
BranchInst::Create(TakenSucc, BB.getTerminator()->getIterator());
|
||||
BB.getTerminator()->eraseFromParent();
|
||||
|
||||
// Delete the edge between BB and RemovedSucc in the DominatorTree, iff
|
||||
|
@ -58,17 +58,9 @@ class UnaryInstruction : public Instruction {
|
||||
constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
|
||||
|
||||
protected:
|
||||
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock::iterator IB)
|
||||
: Instruction(Ty, iType, AllocMarker, IB) {
|
||||
Op<0>() = V;
|
||||
}
|
||||
UnaryInstruction(Type *Ty, unsigned iType, Value *V,
|
||||
Instruction *IB = nullptr)
|
||||
: Instruction(Ty, iType, AllocMarker, IB) {
|
||||
Op<0>() = V;
|
||||
}
|
||||
UnaryInstruction(Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
|
||||
: Instruction(Ty, iType, AllocMarker, IAE) {
|
||||
InsertPosition InsertBefore = nullptr)
|
||||
: Instruction(Ty, iType, AllocMarker, InsertBefore) {
|
||||
Op<0>() = V;
|
||||
}
|
||||
|
||||
@ -130,27 +122,15 @@ public:
|
||||
/// These methods just forward to Create, and are useful when you
|
||||
/// statically know what type of instruction you're going to create. These
|
||||
/// helpers just save some typing.
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name = "") {\
|
||||
return Create(Instruction::OPC, V, Name);\
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name = "") { \
|
||||
return Create(Instruction::OPC, V, Name); \
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
|
||||
BasicBlock *BB) {\
|
||||
return Create(Instruction::OPC, V, Name, BB);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
|
||||
Instruction *I) {\
|
||||
return Create(Instruction::OPC, V, Name, I);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
|
||||
BasicBlock::iterator It) {\
|
||||
return Create(Instruction::OPC, V, Name, It);\
|
||||
#define HANDLE_UNARY_INST(N, OPC, CLASS) \
|
||||
static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
|
||||
InsertPosition InsertBefore = nullptr) { \
|
||||
return Create(Instruction::OPC, V, Name, InsertBefore); \
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
|
||||
@ -221,28 +201,16 @@ public:
|
||||
/// These methods just forward to Create, and are useful when you
|
||||
/// statically know what type of instruction you're going to create. These
|
||||
/// helpers just save some typing.
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
|
||||
const Twine &Name = "") {\
|
||||
return Create(Instruction::OPC, V1, V2, Name);\
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
|
||||
const Twine &Name = "") { \
|
||||
return Create(Instruction::OPC, V1, V2, Name); \
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
|
||||
const Twine &Name, BasicBlock *BB) {\
|
||||
return Create(Instruction::OPC, V1, V2, Name, BB);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
|
||||
const Twine &Name, Instruction *I) {\
|
||||
return Create(Instruction::OPC, V1, V2, Name, I);\
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
|
||||
const Twine &Name, BasicBlock::iterator It) {\
|
||||
return Create(Instruction::OPC, V1, V2, Name, It);\
|
||||
#define HANDLE_BINARY_INST(N, OPC, CLASS) \
|
||||
static BinaryOperator *Create##OPC(Value *V1, Value *V2, const Twine &Name, \
|
||||
InsertPosition InsertBefore) { \
|
||||
return Create(Instruction::OPC, V1, V2, Name, InsertBefore); \
|
||||
}
|
||||
#include "llvm/IR/Instruction.def"
|
||||
|
||||
@ -313,21 +281,11 @@ public:
|
||||
BO->setHasNoSignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock *BB) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
|
||||
BO->setHasNoSignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, Instruction *I) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
|
||||
BO->setHasNoSignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
const Twine &Name,
|
||||
InsertPosition InsertBefore) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, InsertBefore);
|
||||
BO->setHasNoSignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
@ -338,21 +296,11 @@ public:
|
||||
BO->setHasNoUnsignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock *BB) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
|
||||
BO->setHasNoUnsignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, Instruction *I) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
|
||||
BO->setHasNoUnsignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
const Twine &Name,
|
||||
InsertPosition InsertBefore) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, InsertBefore);
|
||||
BO->setHasNoUnsignedWrap(true);
|
||||
return BO;
|
||||
}
|
||||
@ -363,22 +311,11 @@ public:
|
||||
BO->setIsExact(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, BasicBlock *BB) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
|
||||
BO->setIsExact(true);
|
||||
return BO;
|
||||
}
|
||||
static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name, Instruction *I) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
|
||||
BO->setIsExact(true);
|
||||
return BO;
|
||||
}
|
||||
|
||||
static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
|
||||
const Twine &Name,
|
||||
BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
InsertPosition InsertBefore) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, InsertBefore);
|
||||
BO->setIsExact(true);
|
||||
return BO;
|
||||
}
|
||||
@ -387,13 +324,7 @@ public:
|
||||
CreateDisjoint(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name = "");
|
||||
static inline BinaryOperator *CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
BasicBlock *BB);
|
||||
static inline BinaryOperator *CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
Instruction *I);
|
||||
static inline BinaryOperator *CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
BasicBlock::iterator It);
|
||||
InsertPosition InsertBefore);
|
||||
|
||||
#define DEFINE_HELPERS(OPC, NUWNSWEXACT) \
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \
|
||||
@ -401,16 +332,9 @@ public:
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name); \
|
||||
} \
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC( \
|
||||
Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { \
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, BB); \
|
||||
} \
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC( \
|
||||
Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, I); \
|
||||
} \
|
||||
static BinaryOperator *Create##NUWNSWEXACT##OPC( \
|
||||
Value *V1, Value *V2, const Twine &Name, BasicBlock::iterator It) { \
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, It); \
|
||||
Value *V1, Value *V2, const Twine &Name, \
|
||||
InsertPosition InsertBefore = nullptr) { \
|
||||
return Create##NUWNSWEXACT(Instruction::OPC, V1, V2, Name, InsertBefore); \
|
||||
}
|
||||
|
||||
DEFINE_HELPERS(Add, NSW) // CreateNSWAdd
|
||||
@ -501,22 +425,8 @@ BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
}
|
||||
BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
BasicBlock *BB) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, BB);
|
||||
cast<PossiblyDisjointInst>(BO)->setIsDisjoint(true);
|
||||
return BO;
|
||||
}
|
||||
BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
Instruction *I) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, I);
|
||||
cast<PossiblyDisjointInst>(BO)->setIsDisjoint(true);
|
||||
return BO;
|
||||
}
|
||||
BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
|
||||
Value *V2, const Twine &Name,
|
||||
BasicBlock::iterator It) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, It);
|
||||
InsertPosition InsertBefore) {
|
||||
BinaryOperator *BO = Create(Opc, V1, V2, Name, InsertBefore);
|
||||
cast<PossiblyDisjointInst>(BO)->setIsDisjoint(true);
|
||||
return BO;
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ class InsertPosition {
|
||||
|
||||
public:
|
||||
InsertPosition(std::nullptr_t) : InsertAt() {}
|
||||
// LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead",
|
||||
// "BasicBlock::iterator")
|
||||
LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead",
|
||||
"BasicBlock::iterator")
|
||||
InsertPosition(Instruction *InsertBefore);
|
||||
InsertPosition(BasicBlock *InsertAtEnd);
|
||||
InsertPosition(InstListType::iterator InsertAt) : InsertAt(InsertAt) {}
|
||||
|
@ -1362,9 +1362,9 @@ BasicBlock *PHINode::LLVMBBToBB::operator()(llvm::BasicBlock *LLVMBB) const {
|
||||
PHINode *PHINode::create(Type *Ty, unsigned NumReservedValues,
|
||||
Instruction *InsertBefore, Context &Ctx,
|
||||
const Twine &Name) {
|
||||
llvm::PHINode *NewPHI =
|
||||
llvm::PHINode::Create(Ty->LLVMTy, NumReservedValues, Name,
|
||||
InsertBefore->getTopmostLLVMInstruction());
|
||||
llvm::PHINode *NewPHI = llvm::PHINode::Create(
|
||||
Ty->LLVMTy, NumReservedValues, Name,
|
||||
InsertBefore->getTopmostLLVMInstruction()->getIterator());
|
||||
return Ctx.createPHINode(NewPHI);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user