Little disclaimer: I am not llvm expert and never created my own backend - in best case I can write simple optimization pass, lower yet another senseless MLIR dialect or extract some info from IR (and prefer gcc bcs its code more clean & neat and not scattered on thousands of sub-dirs as if written by an orthodox Java devotee), so take everything described below with healthy dose of skepticism
Task of searching for modifications/patches in general is well known, the problem in our case is that binary files is just huge
- cicc from SDK 13.1 has size 80mb
- libLLVM.so.21.1 128mb
CL options
Let's start with something easy - as you could know in llvm all CL options represented as static vars of template class cl::opt<Type>, like
static cl::opt<bool>
NVVMReflectEnabled("nvvm-reflect-enable", cl::init(true), cl::Hidden,
cl::desc("NVVM reflection, enabled by default"));
We can guess that code to create them must be located in array of constructors - in section .ctors or .init_array (actually second can have any name - only section type INIT_ARRAY matters). What really important here is that constructor of these object must load some constant strings from .rodata section
So I wrote dirty hack to disasm array of constructors and dump all used string to file. Results:
I also wrote simple script for comparison, so just run
perl cstr.pl clang-cstr.txt cicc-cstr.txt
What interesting we can note in its output?
- print-schedule - Print 'sched: [latency:throughput]' in .s output
- wmma-memory-space-opt
- dump-ir-before-memory-space-opt & dump-ir-after-memory-space-opt
- enable-bfi64 - Enable generation of 64-bit BFI instructions
- nvptx-add-scalar-move-for-vector-load, nvptx-lower-global-ctor-dtor & nvptx-use-max-local-array-alignment