forked from OSchip/llvm-project
parent
7093946ab1
commit
940fc89dc5
|
@ -61,39 +61,39 @@ template<bool preserveNames = true, typename T = ConstantFolder,
|
||||||
class IRBuilder : public Inserter {
|
class IRBuilder : public Inserter {
|
||||||
BasicBlock *BB;
|
BasicBlock *BB;
|
||||||
BasicBlock::iterator InsertPt;
|
BasicBlock::iterator InsertPt;
|
||||||
unsigned MDKind;
|
unsigned DbgMDKind;
|
||||||
MDNode *CurDbgLocation;
|
MDNode *CurDbgLocation;
|
||||||
LLVMContext &Context;
|
LLVMContext &Context;
|
||||||
T Folder;
|
T Folder;
|
||||||
public:
|
public:
|
||||||
IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter())
|
IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter())
|
||||||
: Inserter(I), MDKind(0), CurDbgLocation(0), Context(C), Folder(F) {
|
: Inserter(I), DbgMDKind(0), CurDbgLocation(0), Context(C), Folder(F) {
|
||||||
ClearInsertionPoint();
|
ClearInsertionPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit IRBuilder(LLVMContext &C)
|
explicit IRBuilder(LLVMContext &C)
|
||||||
: MDKind(0), CurDbgLocation(0), Context(C), Folder(C) {
|
: DbgMDKind(0), CurDbgLocation(0), Context(C), Folder(C) {
|
||||||
ClearInsertionPoint();
|
ClearInsertionPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit IRBuilder(BasicBlock *TheBB, const T &F)
|
explicit IRBuilder(BasicBlock *TheBB, const T &F)
|
||||||
: MDKind(0), CurDbgLocation(0), Context(TheBB->getContext()), Folder(F) {
|
: DbgMDKind(0), CurDbgLocation(0), Context(TheBB->getContext()), Folder(F) {
|
||||||
SetInsertPoint(TheBB);
|
SetInsertPoint(TheBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit IRBuilder(BasicBlock *TheBB)
|
explicit IRBuilder(BasicBlock *TheBB)
|
||||||
: MDKind(0), CurDbgLocation(0), Context(TheBB->getContext()),
|
: DbgMDKind(0), CurDbgLocation(0), Context(TheBB->getContext()),
|
||||||
Folder(Context) {
|
Folder(Context) {
|
||||||
SetInsertPoint(TheBB);
|
SetInsertPoint(TheBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F)
|
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F)
|
||||||
: MDKind(0), CurDbgLocation(0), Context(TheBB->getContext()), Folder(F) {
|
: DbgMDKind(0), CurDbgLocation(0), Context(TheBB->getContext()), Folder(F) {
|
||||||
SetInsertPoint(TheBB, IP);
|
SetInsertPoint(TheBB, IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP)
|
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP)
|
||||||
: MDKind(0), CurDbgLocation(0), Context(TheBB->getContext()),
|
: DbgMDKind(0), CurDbgLocation(0), Context(TheBB->getContext()),
|
||||||
Folder(Context) {
|
Folder(Context) {
|
||||||
SetInsertPoint(TheBB, IP);
|
SetInsertPoint(TheBB, IP);
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,8 @@ public:
|
||||||
/// SetCurrentDebugLocation - Set location information used by debugging
|
/// SetCurrentDebugLocation - Set location information used by debugging
|
||||||
/// information.
|
/// information.
|
||||||
void SetCurrentDebugLocation(MDNode *L) {
|
void SetCurrentDebugLocation(MDNode *L) {
|
||||||
if (MDKind == 0)
|
if (DbgMDKind == 0)
|
||||||
MDKind = Context.getMetadata().getMDKindID("dbg");
|
DbgMDKind = Context.getMetadata().getMDKindID("dbg");
|
||||||
CurDbgLocation = L;
|
CurDbgLocation = L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,14 +146,14 @@ public:
|
||||||
/// SetDebugLocation - Set location information for the given instruction.
|
/// SetDebugLocation - Set location information for the given instruction.
|
||||||
void SetDebugLocation(Instruction *I) {
|
void SetDebugLocation(Instruction *I) {
|
||||||
if (CurDbgLocation)
|
if (CurDbgLocation)
|
||||||
Context.getMetadata().addMD(MDKind, CurDbgLocation, I);
|
Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SetDebugLocation - Set location information for the given instruction.
|
/// SetDebugLocation - Set location information for the given instruction.
|
||||||
void SetDebugLocation(Instruction *I, MDNode *Loc) {
|
void SetDebugLocation(Instruction *I, MDNode *Loc) {
|
||||||
if (MDKind == 0)
|
if (DbgMDKind == 0)
|
||||||
MDKind = Context.getMetadata().getMDKindID("dbg");
|
DbgMDKind = Context.getMetadata().getMDKindID("dbg");
|
||||||
Context.getMetadata().addMD(MDKind, Loc, I);
|
Context.getMetadata().addMD(DbgMDKind, Loc, I);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert - Insert and return the specified instruction.
|
/// Insert - Insert and return the specified instruction.
|
||||||
|
@ -161,7 +161,7 @@ public:
|
||||||
InstTy *Insert(InstTy *I, const Twine &Name = "") const {
|
InstTy *Insert(InstTy *I, const Twine &Name = "") const {
|
||||||
this->InsertHelper(I, Name, BB, InsertPt);
|
this->InsertHelper(I, Name, BB, InsertPt);
|
||||||
if (CurDbgLocation)
|
if (CurDbgLocation)
|
||||||
Context.getMetadata().addMD(MDKind, CurDbgLocation, I);
|
Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I);
|
||||||
return I;
|
return I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue