clspv icon indicating copy to clipboard operation
clspv copied to clipboard

clspv doesn't exit with an error code when a kernel uses an unsupported builtin

Open kpet opened this issue 7 years ago • 1 comments

Instead, it generates invalid SPIR-V that is usually caught by the validator.

Example builtin.cl source:

kernel void test_kernel(global float *in, global float *out)
{
    float3 a = vload3(0, in);
    vstore3(a, 0, out);
}

Compiling with clspv -o builtin.spv builtin.cl does produce a helpful error message:

Can't translate function call.  Missing builtin? _Z7vstore3Dv3_fjPU3AS1f in:   tail call spir_func void @_Z7vstore3Dv3_fjPU3AS1f(<3 x float> %call, i32 0, float addrspace(1)* %4) #2
Can't translate function call.  Missing builtin? _Z6vload3jPU3AS1Kf in:   %call = tail call spir_func <3 x float> @_Z6vload3jPU3AS1Kf(i32 0, float addrspace(1)* %2) #2

But the exit code is zero.

kpet avatar Sep 02 '18 17:09 kpet

Hm. Seems I already visited this before, but didn't finish:

      if (CalleeID == 0) {
        errs() << "Can't translate function call.  Missing builtin? "
               << callee_name << " in: " << *Call << "\n";
        // TODO(dneto): Can we error out?  Enabling this llvm_unreachable
        // causes an infinite loop.  Instead, go ahead and generate
        // the bad function call.  A validator will catch the 0-Id.
        // llvm_unreachable("Can't translate function call");
      }

dneto0 avatar Sep 04 '18 14:09 dneto0