diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-09-30 21:23:03 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-09-30 21:23:03 +0000 |
commit | 2ebcd57e6adf2dc951eb7ad5f42952961f1a60c9 (patch) | |
tree | bb81d00fa401a9d621e5d022c3b2f8ed1c0b37f2 /lib/IR/Module.cpp | |
parent | 3ca8f2e5d5d8cb0551b42ef89deaaadd9c4cb067 (diff) | |
download | llvm-2ebcd57e6adf2dc951eb7ad5f42952961f1a60c9.tar.gz llvm-2ebcd57e6adf2dc951eb7ad5f42952961f1a60c9.tar.bz2 llvm-2ebcd57e6adf2dc951eb7ad5f42952961f1a60c9.tar.xz |
Fix getOrInsertGlobal dropping the address space.
Currently it will insert an illegal bitcast.
Arguably, the address space argument should be
added for the creation case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191702 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Module.cpp')
-rw-r--r-- | lib/IR/Module.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index ba4ee7f6a6..f200da8923 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -260,8 +260,10 @@ Constant *Module::getOrInsertGlobal(StringRef Name, Type *Ty) { // If the variable exists but has the wrong type, return a bitcast to the // right type. - if (GV->getType() != PointerType::getUnqual(Ty)) - return ConstantExpr::getBitCast(GV, PointerType::getUnqual(Ty)); + Type *GVTy = GV->getType(); + PointerType *PTy = PointerType::get(Ty, GVTy->getPointerAddressSpace()); + if (GV->getType() != PTy) + return ConstantExpr::getBitCast(GV, PTy); // Otherwise, we just found the existing function or a prototype. return GV; |