clspv icon indicating copy to clipboard operation
clspv copied to clipboard

Invalid SPIR-V generated from local memory pointer bitcasts

Open jrprice opened this issue 4 years ago • 4 comments

This kernel:

__kernel void foo(
 constant const uchar *indices,
 local int4* __shared)
{
  int x = get_local_id(0);
  short _827 = ((local short *)__shared)[x];
  uchar _833 = indices[_827];
  int y = x + 4872;
  ((local uchar *)__shared)[y] = _833;
}

produces the following SPIR-V validation error:

error: line 75: OpStore Pointer <id> '55[%55]' is not a logical pointer.
  OpStore %55 %50

since the OpStore's pointer operand comes from an OpBitcast instruction.

jrprice avatar Mar 18 '20 20:03 jrprice

This is a problem with replace pointer bitcasts. The load is ok, but the store requires an atomic xor to implement correctly.

alan-baker avatar Mar 19 '20 20:03 alan-baker

There is a problem with ReplaceLLVMIntrinsicsPass::replaceMemcpy. CI->getArgOperand(0) and CI->getArgOperand(1) returns can be a GEPOperator instead of a BitCastOperator. So, some logic must be added to cover the GEPOperator case. @alan-baker, may I work on this issue to understand more about clspv?

andreperezmaselco avatar Mar 22 '20 18:03 andreperezmaselco

@andreperezmaselco that sounds like a separate issue from this. You're welcome to take a look, but please file an issue for it.

alan-baker avatar Mar 23 '20 12:03 alan-baker

I'll file this issue, @alan-baker. Thank you.

andreperezmaselco avatar Mar 23 '20 13:03 andreperezmaselco

This is now passing

rjodinchr avatar Mar 29 '23 09:03 rjodinchr