yaxunl updated this revision to Diff 187862. yaxunl added a comment. Herald added a subscriber: jdoerfert.
Revised by Artem's comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57716/new/ https://reviews.llvm.org/D57716 Files: lib/Sema/SemaDeclAttr.cpp test/SemaCUDA/amdgpu-windows-vectorcall.cu Index: test/SemaCUDA/amdgpu-windows-vectorcall.cu =================================================================== --- /dev/null +++ test/SemaCUDA/amdgpu-windows-vectorcall.cu @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s + +// expected-no-diagnostics +template<class _Ty> + struct A + { + }; + +template<class _Ret, class _Arg0, class _Types> struct A<_Ret (__cdecl _Arg0::*)(_Types) > { }; +template<class _Ret, class _Arg0, class _Types> struct A<_Ret (__vectorcall _Arg0::*)(_Types) > {}; + Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -4615,8 +4615,36 @@ default: llvm_unreachable("unexpected attribute kind"); } + TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK; const TargetInfo &TI = Context.getTargetInfo(); - TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC); + auto *Aux = Context.getAuxTargetInfo(); + if (LangOpts.CUDA) { + auto CudaTarget = IdentifyCUDATarget(FD); + bool CheckHost = false, CheckDevice = false; + switch (CudaTarget) { + case CFT_HostDevice: + CheckHost = true; + CheckDevice = true; + break; + case CFT_Host: + CheckHost = true; + break; + case CFT_Device: + case CFT_Global: + CheckDevice = true; + break; + case CFT_InvalidTarget: + llvm_unreachable("unexpected cuda target"); + } + auto *HostTI = LangOpts.CUDAIsDevice ? Aux : &TI; + auto *DeviceTI = LangOpts.CUDAIsDevice ? &TI : Aux; + if (CheckHost && HostTI) + A = HostTI->checkCallingConvention(CC); + if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI) + A = DeviceTI->checkCallingConvention(CC); + } else { + A = TI.checkCallingConvention(CC); + } if (A != TargetInfo::CCCR_OK) { if (A == TargetInfo::CCCR_Warning) Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;
Index: test/SemaCUDA/amdgpu-windows-vectorcall.cu =================================================================== --- /dev/null +++ test/SemaCUDA/amdgpu-windows-vectorcall.cu @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s + +// expected-no-diagnostics +template<class _Ty> + struct A + { + }; + +template<class _Ret, class _Arg0, class _Types> struct A<_Ret (__cdecl _Arg0::*)(_Types) > { }; +template<class _Ret, class _Arg0, class _Types> struct A<_Ret (__vectorcall _Arg0::*)(_Types) > {}; + Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -4615,8 +4615,36 @@ default: llvm_unreachable("unexpected attribute kind"); } + TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK; const TargetInfo &TI = Context.getTargetInfo(); - TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC); + auto *Aux = Context.getAuxTargetInfo(); + if (LangOpts.CUDA) { + auto CudaTarget = IdentifyCUDATarget(FD); + bool CheckHost = false, CheckDevice = false; + switch (CudaTarget) { + case CFT_HostDevice: + CheckHost = true; + CheckDevice = true; + break; + case CFT_Host: + CheckHost = true; + break; + case CFT_Device: + case CFT_Global: + CheckDevice = true; + break; + case CFT_InvalidTarget: + llvm_unreachable("unexpected cuda target"); + } + auto *HostTI = LangOpts.CUDAIsDevice ? Aux : &TI; + auto *DeviceTI = LangOpts.CUDAIsDevice ? &TI : Aux; + if (CheckHost && HostTI) + A = HostTI->checkCallingConvention(CC); + if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI) + A = DeviceTI->checkCallingConvention(CC); + } else { + A = TI.checkCallingConvention(CC); + } if (A != TargetInfo::CCCR_OK) { if (A == TargetInfo::CCCR_Warning) Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits