Skip to content

Commit f8cb9a5

Browse files
svenvhvladimirlaz
authored andcommitted
Add volatile qualifier for atom_ builtins
Commit 10dee68 ("Fix translation of 64-bit atomics to OpenCL 1.2", 2019-08-15) changes the "atomic_" prefix to "atom_" for 64-bit types, but this caused the "atom_" builtins to no longer have the volatile qualifier to their pointer argument. Update the atomics_int64.spt test to check for the fully mangled names; these should include the volatile qualifier.
1 parent 7df0e1f commit f8cb9a5

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,14 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
483483
addUnsignedArg(0);
484484
setEnumArg(1, SPIR::PRIMITIVE_MEMORY_ORDER);
485485
setEnumArg(2, SPIR::PRIMITIVE_MEMORY_SCOPE);
486+
} else if (UnmangledName.find("atom_") == 0) {
487+
setArgAttr(0, SPIR::ATTR_VOLATILE);
488+
if (UnmangledName.find("atom_umax") == 0 ||
489+
UnmangledName.find("atom_umin") == 0) {
490+
addUnsignedArg(0);
491+
addUnsignedArg(1);
492+
UnmangledName.erase(5, 1);
493+
}
486494
} else if (UnmangledName.find("atomic") == 0) {
487495
setArgAttr(0, SPIR::ATTR_VOLATILE);
488496
if (UnmangledName.find("atomic_umax") == 0 ||

llvm-spirv/test/transcoding/atomics_int64.spt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@
5656
; RUN: FileCheck %s < %t.ll
5757

5858
; OpAtomicLoad is emulated via atom_add(*p, 0)
59-
; CHECK: call spir_func i64 @_Z8atom_add
59+
; CHECK: call spir_func i64 @_Z8atom_addPU3AS4Vll
6060

6161
; OpAtomicStore is emulated via atom_xchg(*p, val)
62-
; CHECK: call spir_func i64 @_Z9atom_xchg
62+
; CHECK: call spir_func i64 @_Z9atom_xchgPU3AS4Vll
6363

64-
; CHECK: call spir_func i64 @_Z9atom_xchg
65-
; CHECK: call spir_func i64 @_Z12atom_cmpxchg
66-
; CHECK: call spir_func i64 @_Z8atom_inc
67-
; CHECK: call spir_func i64 @_Z8atom_dec
68-
; CHECK: call spir_func i64 @_Z8atom_add
69-
; CHECK: call spir_func i64 @_Z8atom_sub
70-
; CHECK: call spir_func i64 @_Z8atom_min
71-
; CHECK: call spir_func i64 @_Z8atom_min
72-
; CHECK: call spir_func i64 @_Z8atom_max
73-
; CHECK: call spir_func i64 @_Z8atom_max
74-
; CHECK: call spir_func i64 @_Z8atom_and
75-
; CHECK: call spir_func i64 @_Z7atom_or
76-
; CHECK: call spir_func i64 @_Z8atom_xor
64+
; CHECK: call spir_func i64 @_Z9atom_xchgPU3AS4Vll
65+
; CHECK: call spir_func i64 @_Z12atom_cmpxchgPU3AS4Vlll
66+
; CHECK: call spir_func i64 @_Z8atom_incPU3AS4Vl
67+
; CHECK: call spir_func i64 @_Z8atom_decPU3AS4Vl
68+
; CHECK: call spir_func i64 @_Z8atom_addPU3AS4Vll
69+
; CHECK: call spir_func i64 @_Z8atom_subPU3AS4Vll
70+
; CHECK: call spir_func i64 @_Z8atom_minPU3AS4Vll
71+
; CHECK: call spir_func i64 @_Z8atom_minPU3AS4Vmm
72+
; CHECK: call spir_func i64 @_Z8atom_maxPU3AS4Vll
73+
; CHECK: call spir_func i64 @_Z8atom_maxPU3AS4Vmm
74+
; CHECK: call spir_func i64 @_Z8atom_andPU3AS4Vll
75+
; CHECK: call spir_func i64 @_Z7atom_orPU3AS4Vll
76+
; CHECK: call spir_func i64 @_Z8atom_xorPU3AS4Vll
7777

7878
; OpAtomicFlagTestAndSet is emulated via atomic_xchg(*p, 1)
7979
; CHECK: call spir_func i32 @_Z11atomic_xchg

0 commit comments

Comments
 (0)