clspv
clspv copied to clipboard
stores involving GEP of aggregates of pointers hits invalid BitCast assert
This line overwrites the target triple to "spir-unknown-unknown" and triggers the following two warnings
warning: overriding the module target triple with spir-unknown-unknown
warning: Linking two modules of different data layouts: 'Unknown buffer' is 'e-p:3
2:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024' whereas 'kernel.ll' is 'e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024'
followed by the following assertion failure:
Assertion failed: (New->getType() == getType() && "replaceAllUses of value with new value of different type!"), function doRAUW, file /Users/nicholaswilson/d/llvm/clspv/clspv/third_party/llvm/llvm/lib/IR/Value.cpp, line 494.
for the attached file kernel.ll.txt.
I don't know a whole lot about clang, but it seems to me that the correct triple should be recoverable from the kernelFile parameter of SetCompilerInstanceOptions, either that or add an extra command line argument.
I'll try to figure it out and have a PR soon.
Hmm, so apparently it doesn't like the bitcasts present. The warnings still make me nervous.
https://godbolt.org/z/9Ka6jzbrY This is now passing.
I still needed to fix a few things in the kernel as shown in compiler-explorer:
- I needed to use the same data layout as the one in the builtin library to avoid the link warning
- _Z13get_global_idj needs to return an i32. Plus adding bitcast to i64 to keep everyone coherent.
Thanks!