- Native Image
- GraalVM Updater
- Embedding Reference
- Polyglot Programming
- JVM Languages Reference
- LLVM Languages Reference
- Compiling Native Projects to LLVM Bitcode
- Limitations and Differences to Native Execution
- GraalVM LLVM Runtime Debugging
- LLI Command Options
- LLVM Compatibility
- Python Reference
- Ruby Reference
- R Reference Manual
- WebAssembly Reference
GraalVM supports LLVM bitcode versions 3.8 to 10.0. It is recommended to use the LLVM toolchain shipped with GraalVM.
Optimizations Flags #
In contrast to the static compilation model of LLVM languages, in GraalVM the machine code is not directly produced from the LLVM bitcode. There is an additional dynamic compilation step by the GraalVM compiler.
First, the LLVM frontend (e.g.,
clang) performs optimizations on
the bitcode level, and then the GraalVM compiler does its own optimizations on top of that
during dynamic compilation. Some optimizations are better when done
ahead-of-time on bitcode, while other optimizations are better left for the
dynamic compilation of the GraalVM compiler, when profiling information is available.
The LLVM toolchain that is shipped with GraalVM automatically selects the recommended flags by default.
Generally, all optimization levels should work, but for a better result, it is
recommended to compile the bitcode with the optimization level
For cross-language interoperability, the
-mem2reg optimization is required.
There are two ways to get that: either compile with at least
-O1, or use the
opt tool to apply the
-mem2reg optimization manually.