aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/ProfilingUtils.cpp
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/ProfilingUtils.cpp
parent7cf12c7efd37dc12c3ed536a3f4c373dddac2b85 (diff)
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/ProfilingUtils.cpp')
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp28
1 files changed, 14 insertions, 14 deletions
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);
}