diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -401,8 +401,10 @@ // Cast the address we've calculated to the right type. llvm::Type *DirectTy = CGF.ConvertTypeForMem(ValueTy), *ElementTy = DirectTy; - if (IsIndirect) - DirectTy = DirectTy->getPointerTo(0); + if (IsIndirect) { + unsigned AllocaAS = CGF.CGM.getDataLayout().getAllocaAddrSpace(); + DirectTy = DirectTy->getPointerTo(AllocaAS); + } Address Addr = emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize, DirectAlign, SlotSizeAndAlign,