A lot of LLVM languages like Rust support cross-language optimization at link time, allowing e.g. C code to be inlined and further optimized to LLVM’s wish. Since Julia also heavily uses LLVM (albeit in a more… just-in-time way), I wonder whether it’s worth looking at.
While the current ccall
works in a very traditional dlopen
paradiam with dynamic libraries, a LTO call would involve a search for the corresponding “static” library and fetching the bitcode from there.
Having peeked at how ccall.cpp
looks, I have… no idea whether this might even be possible with all the runtime functions that might need to be injected. I also have no idea how the extra bitcode files will fit into the JIT flow – are they additional modules now?