RFC: clc/rusticl: binary size reduction of compiled spirvs
I've played around in order to reduce CPU and memory overhead of compiling OpenCL C.
There are several things here:
- serialize
clc_parsed_spirv
so it can be cached alongside spirvs when e.g. caching the OpenCL C -> SPIR-V compilation - run some LLVM passes on the generated LLVM module (cuts size by roughly 25%)
- optimize the spirv (cuts size by roughly 20%)
There is also a bit of more potential, as I can further cut the size of the final spirv by 50% by running MergeFunctions
. Sadly this has a chance of generating function pointers which we can't handle without also supporting SPV_INTEL_function_pointers
.
I didn't do any actual proper CPU performance analysis on this, but I'd expect that doing the size reduction early on will save us a lot of CPU time inside spirv_to_nir
and clc_parse_spirv
.