summaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-08 01:26:06 +0000
committerOwen Anderson <resistor@mac.com>2009-07-08 01:26:06 +0000
commit3d29df3e8a203b167d8071ea6f805b21db18a5af (patch)
tree04e35fb85689b9621ea6ec76db47849335a87c5c /lib/Transforms
parent8b8d31e3ec8c491a893307069ac123728c84782c (diff)
downloadexternal_llvm-3d29df3e8a203b167d8071ea6f805b21db18a5af.zip
external_llvm-3d29df3e8a203b167d8071ea6f805b21db18a5af.tar.gz
external_llvm-3d29df3e8a203b167d8071ea6f805b21db18a5af.tar.bz2
Push LLVMContext through GlobalVariables and IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74985 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/ExtractGV.cpp2
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp24
-rw-r--r--lib/Transforms/Instrumentation/BlockProfiling.cpp4
-rw-r--r--lib/Transforms/Instrumentation/EdgeProfiling.cpp2
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp6
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp3
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp3
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp9
8 files changed, 33 insertions, 20 deletions
diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp
index 8cd5deb..e26bd3a 100644
--- a/lib/Transforms/IPO/ExtractGV.cpp
+++ b/lib/Transforms/IPO/ExtractGV.cpp
@@ -108,7 +108,7 @@ namespace {
}
ArrayType *AT = Context->getArrayType(SBP, AUGs.size());
Constant *Init = Context->getConstantArray(AT, AUGs);
- GlobalValue *gv = new GlobalVariable(AT, false,
+ GlobalValue *gv = new GlobalVariable(M.getContext(), AT, false,
GlobalValue::AppendingLinkage,
Init, "llvm.used", &M);
gv->setSection("llvm.metadata");
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index f394a3a..eb13067 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -490,12 +490,13 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
Context->getConstantInt(Type::Int32Ty, i),
Context);
assert(In && "Couldn't get element of initializer?");
- GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false,
+ GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(i),
+ false,
GlobalVariable::InternalLinkage,
In, GV->getName()+"."+utostr(i),
(Module *)NULL,
GV->isThreadLocal(),
- GV->getType()->getAddressSpace());
+ GV->getType()->getAddressSpace());
Globals.insert(GV, NGV);
NewGlobals.push_back(NGV);
@@ -526,7 +527,8 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
Context);
assert(In && "Couldn't get element of initializer?");
- GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false,
+ GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(),
+ false,
GlobalVariable::InternalLinkage,
In, GV->getName()+"."+utostr(i),
(Module *)NULL,
@@ -841,7 +843,8 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
// Create the new global variable. The contents of the malloc'd memory is
// undefined, so initialize with an undef value.
Constant *Init = Context->getUndef(MI->getAllocatedType());
- GlobalVariable *NewGV = new GlobalVariable(MI->getAllocatedType(), false,
+ GlobalVariable *NewGV = new GlobalVariable(*Context, MI->getAllocatedType(),
+ false,
GlobalValue::InternalLinkage, Init,
GV->getName()+".body",
(Module *)NULL,
@@ -862,7 +865,8 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
// If there is a comparison against null, we will insert a global bool to
// keep track of whether the global was initialized yet or not.
GlobalVariable *InitBool =
- new GlobalVariable(Type::Int1Ty, false, GlobalValue::InternalLinkage,
+ new GlobalVariable(*Context, Type::Int1Ty, false,
+ GlobalValue::InternalLinkage,
Context->getConstantIntFalse(), GV->getName()+".init",
(Module *)NULL, GV->isThreadLocal());
bool InitBoolUsed = false;
@@ -1282,7 +1286,8 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
const Type *PFieldTy = Context->getPointerTypeUnqual(FieldTy);
GlobalVariable *NGV =
- new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage,
+ new GlobalVariable(*Context, PFieldTy, false,
+ GlobalValue::InternalLinkage,
Context->getNullValue(PFieldTy),
GV->getName() + ".f" + utostr(FieldNo), GV,
GV->isThreadLocal());
@@ -1579,7 +1584,7 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal,
DOUT << " *** SHRINKING TO BOOL: " << *GV;
// Create the new global, initializing it to false.
- GlobalVariable *NewGV = new GlobalVariable(Type::Int1Ty, false,
+ GlobalVariable *NewGV = new GlobalVariable(*Context, Type::Int1Ty, false,
GlobalValue::InternalLinkage, Context->getConstantIntFalse(),
GV->getName()+".b",
(Module *)NULL,
@@ -1974,7 +1979,8 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
}
// Create the new global and insert it next to the existing list.
- GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(),
+ GlobalVariable *NGV = new GlobalVariable(*Context, CA->getType(),
+ GCL->isConstant(),
GCL->getLinkage(), CA, "",
(Module *)NULL,
GCL->isThreadLocal());
@@ -2222,7 +2228,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
} else if (AllocaInst *AI = dyn_cast<AllocaInst>(CurInst)) {
if (AI->isArrayAllocation()) return false; // Cannot handle array allocs.
const Type *Ty = AI->getType()->getElementType();
- AllocaTmps.push_back(new GlobalVariable(Ty, false,
+ AllocaTmps.push_back(new GlobalVariable(*Context, Ty, false,
GlobalValue::InternalLinkage,
Context->getUndef(Ty),
AI->getName()));
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp
index 913680c..6dfcc0b 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -65,7 +65,7 @@ bool FunctionProfiler::runOnModule(Module &M) {
const Type *ATy = Context->getArrayType(Type::Int32Ty, NumFunctions);
GlobalVariable *Counters =
- new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
+ new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage,
Context->getNullValue(ATy), "FuncProfCounters", &M);
// Instrument all of the functions...
@@ -110,7 +110,7 @@ bool BlockProfiler::runOnModule(Module &M) {
const Type *ATy = Context->getArrayType(Type::Int32Ty, NumBlocks);
GlobalVariable *Counters =
- new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
+ new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage,
Context->getNullValue(ATy), "BlockProfCounters", &M);
// Instrument all of the blocks...
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index 88825b1..b625341 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -66,7 +66,7 @@ bool EdgeProfiler::runOnModule(Module &M) {
const Type *ATy = Context->getArrayType(Type::Int32Ty, NumEdges);
GlobalVariable *Counters =
- new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
+ new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage,
Context->getNullValue(ATy), "EdgeProfCounters", &M);
// Instrument all of the edges...
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index e487d2f..0999a27 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -198,7 +198,8 @@ GlobalRandomCounter::GlobalRandomCounter(Module& M, const IntegerType* t,
uint64_t resetval) : T(t) {
ConstantInt* Init = M.getContext().getConstantInt(T, resetval);
ResetValue = Init;
- Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage,
+ Counter = new GlobalVariable(M.getContext(), T, false,
+ GlobalValue::InternalLinkage,
Init, "RandomSteeringCounter", &M);
}
@@ -237,7 +238,8 @@ GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const IntegerType* t,
: AI(0), T(t) {
ConstantInt* Init = M.getContext().getConstantInt(T, resetval);
ResetValue = Init;
- Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage,
+ Counter = new GlobalVariable(M.getContext(), T, false,
+ GlobalValue::InternalLinkage,
Init, "RandomSteeringCounter", &M);
}
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index ec48469..72308c8 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -1290,7 +1290,8 @@ struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization {
// pass to be run after this pass, to merge duplicate strings.
FormatStr.erase(FormatStr.end()-1);
Constant *C = Context->getConstantArray(FormatStr, true);
- C = new GlobalVariable(C->getType(), true,GlobalVariable::InternalLinkage,
+ C = new GlobalVariable(*Context, C->getType(),
+ true, GlobalVariable::InternalLinkage,
C, "str", Callee->getParent());
EmitPutS(C, B);
return CI->use_empty() ? (Value*)CI :
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index f605636..afebd5b 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/lib/Transforms/Utils/CloneModule.cpp
@@ -56,7 +56,8 @@ Module *llvm::CloneModule(const Module *M,
//
for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I) {
- GlobalVariable *GV = new GlobalVariable(I->getType()->getElementType(),
+ GlobalVariable *GV = new GlobalVariable(M->getContext(),
+ I->getType()->getElementType(),
false,
GlobalValue::ExternalLinkage, 0,
I->getName(), New);
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 8a585d2..1eefdc4 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -139,7 +139,8 @@ bool LowerInvoke::doInitialization(Module &M) {
// Now that we've done that, insert the jmpbuf list head global, unless it
// already exists.
if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) {
- JBListHead = new GlobalVariable(PtrJBList, false,
+ JBListHead = new GlobalVariable(M.getContext(),
+ PtrJBList, false,
GlobalValue::LinkOnceAnyLinkage,
Context->getNullValue(PtrJBList),
"llvm.sjljeh.jblist", &M);
@@ -182,7 +183,8 @@ void LowerInvoke::createAbortMessage(Module *M) {
Context->getConstantArray("ERROR: Exception thrown, but not caught!\n");
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
- GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
+ GlobalVariable *MsgGV = new GlobalVariable(M->getContext(),
+ Msg->getType(), true,
GlobalValue::InternalLinkage,
Msg, "abortmsg", M);
std::vector<Constant*> GEPIdx(2, Context->getNullValue(Type::Int32Ty));
@@ -195,7 +197,8 @@ void LowerInvoke::createAbortMessage(Module *M) {
"Recompile program with -enable-correct-eh-support.\n");
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
- GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
+ GlobalVariable *MsgGV = new GlobalVariable(M->getContext(),
+ Msg->getType(), true,
GlobalValue::InternalLinkage,
Msg, "abortmsg", M);
std::vector<Constant*> GEPIdx(2, Context->getNullValue(Type::Int32Ty));