clspv icon indicating copy to clipboard operation
clspv copied to clipboard

Invalid SPIR-V generated from selection of __constant pointers

Open alan-baker opened this issue 7 years ago • 0 comments

__constant int const_array[] = {0,1,2,3};

void bar(__global int* data, __constant int* c1, __constant int* c2, int x) {
  __constant int* c = (x == 0) ? c1 : c2;
  *data = *c;
}

__kernel void foo(__global int* data, __constant int* const_arg, int x) {
  bar(data, const_array, const_arg, x);
}

clspv generates const_array as a variable in the Private storage class. The ternary statement in bar attempts to produce a StorageBuffer storage class pointer by selecting between a Private storage class pointer and StorageBuffer storage class pointer. This is invalid SPIR-V.

The resolution of this issue should also work with #208.

alan-baker avatar Oct 03 '18 18:10 alan-baker