diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Core.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/IR/Globals.cpp | 23 |
2 files changed, 23 insertions, 6 deletions
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); |