diff --git a/src/tcompiler.cpp b/src/tcompiler.cpp index 6e76c3ec..fce3b449 100644 --- a/src/tcompiler.cpp +++ b/src/tcompiler.cpp @@ -2828,7 +2828,11 @@ struct FunctionEmitter { #if LLVM_VERSION < 170 return B->CreateBitCast(v, toT->type); #else - return v; + if (fromT->type->getPointerAddressSpace() != toT->type->getPointerAddressSpace()) { + return B->CreateAddrSpaceCast(v, toT->type); + } else { + return v; + } #endif } else { assert(toT->type->isIntegerTy());