Issue 239597
Summary [AMDGPU] Clang codegen crash on monitor-load with invalid memory ordering
Labels backend:AMDGPU, crash-on-invalid
Assignees Pierre-vh
Reporter jayfoad
    See repro (generated by Claude). This seems to have been introduced by #177343.

```
// Clang crash: an invalid memory order on an AMDGPU monitor-load or
// cooperative-atomic builtin gives only a warning in Sema, but the call is
// dropped and CodeGen hits
//   UNREACHABLE executed at clang/lib/CodeGen/CodeGenTypes.cpp:618!
//
// Run each case separately, e.g.:
//   clang -cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1250 \
//         -cl-std=CL2.0 -emit-llvm -o /dev/null -DCASE=1 repro.cl
// CASE=0 is a valid control and compiles; every other case crashes.

typedef int int2 __attribute__((ext_vector_type(2)));
typedef int int4 __attribute__((ext_vector_type(4)));

#if CASE == 0
int f(global int *p) { return __builtin_amdgcn_global_load_monitor_b32(p, __ATOMIC_ACQUIRE, __MEMORY_SCOPE_DEVICE); }

// Monitor loads: release and acq_rel are invalid for a load.
#elif CASE == 1
int f(global int *p) { return __builtin_amdgcn_global_load_monitor_b32(p, __ATOMIC_RELEASE, __MEMORY_SCOPE_DEVICE); }
#elif CASE == 2
int f(global int *p) { return __builtin_amdgcn_global_load_monitor_b32(p, __ATOMIC_ACQ_REL, __MEMORY_SCOPE_DEVICE); }
#elif CASE == 3
int2 f(global int2 *p) { return __builtin_amdgcn_global_load_monitor_b64(p, __ATOMIC_RELEASE, __MEMORY_SCOPE_DEVICE); }
#elif CASE == 4
int4 f(global int4 *p) { return __builtin_amdgcn_global_load_monitor_b128(p, __ATOMIC_RELEASE, __MEMORY_SCOPE_DEVICE); }
#elif CASE == 5
int f(int *p) { return __builtin_amdgcn_flat_load_monitor_b32(p, __ATOMIC_RELEASE, __MEMORY_SCOPE_DEVICE); }
#elif CASE == 6
int2 f(int2 *p) { return __builtin_amdgcn_flat_load_monitor_b64(p, __ATOMIC_ACQ_REL, __MEMORY_SCOPE_DEVICE); }
#elif CASE == 7
int4 f(int4 *p) { return __builtin_amdgcn_flat_load_monitor_b128(p, __ATOMIC_RELEASE, __MEMORY_SCOPE_DEVICE); }

// Cooperative atomic loads: release and acq_rel are invalid.
#elif CASE == 8
int f(int *p) { return __builtin_amdgcn_cooperative_atomic_load_32x4B(p, __ATOMIC_RELEASE, "agent"); }
#elif CASE == 9
int2 f(int2 *p) { return __builtin_amdgcn_cooperative_atomic_load_16x8B(p, __ATOMIC_ACQ_REL, "agent"); }
#elif CASE == 10
int4 f(int4 *p) { return __builtin_amdgcn_cooperative_atomic_load_8x16B(p, __ATOMIC_RELEASE, "agent"); }

// Cooperative atomic stores: acquire and acq_rel are invalid.
#elif CASE == 11
void f(int *p, int v) { __builtin_amdgcn_cooperative_atomic_store_32x4B(p, v, __ATOMIC_ACQUIRE, "agent"); }
#elif CASE == 12
void f(int2 *p, int2 v) { __builtin_amdgcn_cooperative_atomic_store_16x8B(p, v, __ATOMIC_ACQ_REL, "agent"); }
#elif CASE == 13
void f(int4 *p, int4 v) { __builtin_amdgcn_cooperative_atomic_store_8x16B(p, v, __ATOMIC_ACQUIRE, "agent"); }
#endif
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to