Summary:
The SPIR-V backend does not include Int64Atomics in the available capabilities for Vulkan targets. This causes a fatal error ("Unable to meet SPIR-V requirements for this target") when compiling any 64-bit atomic operation (e.g., OpAtomicIAdd on i64) for a Vulkan target.
Reproduction:
; RUN: llc -O0 -mtriple=spirv1.6-vulkan1.3-compute %s -o -
@gs_i64 = internal addrspace(3) global i64 zeroinitializer
define i64 @test_i64(i64 %v) {
entry:
%r = call i64 @llvm.spv.interlocked.add.i64.p3(
ptr addrspace(3) @gs_i64, i64 %v)
ret i64 %r
}
declare i64 @llvm.spv.interlocked.add.i64.p3(ptr addrspace(3), i64)
Output: LLVM ERROR: Unable to meet SPIR-V requirements for this target.
Root Cause:
In SPIRVModuleAnalysis.cpp, when an OpAtomicIAdd (or any atomic op) operates on a 64-bit integer type, the backend adds a requirement for Capability::Int64Atomics (line 1696). However, initAvailableCapabilitiesForVulkan() (lines 961-1006) does not include Int64Atomics in any of its capability sets (core 1.1, 1.2, or 1.3). The capability is only granted for OpenCL full profile targets (line 939). Since checkSatisfiable() finds Int64Atomics in the required set but not in the available set, it calls report_fatal_error.
Expected Behavior:
64-bit atomic operations should compile successfully for Vulkan targets. The backend should emit OpCapability Int64Atomics in the output SPIR-V module.
Suggested Fix:
Add Capability::Int64Atomics to the Vulkan available capabilities in initAvailableCapabilitiesForVulkan().
Context:
This was discovered while adding InterlockedAdd HLSL intrinsic support (#195742). The DirectX backend handles i64 atomics without issue, but the SPIRV backend cannot emit the equivalent i64 test due to this missing capability.
Summary:
The SPIR-V backend does not include
Int64Atomicsin the available capabilities for Vulkan targets. This causes a fatal error ("Unable to meet SPIR-V requirements for this target") when compiling any 64-bit atomic operation (e.g., OpAtomicIAdd on i64) for a Vulkan target.Reproduction:
declare i64 @llvm.spv.interlocked.add.i64.p3(ptr addrspace(3), i64)
Output: LLVM ERROR: Unable to meet SPIR-V requirements for this target.
Root Cause:
In SPIRVModuleAnalysis.cpp, when an OpAtomicIAdd (or any atomic op) operates on a 64-bit integer type, the backend adds a requirement for Capability::Int64Atomics (line 1696). However, initAvailableCapabilitiesForVulkan() (lines 961-1006) does not include Int64Atomics in any of its capability sets (core 1.1, 1.2, or 1.3). The capability is only granted for OpenCL full profile targets (line 939). Since checkSatisfiable() finds Int64Atomics in the required set but not in the available set, it calls report_fatal_error.
Expected Behavior:
64-bit atomic operations should compile successfully for Vulkan targets. The backend should emit OpCapability Int64Atomics in the output SPIR-V module.
Suggested Fix:
Add Capability::Int64Atomics to the Vulkan available capabilities in initAvailableCapabilitiesForVulkan().
Context:
This was discovered while adding InterlockedAdd HLSL intrinsic support (#195742). The DirectX backend handles i64 atomics without issue, but the SPIRV backend cannot emit the equivalent i64 test due to this missing capability.