Search code examples
llvmopenclllvm-irllc

Illegal BitCast while compiling opencl kernel


The below bitcast instruction is throwing me an Illegal Bitcast error, can someone point what the problem is?

%opencl.image1d_ro_t = type opaque
%struct.dev_image_t = type { i8*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

%astype = bitcast %opencl.image1d_ro_t addrspace(1)* %image to %struct.dev_image_t*

Solution

  • You're casting from address space 1 to the default address space, 0. That won't work, as the documentation says. Each address space is independent.

    Address spaces are meant for things like programs that have some garbage-collected and some manually managed memory. The pointer points to two profoundly different kinds of memory.