diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-09-14 18:01:59 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-09-14 18:01:59 +0000 |
commit | 16a2f3e3022a48426e10ab7b822e8dc824abe23c (patch) | |
tree | a2f8977ccdc019e30fe644e1104bfecb47b57f39 /llvm/lib/IR | |
parent | c23a8b2d39f8965af32e880d2d336f4f77d8a867 (diff) | |
download | bcm5719-llvm-16a2f3e3022a48426e10ab7b822e8dc824abe23c.tar.gz bcm5719-llvm-16a2f3e3022a48426e10ab7b822e8dc824abe23c.zip |
Revert "[opaque pointer type] Pass GlobalAlias the actual pointer type rather than decomposing it into pointee type + address space"
This was a flawed change - it just caused the getElementType call to be
deferred until later, when we really need to remove it. Now that the IR
for GlobalAliases has been updated, the root cause is addressed that way
instead and this change is no longer needed (and in fact gets in the way
- because we want to pass the pointee type directly down further).
Follow up patches to push this through GlobalValue, bitcode format, etc,
will come along soon.
This reverts commit 236160.
llvm-svn: 247585
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Core.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/IR/Globals.cpp | 33 |
2 files changed, 21 insertions, 15 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 2937a62f3b5..22413297796 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1644,7 +1644,8 @@ 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(GlobalAlias::create(PTy, GlobalValue::ExternalLinkage, Name, + return wrap(GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(), + GlobalValue::ExternalLinkage, Name, unwrap<Constant>(Aliasee), unwrap(M))); } diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index 2cd1ea6b2d3..28f223593a8 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -231,35 +231,40 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) { // GlobalAlias Implementation //===----------------------------------------------------------------------===// -GlobalAlias::GlobalAlias(PointerType *Ty, LinkageTypes Link, const Twine &Name, - Constant *Aliasee, Module *ParentModule) - : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) { +GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link, + const Twine &Name, Constant *Aliasee, + Module *ParentModule) + : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalAliasVal, + &Op<0>(), 1, Link, Name) { Op<0>() = Aliasee; if (ParentModule) ParentModule->getAliasList().push_back(this); } -GlobalAlias *GlobalAlias::create(PointerType *Ty, LinkageTypes Link, - const Twine &Name, Constant *Aliasee, - Module *ParentModule) { - return new GlobalAlias(Ty, Link, Name, Aliasee, ParentModule); +GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace, + LinkageTypes Link, const Twine &Name, + Constant *Aliasee, Module *ParentModule) { + return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule); } -GlobalAlias *GlobalAlias::create(PointerType *Ty, LinkageTypes Linkage, - const Twine &Name, Module *Parent) { - return create(Ty, Linkage, Name, nullptr, Parent); +GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace, + LinkageTypes Linkage, const Twine &Name, + Module *Parent) { + return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent); } -GlobalAlias *GlobalAlias::create(PointerType *Ty, LinkageTypes Linkage, - const Twine &Name, GlobalValue *Aliasee) { - return create(Ty, Linkage, Name, Aliasee, Aliasee->getParent()); +GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace, + LinkageTypes Linkage, const Twine &Name, + GlobalValue *Aliasee) { + return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent()); } GlobalAlias *GlobalAlias::create(LinkageTypes Link, const Twine &Name, GlobalValue *Aliasee) { PointerType *PTy = Aliasee->getType(); - return create(PTy, Link, Name, Aliasee); + return create(PTy->getElementType(), PTy->getAddressSpace(), Link, Name, + Aliasee); } GlobalAlias *GlobalAlias::create(const Twine &Name, GlobalValue *Aliasee) { |