diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-08 19:03:57 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-08 19:03:57 +0000 |
commit | e9b11b431308f4766b73cda93e38ec930c912122 (patch) | |
tree | d72fc321dc0c445f8880443050c0a03c2ccdf7d2 /lib/Transforms/IPO | |
parent | 515cdbe49d9bb5cd05be2713faaa7e2a66ddc3bc (diff) | |
download | external_llvm-e9b11b431308f4766b73cda93e38ec930c912122.zip external_llvm-e9b11b431308f4766b73cda93e38ec930c912122.tar.gz external_llvm-e9b11b431308f4766b73cda93e38ec930c912122.tar.bz2 |
Switch GlobalVariable ctors to a sane API, where *either* a context or a module is required.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75025 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/ExtractGV.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 35 |
2 files changed, 17 insertions, 22 deletions
diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp index e26bd3a..b7c5ca3 100644 --- a/lib/Transforms/IPO/ExtractGV.cpp +++ b/lib/Transforms/IPO/ExtractGV.cpp @@ -108,9 +108,9 @@ namespace { } ArrayType *AT = Context->getArrayType(SBP, AUGs.size()); Constant *Init = Context->getConstantArray(AT, AUGs); - GlobalValue *gv = new GlobalVariable(M.getContext(), AT, false, + GlobalValue *gv = new GlobalVariable(M, AT, false, GlobalValue::AppendingLinkage, - Init, "llvm.used", &M); + Init, "llvm.used"); gv->setSection("llvm.metadata"); } diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index eb13067..2cd8b6b 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -490,11 +490,10 @@ 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(*Context, 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()); Globals.insert(GV, NGV); @@ -527,13 +526,12 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD, Context); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(), - false, + GlobalVariable *NGV = new GlobalVariable(*Context, + STy->getElementType(), 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); @@ -842,18 +840,17 @@ 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. + // FIXME: This new global should have the alignment returned by malloc. Code + // could depend on malloc returning large alignment (on the mac, 16 bytes) but + // this would only guarantee some lower alignment. Constant *Init = Context->getUndef(MI->getAllocatedType()); - GlobalVariable *NewGV = new GlobalVariable(*Context, MI->getAllocatedType(), - false, + GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(), + MI->getAllocatedType(), false, GlobalValue::InternalLinkage, Init, GV->getName()+".body", - (Module *)NULL, + GV, GV->isThreadLocal()); - // FIXME: This new global should have the alignment returned by malloc. Code - // could depend on malloc returning large alignment (on the mac, 16 bytes) but - // this would only guarantee some lower alignment. - GV->getParent()->getGlobalList().insert(GV, NewGV); - + // Anything that used the malloc now uses the global directly. MI->replaceAllUsesWith(NewGV); @@ -868,7 +865,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, new GlobalVariable(*Context, Type::Int1Ty, false, GlobalValue::InternalLinkage, Context->getConstantIntFalse(), GV->getName()+".init", - (Module *)NULL, GV->isThreadLocal()); + GV->isThreadLocal()); bool InitBoolUsed = false; // Loop over all uses of GV, processing them in turn. @@ -1286,8 +1283,8 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI, const Type *PFieldTy = Context->getPointerTypeUnqual(FieldTy); GlobalVariable *NGV = - new GlobalVariable(*Context, PFieldTy, false, - GlobalValue::InternalLinkage, + new GlobalVariable(*GV->getParent(), + PFieldTy, false, GlobalValue::InternalLinkage, Context->getNullValue(PFieldTy), GV->getName() + ".f" + utostr(FieldNo), GV, GV->isThreadLocal()); @@ -1587,7 +1584,6 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal, GlobalVariable *NewGV = new GlobalVariable(*Context, Type::Int1Ty, false, GlobalValue::InternalLinkage, Context->getConstantIntFalse(), GV->getName()+".b", - (Module *)NULL, GV->isThreadLocal()); GV->getParent()->getGlobalList().insert(GV, NewGV); @@ -1982,7 +1978,6 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, GlobalVariable *NGV = new GlobalVariable(*Context, CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", - (Module *)NULL, GCL->isThreadLocal()); GCL->getParent()->getGlobalList().insert(GCL, NGV); NGV->takeName(GCL); |