summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Core.cpp6
-rw-r--r--llvm/lib/IR/Globals.cpp16
2 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 81d137edfe0..40c1c70257e 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1488,8 +1488,10 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit) {
LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
const char *Name) {
- return wrap(new GlobalAlias(unwrap(Ty), GlobalValue::ExternalLinkage, Name,
- unwrap<Constant>(Aliasee), unwrap (M)));
+ auto *PTy = cast<PointerType>(unwrap(Ty));
+ return wrap(new GlobalAlias(
+ PTy->getElementType(), GlobalValue::ExternalLinkage, Name,
+ unwrap<Constant>(Aliasee), unwrap(M), PTy->getAddressSpace()));
}
/*--.. Operations on functions .............................................--*/
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 0ec54fe3c08..8e7478496f0 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -213,15 +213,17 @@ void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
// GlobalAlias Implementation
//===----------------------------------------------------------------------===//
-GlobalAlias::GlobalAlias(Type *Ty, LinkageTypes Link,
- const Twine &Name, Constant* aliasee,
- Module *ParentModule)
- : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) {
+GlobalAlias::GlobalAlias(Type *Ty, LinkageTypes Link, const Twine &Name,
+ Constant *Aliasee, Module *ParentModule,
+ unsigned AddressSpace)
+ : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalAliasVal,
+ &Op<0>(), 1, Link, Name) {
LeakDetector::addGarbageObject(this);
- if (aliasee)
- assert(aliasee->getType() == Ty && "Alias and aliasee types should match!");
- Op<0>() = aliasee;
+ if (Aliasee)
+ assert(Aliasee->getType() == getType() &&
+ "Alias and aliasee types should match!");
+ Op<0>() = Aliasee;
if (ParentModule)
ParentModule->getAliasList().push_back(this);
OpenPOWER on IntegriCloud