https://github.com/ssahasra created https://github.com/llvm/llvm-project/pull/188890
The tests demonstrate how incorrect LLVM IR is generated without diagnostics, when an OpenCL or HIP scope number is passed to an AMDGPU intrinsic. #185408 lays the groundwork for properly diagnosing this situation by internally using a separate enum type to represent each set of scope numbers. >From 601d50289bd5ba36f92f0c636310901852cad31f Mon Sep 17 00:00:00 2001 From: Sameer Sahasrabuddhe <[email protected]> Date: Fri, 27 Mar 2026 06:33:19 +0530 Subject: [PATCH] [Clang][NFC] Pre-commit tests for #185408 The tests demonstrate how incorrect LLVM IR is generated without diagnostics, when an OpenCL or HIP scope number is passed to an AMDGPU intrinsic. #185408 lays the groundwork for properly diagnosing this situation by internally using a separate enum type to represent each set of scope numbers. --- clang/test/CodeGenHIP/incorrect-atomic-scope.hip | 10 ++++++++++ clang/test/CodeGenOpenCL/incorrect-atomic-scope.cl | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 clang/test/CodeGenHIP/incorrect-atomic-scope.hip create mode 100644 clang/test/CodeGenOpenCL/incorrect-atomic-scope.cl diff --git a/clang/test/CodeGenHIP/incorrect-atomic-scope.hip b/clang/test/CodeGenHIP/incorrect-atomic-scope.hip new file mode 100644 index 0000000000000..6ededb84c6eac --- /dev/null +++ b/clang/test/CodeGenHIP/incorrect-atomic-scope.hip @@ -0,0 +1,10 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx942 -x hip -emit-llvm -fcuda-is-device %s -o - | FileCheck %s + +#define __device__ __attribute__((device)) + +// CHECK: atomicrmw {{.*}} syncscope("singlethread") + +__device__ void test(__attribute__((address_space(3))) float *out, float src) { + *out = __builtin_amdgcn_ds_fmaxf(out, src, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT, false); // produces the wrong scope, and there is no check for it. +} diff --git a/clang/test/CodeGenOpenCL/incorrect-atomic-scope.cl b/clang/test/CodeGenOpenCL/incorrect-atomic-scope.cl new file mode 100644 index 0000000000000..7e884b911c014 --- /dev/null +++ b/clang/test/CodeGenOpenCL/incorrect-atomic-scope.cl @@ -0,0 +1,13 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK %s +// RUN: %clang_cc1 -triple spirv64-amd-amdhsa -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK %s + +// CHECK: atomicrmw {{.*}} syncscope("workgroup") + +#if !defined(__SPIRV__) +void test(local float *out, float src) { +#else +void test(__attribute__((address_space(3))) float *out, float src) { +#endif + *out = __builtin_amdgcn_ds_fmaxf(out, src, __ATOMIC_RELAXED, __OPENCL_MEMORY_SCOPE_DEVICE, false); // produces the wrong scope, and there is no check for it. +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
