summaryrefslogtreecommitdiff
path: root/lib/CodeGen
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/CodeGen
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/CodeGen')
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp4
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp24
-rw-r--r--lib/CodeGen/SelectionDAG/CallingConvLower.cpp2
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp10
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp2
-rw-r--r--lib/CodeGen/ShadowStackGC.cpp40
-rw-r--r--lib/CodeGen/UnreachableBlockElim.cpp2
7 files changed, 42 insertions, 42 deletions
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 3691ba0773..43760afad8 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -314,7 +314,7 @@ bool DwarfEHPrepare::PromoteStackTemporaries() {
if (ExceptionValueVar && DT && DF && isAllocaPromotable(ExceptionValueVar)) {
// Turn the exception temporary into registers and phi nodes if possible.
std::vector<AllocaInst*> Allocas(1, ExceptionValueVar);
- PromoteMemToReg(Allocas, *DT, *DF, Context);
+ PromoteMemToReg(Allocas, *DT, *DF, ExceptionValueVar->getContext());
return true;
}
return false;
@@ -355,7 +355,7 @@ Instruction *DwarfEHPrepare::CreateValueLoad(BasicBlock *BB) {
// Create the temporary if we didn't already.
if (!ExceptionValueVar) {
ExceptionValueVar = new AllocaInst(
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ BB->getContext().getPointerTypeUnqual(Type::Int8Ty),
"eh.value", F->begin()->begin());
++NumStackTempsIntroduced;
}
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 455adc44a1..34cbf2f9b2 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -320,7 +320,7 @@ static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
IRBuilder<> Builder(CI->getParent(), CI);
- LLVMContext *Context = CI->getParent()->getContext();
+ LLVMContext &Context = CI->getContext();
Function *Callee = CI->getCalledFunction();
assert(Callee && "Cannot lower an indirect call!");
@@ -346,7 +346,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
}
case Intrinsic::sigsetjmp:
if (CI->getType() != Type::VoidTy)
- CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
+ CI->replaceAllUsesWith(Context.getNullValue(CI->getType()));
break;
case Intrinsic::longjmp: {
@@ -362,15 +362,15 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break;
}
case Intrinsic::ctpop:
- CI->replaceAllUsesWith(LowerCTPOP(*Context, CI->getOperand(1), CI));
+ CI->replaceAllUsesWith(LowerCTPOP(Context, CI->getOperand(1), CI));
break;
case Intrinsic::bswap:
- CI->replaceAllUsesWith(LowerBSWAP(*Context, CI->getOperand(1), CI));
+ CI->replaceAllUsesWith(LowerBSWAP(Context, CI->getOperand(1), CI));
break;
case Intrinsic::ctlz:
- CI->replaceAllUsesWith(LowerCTLZ(*Context, CI->getOperand(1), CI));
+ CI->replaceAllUsesWith(LowerCTLZ(Context, CI->getOperand(1), CI));
break;
case Intrinsic::cttz: {
@@ -378,9 +378,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
Value *Src = CI->getOperand(1);
Value *NotSrc = Builder.CreateNot(Src);
NotSrc->setName(Src->getName() + ".not");
- Value *SrcM1 = Context->getConstantInt(Src->getType(), 1);
+ Value *SrcM1 = Context.getConstantInt(Src->getType(), 1);
SrcM1 = Builder.CreateSub(Src, SrcM1);
- Src = LowerCTPOP(*Context, Builder.CreateAnd(NotSrc, SrcM1), CI);
+ Src = LowerCTPOP(Context, Builder.CreateAnd(NotSrc, SrcM1), CI);
CI->replaceAllUsesWith(Src);
break;
}
@@ -393,7 +393,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
"save" : "restore") << " intrinsic.\n";
Warned = true;
if (Callee->getIntrinsicID() == Intrinsic::stacksave)
- CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
+ CI->replaceAllUsesWith(Context.getNullValue(CI->getType()));
break;
}
@@ -414,7 +414,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::readcyclecounter: {
cerr << "WARNING: this target does not support the llvm.readcyclecoun"
<< "ter intrinsic. It is being lowered to a constant 0\n";
- CI->replaceAllUsesWith(Context->getConstantInt(Type::Int64Ty, 0));
+ CI->replaceAllUsesWith(Context.getConstantInt(Type::Int64Ty, 0));
break;
}
@@ -428,13 +428,13 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::eh_exception:
case Intrinsic::eh_selector_i32:
case Intrinsic::eh_selector_i64:
- CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
+ CI->replaceAllUsesWith(Context.getNullValue(CI->getType()));
break;
case Intrinsic::eh_typeid_for_i32:
case Intrinsic::eh_typeid_for_i64:
// Return something different to eh_selector.
- CI->replaceAllUsesWith(Context->getConstantInt(CI->getType(), 1));
+ CI->replaceAllUsesWith(Context.getConstantInt(CI->getType(), 1));
break;
case Intrinsic::var_annotation:
@@ -506,7 +506,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::flt_rounds:
// Lower to "round to the nearest"
if (CI->getType() != Type::VoidTy)
- CI->replaceAllUsesWith(Context->getConstantInt(CI->getType(), 1));
+ CI->replaceAllUsesWith(Context.getConstantInt(CI->getType(), 1));
break;
}
diff --git a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
index 2f4db28d64..e43af82caf 100644
--- a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
+++ b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
@@ -21,7 +21,7 @@
using namespace llvm;
CCState::CCState(unsigned CC, bool isVarArg, const TargetMachine &tm,
- SmallVector<CCValAssign, 16> &locs, LLVMContext *C)
+ SmallVector<CCValAssign, 16> &locs, LLVMContext &C)
: CallingConv(CC), IsVarArg(isVarArg), TM(tm),
TRI(*TM.getRegisterInfo()), Locs(locs), Context(C) {
// No stack is used.
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index d523e7fce3..547a7bf281 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -92,7 +92,7 @@ unsigned FastISel::getRegForValue(Value *V) {
} else if (isa<ConstantPointerNull>(V)) {
// Translate this as an integer zero so that it can be
// local-CSE'd with actual integer zeros.
- Reg = getRegForValue(Context->getNullValue(TD.getIntPtrType()));
+ Reg = getRegForValue(V->getContext().getNullValue(TD.getIntPtrType()));
} else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF);
@@ -108,7 +108,8 @@ unsigned FastISel::getRegForValue(Value *V) {
if (isExact) {
APInt IntVal(IntBitWidth, 2, x);
- unsigned IntegerReg = getRegForValue(Context->getConstantInt(IntVal));
+ unsigned IntegerReg =
+ getRegForValue(V->getContext().getConstantInt(IntVal));
if (IntegerReg != 0)
Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
}
@@ -480,7 +481,7 @@ bool FastISel::SelectCall(User *I) {
UpdateValueMap(I, ResultReg);
} else {
unsigned ResultReg =
- getRegForValue(Context->getNullValue(I->getType()));
+ getRegForValue(I->getContext().getNullValue(I->getType()));
UpdateValueMap(I, ResultReg);
}
return true;
@@ -753,8 +754,7 @@ FastISel::FastISel(MachineFunction &mf,
TM(MF.getTarget()),
TD(*TM.getTargetData()),
TII(*TM.getInstrInfo()),
- TLI(*TM.getTargetLowering()),
- Context(mf.getFunction()->getContext()) {
+ TLI(*TM.getTargetLowering()) {
}
FastISel::~FastISel() {}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 87ca13e286..c2595bced3 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -816,7 +816,7 @@ void SelectionDAG::init(MachineFunction &mf, MachineModuleInfo *mmi,
MF = &mf;
MMI = mmi;
DW = dw;
- Context = mf.getFunction()->getContext();
+ Context = &mf.getFunction()->getContext();
}
SelectionDAG::~SelectionDAG() {
diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp
index 77ec9c6131..fe843f7250 100644
--- a/lib/CodeGen/ShadowStackGC.cpp
+++ b/lib/CodeGen/ShadowStackGC.cpp
@@ -62,10 +62,10 @@ namespace {
Constant *GetFrameMap(Function &F);
const Type* GetConcreteStackEntryType(Function &F);
void CollectRoots(Function &F);
- static GetElementPtrInst *CreateGEP(LLVMContext *Context,
+ static GetElementPtrInst *CreateGEP(LLVMContext &Context,
IRBuilder<> &B, Value *BasePtr,
int Idx1, const char *Name);
- static GetElementPtrInst *CreateGEP(LLVMContext *Context,
+ static GetElementPtrInst *CreateGEP(LLVMContext &Context,
IRBuilder<> &B, Value *BasePtr,
int Idx1, int Idx2, const char *Name);
};
@@ -95,7 +95,7 @@ namespace {
public:
EscapeEnumerator(Function &F, const char *N = "cleanup")
- : F(F), CleanupBBName(N), State(0), Builder(*F.getContext()) {}
+ : F(F), CleanupBBName(N), State(0), Builder(F.getContext()) {}
IRBuilder<> *Next() {
switch (State) {
@@ -188,7 +188,7 @@ ShadowStackGC::ShadowStackGC() : Head(0), StackEntryTy(0) {
Constant *ShadowStackGC::GetFrameMap(Function &F) {
// doInitialization creates the abstract type of this value.
- LLVMContext *Context = F.getContext();
+ LLVMContext &Context = F.getContext();
Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
@@ -203,17 +203,17 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
}
Constant *BaseElts[] = {
- Context->getConstantInt(Type::Int32Ty, Roots.size(), false),
- Context->getConstantInt(Type::Int32Ty, NumMeta, false),
+ Context.getConstantInt(Type::Int32Ty, Roots.size(), false),
+ Context.getConstantInt(Type::Int32Ty, NumMeta, false),
};
Constant *DescriptorElts[] = {
- Context->getConstantStruct(BaseElts, 2),
- Context->getConstantArray(Context->getArrayType(VoidPtr, NumMeta),
+ Context.getConstantStruct(BaseElts, 2),
+ Context.getConstantArray(Context.getArrayType(VoidPtr, NumMeta),
Metadata.begin(), NumMeta)
};
- Constant *FrameMap = Context->getConstantStruct(DescriptorElts, 2);
+ Constant *FrameMap = Context.getConstantStruct(DescriptorElts, 2);
std::string TypeName("gc_map.");
TypeName += utostr(NumMeta);
@@ -236,9 +236,9 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
GlobalVariable::InternalLinkage,
FrameMap, "__gc_" + F.getName());
- Constant *GEPIndices[2] = { Context->getConstantInt(Type::Int32Ty, 0),
- Context->getConstantInt(Type::Int32Ty, 0) };
- return Context->getConstantExprGetElementPtr(GV, GEPIndices, 2);
+ Constant *GEPIndices[2] = { Context.getConstantInt(Type::Int32Ty, 0),
+ Context.getConstantInt(Type::Int32Ty, 0) };
+ return Context.getConstantExprGetElementPtr(GV, GEPIndices, 2);
}
const Type* ShadowStackGC::GetConcreteStackEntryType(Function &F) {
@@ -340,11 +340,11 @@ void ShadowStackGC::CollectRoots(Function &F) {
}
GetElementPtrInst *
-ShadowStackGC::CreateGEP(LLVMContext *Context, IRBuilder<> &B, Value *BasePtr,
+ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
int Idx, int Idx2, const char *Name) {
- Value *Indices[] = { Context->getConstantInt(Type::Int32Ty, 0),
- Context->getConstantInt(Type::Int32Ty, Idx),
- Context->getConstantInt(Type::Int32Ty, Idx2) };
+ Value *Indices[] = { Context.getConstantInt(Type::Int32Ty, 0),
+ Context.getConstantInt(Type::Int32Ty, Idx),
+ Context.getConstantInt(Type::Int32Ty, Idx2) };
Value* Val = B.CreateGEP(BasePtr, Indices, Indices + 3, Name);
assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -353,10 +353,10 @@ ShadowStackGC::CreateGEP(LLVMContext *Context, IRBuilder<> &B, Value *BasePtr,
}
GetElementPtrInst *
-ShadowStackGC::CreateGEP(LLVMContext *Context, IRBuilder<> &B, Value *BasePtr,
+ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
int Idx, const char *Name) {
- Value *Indices[] = { Context->getConstantInt(Type::Int32Ty, 0),
- Context->getConstantInt(Type::Int32Ty, Idx) };
+ Value *Indices[] = { Context.getConstantInt(Type::Int32Ty, 0),
+ Context.getConstantInt(Type::Int32Ty, Idx) };
Value *Val = B.CreateGEP(BasePtr, Indices, Indices + 2, Name);
assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -366,7 +366,7 @@ ShadowStackGC::CreateGEP(LLVMContext *Context, IRBuilder<> &B, Value *BasePtr,
/// runOnFunction - Insert code to maintain the shadow stack.
bool ShadowStackGC::performCustomLowering(Function &F) {
- LLVMContext *Context = F.getContext();
+ LLVMContext &Context = F.getContext();
// Find calls to llvm.gcroot.
CollectRoots(F);
diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp
index 003470d954..27b9627e59 100644
--- a/lib/CodeGen/UnreachableBlockElim.cpp
+++ b/lib/CodeGen/UnreachableBlockElim.cpp
@@ -68,7 +68,7 @@ bool UnreachableBlockElim::runOnFunction(Function &F) {
BasicBlock *BB = I;
DeadBlocks.push_back(BB);
while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
- PN->replaceAllUsesWith(Context->getNullValue(PN->getType()));
+ PN->replaceAllUsesWith(F.getContext().getNullValue(PN->getType()));
BB->getInstList().pop_front();
}
for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)