Index: lib/Basic/Targets/AMDGPU.cpp =================================================================== --- lib/Basic/Targets/AMDGPU.cpp +++ lib/Basic/Targets/AMDGPU.cpp @@ -254,9 +254,15 @@ PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits(); if (getMaxPointerWidth() == 64) { LongWidth = LongAlign = 64; - SizeType = UnsignedLong; - PtrDiffType = SignedLong; - IntPtrType = SignedLong; + if (Triple.getEnvironment() == llvm::Triple::MSVC) { + SizeType = UnsignedLongLong; + PtrDiffType = SignedLongLong; + IntPtrType = SignedLongLong; + } else { + SizeType = UnsignedLong; + PtrDiffType = SignedLong; + IntPtrType = SignedLong; + } } MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -614,7 +614,11 @@ StringRef DeviceTripleStr; auto OFK = Action::OFK_HIP; DeviceTripleStr = "amdgcn-amd-amdhsa"; - llvm::Triple HIPTriple(DeviceTripleStr); + StringRef Env; + if (HostTriple.getEnvironment() == llvm::Triple::MSVC) + Env = HostTriple.getEnvironmentName(); + llvm::Triple HIPTriple(Env.empty() ? Twine(DeviceTripleStr) : + DeviceTripleStr + "-" + Env); // Use the HIP and host triples as the key into the ToolChains map, // because the device toolchain we create depends on both. auto &HIPTC = ToolChains[HIPTriple.str() + "/" + HostTriple.str()]; Index: test/SemaCUDA/amdgpu-size_t.cu =================================================================== --- /dev/null +++ test/SemaCUDA/amdgpu-size_t.cu @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s + +// expected-no-diagnostics +typedef unsigned __int64 size_t; +typedef __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +