mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-23 17:28:54 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user