Description
Multiple SyCL CTS tests are triggering the "Interface variable is used by entry point, but is not listed as an interface" spir-v validation error, e.g. test_atomic_fence
; SPIR-V
; Version: 1.4
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 1113
; Schema: 0
...
OpEntryPoint Kernel %23 "_ZTSZZN17atomic_fence_test16run_atomic_fenceISt17integral_constantIN4sycl3_V112memory_orderELS4_3EES1_INS3_12memory_scopeELS6_2EES1_INS_9test_typeELS8_1EEEclERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESI_SI_ENKUlRNS3_7handlerEE_clESK_EUlNS3_7nd_itemILi1EEEE_"
...
%__spirv_BuiltInGlobalOffset = OpVariable %_ptr_CrossWorkgroup_v3ulong CrossWorkgroup
...
%23 = OpFunction %void None %22
...
%65 = OpLoad %v3ulong %__spirv_BuiltInGlobalOffset Aligned 32
From the SPIR-V specification on OpEntryPoint:
"Interface is a list of of global OpVariable instructions. These declare the set of global variables from a module that form the interface of this entry point. The set of Interface must be equal to or a superset of the global OpVariable Result referenced by the entry point’s static call tree, within the interface’s storage classes. Before version 1.4, the interface’s storage classes are limited to the Input and Output storage classes. Starting with version 1.4, the interface’s storage classes are all storage classes used in declaring all global variables referenced by the entry point’s call tree."
Side Note: the storage class of builtins also have to be in the Input
storage class according to the OpenCL SPIR-V Env specification in 2.9: "An OpVariable in a SPIR-V module with the BuiltIn decoration represents a built-in variable. All built-in variables must be in the Input storage class."
Side Note2: I'm confused this even comes up, as this issue was fixed years ago in the SPIRV-LLVM-Translator: