https://github.com/ritter-x2a created https://github.com/llvm/llvm-project/pull/239553
GFX12.5 no longer supports the s_waitcnt instruction (it uses different instructions), so this builtin is not available on GFX12.5. So far, this would fail during instruction selection. Disclaimer: Implemented with AI, manually checked. Assisted-by: AI >From 196c5e95c6fca0c4f43e98b733500eae69344005 Mon Sep 17 00:00:00 2001 From: Fabian Ritter <[email protected]> Date: Fri, 6 Nov 2026 05:14:53 -0500 Subject: [PATCH] [AMDGPU] Diagnose s_waitcnt builtin on archs that don't have it GFX12.5 no longer supports the s_waitcnt instruction (it uses different instructions), so this builtin is not available on GFX12.5. So far, this would fail during instruction selection. Disclaimer: Implemented with AI, manually checked. Assisted-by: AI --- clang/lib/Sema/SemaAMDGPU.cpp | 7 +++++++ clang/test/SemaOpenCL/builtins-amdgcn-s-waitcnt.cl | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-s-waitcnt.cl diff --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp index 1d79fa881202d..c970793044b24 100644 --- a/clang/lib/Sema/SemaAMDGPU.cpp +++ b/clang/lib/Sema/SemaAMDGPU.cpp @@ -184,6 +184,13 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(const TargetInfo &TI, << ArgExpr->getSourceRange(); return true; } + case AMDGPU::BI__builtin_amdgcn_s_waitcnt: + if (Builtin::evaluateRequiredTargetFeatures("gfx1250-insts", + CallerFeatureMap)) + return SemaRef.targetDiag(TheCall->getBeginLoc(), + diag::err_builtin_target_unsupported) + << TheCall->getSourceRange(); + return false; case AMDGPU::BI__builtin_amdgcn_s_wait_event: { llvm::APSInt Result; if (SemaRef.BuiltinConstantArg(TheCall, 0, Result)) diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-s-waitcnt.cl b/clang/test/SemaOpenCL/builtins-amdgcn-s-waitcnt.cl new file mode 100644 index 0000000000000..5dafd750bd6db --- /dev/null +++ b/clang/test/SemaOpenCL/builtins-amdgcn-s-waitcnt.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -triple amdgpu11.00-- -verify=GFX11 %s +// RUN: %clang_cc1 -fsyntax-only -triple amdgpu12.00-- -verify=GFX1200 %s +// RUN: %clang_cc1 -fsyntax-only -triple amdgpu12.50-- -verify=GFX1250 %s + +void test(void) { + // GFX11-no-diagnostics + // GFX1200-no-diagnostics + // GFX1250-error@+1 {{builtin is not supported on this target}} + __builtin_amdgcn_s_waitcnt(0); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
