summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-22 00:24:57 +0000
committerOwen Anderson <resistor@mac.com>2009-07-22 00:24:57 +0000
commite922c0201916e0b980ab3cfe91e1413e68d55647 (patch)
tree663be741b84470d97945f01da459a3627af683fd /lib/Transforms/Instrumentation
parent7cf12c7efd37dc12c3ed536a3f4c373dddac2b85 (diff)
downloadllvm-e922c0201916e0b980ab3cfe91e1413e68d55647.tar.gz
llvm-e922c0201916e0b980ab3cfe91e1413e68d55647.tar.bz2
llvm-e922c0201916e0b980ab3cfe91e1413e68d55647.tar.xz
Get rid of the Pass+Context magic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76702 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation')
-rw-r--r--lib/Transforms/Instrumentation/BlockProfiling.cpp8
-rw-r--r--lib/Transforms/Instrumentation/EdgeProfiling.cpp4
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp28
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp33
4 files changed, 37 insertions, 36 deletions
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp
index 440f59b37d..065bd1125d 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -63,10 +63,10 @@ bool FunctionProfiler::runOnModule(Module &M) {
if (!I->isDeclaration())
++NumFunctions;
- const Type *ATy = Context->getArrayType(Type::Int32Ty, NumFunctions);
+ const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumFunctions);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
- Context->getNullValue(ATy), "FuncProfCounters");
+ M.getContext().getNullValue(ATy), "FuncProfCounters");
// Instrument all of the functions...
unsigned i = 0;
@@ -108,10 +108,10 @@ bool BlockProfiler::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
NumBlocks += I->size();
- const Type *ATy = Context->getArrayType(Type::Int32Ty, NumBlocks);
+ const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumBlocks);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
- Context->getNullValue(ATy), "BlockProfCounters");
+ M.getContext().getNullValue(ATy), "BlockProfCounters");
// Instrument all of the blocks...
unsigned i = 0;
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index c3ec4b92f0..d1aa370187 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -64,10 +64,10 @@ bool EdgeProfiler::runOnModule(Module &M) {
NumEdges += BB->getTerminator()->getNumSuccessors();
}
- const Type *ATy = Context->getArrayType(Type::Int32Ty, NumEdges);
+ const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumEdges);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
- Context->getNullValue(ATy), "EdgeProfCounters");
+ M.getContext().getNullValue(ATy), "EdgeProfCounters");
// Instrument all of the edges...
unsigned i = 0;
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index a67c35649f..b43ca0a4c5 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -23,10 +23,10 @@
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
GlobalValue *Array) {
- LLVMContext *Context = MainFn->getContext();
+ LLVMContext &Context = MainFn->getContext();
const Type *ArgVTy =
- Context->getPointerTypeUnqual(Context->getPointerTypeUnqual(Type::Int8Ty));
- const PointerType *UIntPtr = Context->getPointerTypeUnqual(Type::Int32Ty);
+ Context.getPointerTypeUnqual(Context.getPointerTypeUnqual(Type::Int8Ty));
+ const PointerType *UIntPtr = Context.getPointerTypeUnqual(Type::Int32Ty);
Module &M = *MainFn->getParent();
Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
ArgVTy, UIntPtr, Type::Int32Ty,
@@ -35,27 +35,27 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
// This could force argc and argv into programs that wouldn't otherwise have
// them, but instead we just pass null values in.
std::vector<Value*> Args(4);
- Args[0] = Context->getNullValue(Type::Int32Ty);
- Args[1] = Context->getNullValue(ArgVTy);
+ Args[0] = Context.getNullValue(Type::Int32Ty);
+ Args[1] = Context.getNullValue(ArgVTy);
// Skip over any allocas in the entry block.
BasicBlock *Entry = MainFn->begin();
BasicBlock::iterator InsertPos = Entry->begin();
while (isa<AllocaInst>(InsertPos)) ++InsertPos;
- std::vector<Constant*> GEPIndices(2, Context->getNullValue(Type::Int32Ty));
+ std::vector<Constant*> GEPIndices(2, Context.getNullValue(Type::Int32Ty));
unsigned NumElements = 0;
if (Array) {
- Args[2] = Context->getConstantExprGetElementPtr(Array, &GEPIndices[0],
+ Args[2] = Context.getConstantExprGetElementPtr(Array, &GEPIndices[0],
GEPIndices.size());
NumElements =
cast<ArrayType>(Array->getType()->getElementType())->getNumElements();
} else {
// If this profiling instrumentation doesn't have a constant array, just
// pass null.
- Args[2] = Context->getConstantPointerNull(UIntPtr);
+ Args[2] = Context.getConstantPointerNull(UIntPtr);
}
- Args[3] = Context->getConstantInt(Type::Int32Ty, NumElements);
+ Args[3] = Context.getConstantInt(Type::Int32Ty, NumElements);
Instruction *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(),
"newargc", InsertPos);
@@ -101,7 +101,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
GlobalValue *CounterArray) {
- LLVMContext *Context = BB->getContext();
+ LLVMContext &Context = BB->getContext();
// Insert the increment after any alloca or PHI instructions...
BasicBlock::iterator InsertPos = BB->getFirstNonPHI();
@@ -110,16 +110,16 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
// Create the getelementptr constant expression
std::vector<Constant*> Indices(2);
- Indices[0] = Context->getNullValue(Type::Int32Ty);
- Indices[1] = Context->getConstantInt(Type::Int32Ty, CounterNum);
+ Indices[0] = Context.getNullValue(Type::Int32Ty);
+ Indices[1] = Context.getConstantInt(Type::Int32Ty, CounterNum);
Constant *ElementPtr =
- Context->getConstantExprGetElementPtr(CounterArray, &Indices[0],
+ Context.getConstantExprGetElementPtr(CounterArray, &Indices[0],
Indices.size());
// Load, increment and store the value back.
Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos);
Value *NewVal = BinaryOperator::Create(Instruction::Add, OldVal,
- Context->getConstantInt(Type::Int32Ty, 1),
+ Context.getConstantInt(Type::Int32Ty, 1),
"NewFuncCounter", InsertPos);
new StoreInst(NewVal, ElementPtr, InsertPos);
}
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index 36b4464311..05196cd310 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -209,16 +209,16 @@ void GlobalRandomCounter::PrepFunction(Function* F) {}
void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) {
BranchInst* t = cast<BranchInst>(bb->getTerminator());
- LLVMContext *Context = bb->getContext();
+ LLVMContext &Context = bb->getContext();
//decrement counter
LoadInst* l = new LoadInst(Counter, "counter", t);
ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l,
- Context->getConstantInt(T, 0),
+ Context.getConstantInt(T, 0),
"countercc");
- Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1),
+ Value* nv = BinaryOperator::CreateSub(l, Context.getConstantInt(T, 1),
"counternew", t);
new StoreInst(nv, Counter, t);
t->setCondition(s);
@@ -283,16 +283,16 @@ void GlobalRandomCounterOpt::PrepFunction(Function* F) {
void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) {
BranchInst* t = cast<BranchInst>(bb->getTerminator());
- LLVMContext *Context = bb->getContext();
+ LLVMContext &Context = bb->getContext();
//decrement counter
LoadInst* l = new LoadInst(AI, "counter", t);
ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l,
- Context->getConstantInt(T, 0),
+ Context.getConstantInt(T, 0),
"countercc");
- Value* nv = BinaryOperator::CreateSub(l, Context->getConstantInt(T, 1),
+ Value* nv = BinaryOperator::CreateSub(l, Context.getConstantInt(T, 1),
"counternew", t);
new StoreInst(nv, AI, t);
t->setCondition(s);
@@ -318,15 +318,15 @@ void CycleCounter::PrepFunction(Function* F) {}
void CycleCounter::ProcessChoicePoint(BasicBlock* bb) {
BranchInst* t = cast<BranchInst>(bb->getTerminator());
- LLVMContext *Context = bb->getContext();
+ LLVMContext &Context = bb->getContext();
CallInst* c = CallInst::Create(F, "rdcc", t);
BinaryOperator* b =
- BinaryOperator::CreateAnd(c, Context->getConstantInt(Type::Int64Ty, rm),
+ BinaryOperator::CreateAnd(c, Context.getConstantInt(Type::Int64Ty, rm),
"mrdcc", t);
ICmpInst *s = new ICmpInst(t, ICmpInst::ICMP_EQ, b,
- Context->getConstantInt(Type::Int64Ty, 0),
+ Context.getConstantInt(Type::Int64Ty, 0),
"mrdccc");
t->setCondition(s);
@@ -352,16 +352,17 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu
// Create the getelementptr constant expression
std::vector<Constant*> Indices(2);
- Indices[0] = Context->getNullValue(Type::Int32Ty);
- Indices[1] = Context->getConstantInt(Type::Int32Ty, CounterNum);
- Constant *ElementPtr = Context->getConstantExprGetElementPtr(CounterArray,
+ Indices[0] = BB->getContext().getNullValue(Type::Int32Ty);
+ Indices[1] = BB->getContext().getConstantInt(Type::Int32Ty, CounterNum);
+ Constant *ElementPtr =
+ BB->getContext().getConstantExprGetElementPtr(CounterArray,
&Indices[0], 2);
// Load, increment and store the value back.
Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos);
profcode.insert(OldVal);
Value *NewVal = BinaryOperator::CreateAdd(OldVal,
- Context->getConstantInt(Type::Int32Ty, 1),
+ BB->getContext().getConstantInt(Type::Int32Ty, 1),
"NewCounter", InsertPos);
profcode.insert(NewVal);
profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos));
@@ -395,7 +396,7 @@ Value* ProfilerRS::Translate(Value* v) {
return i;
} else {
//translate this
- Instruction* i2 = i->clone(*Context);
+ Instruction* i2 = i->clone(v->getContext());
if (i->hasName())
i2->setName("dup_" + i->getName());
TransCache[i] = i2;
@@ -482,7 +483,7 @@ void ProfilerRS::ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F)
//b:
BranchInst::Create(cast<BasicBlock>(Translate(dst)), bbC);
BranchInst::Create(dst, cast<BasicBlock>(Translate(dst)),
- Context->getConstantInt(Type::Int1Ty, true), bbCp);
+ F.getContext().getConstantInt(Type::Int1Ty, true), bbCp);
//c:
{
TerminatorInst* iB = src->getTerminator();
@@ -539,7 +540,7 @@ bool ProfilerRS::runOnFunction(Function& F) {
ReplaceInstWithInst(T, BranchInst::Create(T->getSuccessor(0),
cast<BasicBlock>(
Translate(T->getSuccessor(0))),
- Context->getConstantInt(Type::Int1Ty,
+ F.getContext().getConstantInt(Type::Int1Ty,
true)));
//do whatever is needed now that the function is duplicated