diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/IR/Core.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/IR/Globals.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneModule.cpp | 5 |
7 files changed, 33 insertions, 18 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index b457672d777..b463d49af52 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -697,8 +697,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, // Okay, create the alias but do not insert it into the module yet. std::unique_ptr<GlobalAlias> GA( - new GlobalAlias(Ty, (GlobalValue::LinkageTypes)Linkage, Name, Aliasee, - /*Parent*/ nullptr, AddrSpace)); + new GlobalAlias(Ty, AddrSpace, (GlobalValue::LinkageTypes)Linkage, Name, + Aliasee, /*Parent*/ nullptr)); GA->setVisibility((GlobalValue::VisibilityTypes)Visibility); GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass); diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index a2bb52c1e9f..478103f982f 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2004,8 +2004,8 @@ error_code BitcodeReader::ParseModule(bool Resume) { return Error(InvalidTypeForValue); auto *NewGA = - new GlobalAlias(PTy->getElementType(), GetDecodedLinkage(Record[2]), - "", nullptr, TheModule, PTy->getAddressSpace()); + new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(), + GetDecodedLinkage(Record[2]), "", TheModule); // Old bitcode files didn't have visibility field. // Local linkage must have default visibility. if (Record.size() > 3 && !NewGA->hasLocalLinkage()) diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 100c9def185..dc3d6f34c88 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1489,9 +1489,9 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit) { LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, const char *Name) { auto *PTy = cast<PointerType>(unwrap(Ty)); - return wrap(new GlobalAlias( - PTy->getElementType(), GlobalValue::ExternalLinkage, Name, - unwrap<GlobalObject>(Aliasee), unwrap(M), PTy->getAddressSpace())); + return wrap(new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(), + GlobalValue::ExternalLinkage, Name, + unwrap<GlobalObject>(Aliasee), unwrap(M))); } /*--.. Operations on functions .............................................--*/ diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index dd2a4e435ec..dae3bad5eae 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -213,9 +213,9 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) { // GlobalAlias Implementation //===----------------------------------------------------------------------===// -GlobalAlias::GlobalAlias(Type *Ty, LinkageTypes Link, const Twine &Name, - GlobalObject *Aliasee, Module *ParentModule, - unsigned AddressSpace) +GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link, + const Twine &Name, GlobalObject *Aliasee, + Module *ParentModule) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) { LeakDetector::addGarbageObject(this); @@ -225,6 +225,23 @@ GlobalAlias::GlobalAlias(Type *Ty, LinkageTypes Link, const Twine &Name, ParentModule->getAliasList().push_back(this); } +GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, + const Twine &Name, Module *Parent) + : GlobalAlias(Ty, AddressSpace, Linkage, Name, nullptr, Parent) {} + +GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, + const Twine &Name, GlobalObject *Aliasee) + : GlobalAlias(Ty, AddressSpace, Linkage, Name, Aliasee, + Aliasee->getParent()) {} + +GlobalAlias::GlobalAlias(LinkageTypes Link, const Twine &Name, + GlobalObject *Aliasee) + : GlobalAlias(Aliasee->getType()->getElementType(), + Aliasee->getType()->getAddressSpace(), Link, Name, Aliasee) {} + +GlobalAlias::GlobalAlias(const Twine &Name, GlobalObject *Aliasee) + : GlobalAlias(Aliasee->getLinkage(), Name, Aliasee) {} + void GlobalAlias::setParent(Module *parent) { if (getParent()) LeakDetector::addGarbageObject(this); diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index cf49d3fd556..518b681046a 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -922,9 +922,8 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) { // If there is no linkage to be performed or we're linking from the source, // bring over SGA. auto *PTy = cast<PointerType>(TypeMap.get(SGA->getType())); - auto *NewDA = - new GlobalAlias(PTy->getElementType(), SGA->getLinkage(), SGA->getName(), - /*aliasee*/ nullptr, DstM, PTy->getAddressSpace()); + auto *NewDA = new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(), + SGA->getLinkage(), SGA->getName(), DstM); copyGVAttributes(NewDA, SGA); if (NewVisibility) NewDA->setVisibility(*NewVisibility); diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 83d9a6f7497..bcc2835d3da 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -1328,8 +1328,8 @@ void MergeFunctions::writeThunk(Function *F, Function *G) { // Replace G with an alias to F and delete G. void MergeFunctions::writeAlias(Function *F, Function *G) { PointerType *PTy = G->getType(); - auto *GA = new GlobalAlias(PTy->getElementType(), G->getLinkage(), "", F, - G->getParent(), PTy->getAddressSpace()); + auto *GA = new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(), + G->getLinkage(), "", F); F->setAlignment(std::max(F->getAlignment(), G->getAlignment())); GA->takeName(G); GA->setVisibility(G->getVisibility()); diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index d4c4c1907aa..4ccdd9c2b86 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/lib/Transforms/Utils/CloneModule.cpp @@ -68,9 +68,8 @@ Module *llvm::CloneModule(const Module *M, ValueToValueMapTy &VMap) { for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end(); I != E; ++I) { auto *PTy = cast<PointerType>(I->getType()); - auto *GA = - new GlobalAlias(PTy->getElementType(), I->getLinkage(), I->getName(), - nullptr, New, PTy->getAddressSpace()); + auto *GA = new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(), + I->getLinkage(), I->getName(), New); GA->copyAttributesFrom(I); VMap[I] = GA; } |