llvm-project/clang/test/CodeGenHLSL/builtins/GroupMemoryBarrierWithGroupSync.hlsl
Finn Plummer 87e1da3f2e
[HLSL] Mark GroupMemoryBarrierWithGroupSync as convergent (#160175)
`GroupMemoryBarrierWithGroupSync` is required to be marked as convergent
so that it can't generate duplicate calls or be moved to identical
control flow.

Without it, we generate undefined behaviour during optimization. For
instance: https://godbolt.org/z/9j3vsq1h3.

Testing that the convergent attribute is added is sufficient. There
already exists testing,
[here](https://github.com/inbelic/llvm-project/blob/main/llvm/test/Transforms/SimplifyCFG/attr-convergent.ll),
that it will not be moved as described in the above link.
2025-09-22 19:18:28 +00:00

21 lines
1014 B
HLSL

// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: dxil-pc-shadermodel6.3-library %s \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
// RUN: -DTARGET=dx -check-prefixes=CHECK,CHECK-DXIL
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: spirv-unknown-vulkan-compute %s \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
// RUN: -DTARGET=spv -check-prefixes=CHECK,CHECK-SPIRV
// CHECK-DXIL: define hidden void @
// CHECK-SPIRV: define hidden spir_func void @
void test_GroupMemoryBarrierWithGroupSync() {
// CHECK-DXIL: call void @llvm.[[TARGET]].group.memory.barrier.with.group.sync()
// CHECK-SPIRV: call spir_func void @llvm.[[TARGET]].group.memory.barrier.with.group.sync()
GroupMemoryBarrierWithGroupSync();
}
// CHECK: declare void @llvm.[[TARGET]].group.memory.barrier.with.group.sync() #[[ATTRS:[0-9]+]]
// CHECK-NOT: attributes #[[ATTRS]] = {{.+}}memory(none){{.+}}
// CHECK: attributes #[[ATTRS]] = {{.+}}convergent{{.+}}