Add missing addrspace_operators.ll to kernel
Closes #1288
Not sure how this ever worked. The functions that implement this were simply missing. The file was unused. From what I can tell, this should have affected all platforms?! Is nobody using the CPU devices?
Thanks for the effort, however this won't work as it is. Let me try to explain. As you have noticed, commit 4500774f4af2a134e027169 removed these from lib/kernel/host. In short, the problem is: 1) __to_XYZ are operators, not functions -> Clang doesn't do name mangling on them; 2) you need two versions of each operator to support two different compilation inputs with the CPU driver (SPIR-V and OpenCL C source). In case of SPIR-V you need: ptr addrspace(1) __to_global(ptr addrspace(4) %p); in case of OpenCL C source you need ptr __to_global(ptr %p). This is because the LLVM IR output from SPIR-V translator has pointers with SPIR address space numbers (e.g. global is 1), while the OpenCL C compiled to LLVM IR with Clang has pointer address space numbers of the target (for CPU, all OpenCL address spaces map to zero). Both of these LLVM IR outputs need to be linked with PoCL's builtin library. Since LLVM IR doesn't support having two functions with the same name & different signature in the same bitcode file, we cannot implement the operators in the builtin library. That's why addrspace_operators.ll was removed from lib/kernel/host.
There are multiple solutions (changing SPIRV-translator to output target AS numbers, or having the operators in separate files and linking it separately). But the simplest solution right now, could be to add the triple-underscore names to the f->getName().equals("__to_local")... code block in commit 4500774f4af2a134e027169.
Actually after re-reading the bugreport, ignore my suggestion about triple-underscore names, they only appear in the .so object files, and with the CPU driver this should never happen. Seems like there's some bug in the code from commit 4500774 and it misses the calls (possibly the remove-inside-loop ?).
@franz maybe you missed the discussion in https://github.com/pocl/pocl/issues/1288?