So I was thinking about shifting the complexity and offline compilation and whether we may benefit from doing the transformations "online".
If we think about PolkaVM (or any other VM) holistically, as a process from the source code to performing the IO (host functions included) on the target machine, you can notice that there is a path through components with some boundaries. It's actually a graph, because there could be multiple producers for some components.
Right now, we have something like that
source → {Rust, C++} compiler → LLVM → [wasm-opt] → wasmtime → substrate/PVF host
you could drill down deeper into each of the components. rust has MIR. LLVM also has its internal representations as well as wasmtime. There is also a linker.