- Latest (GraalVM for JDK 21)
- Dev Build
- GraalVM for JDK 21
- GraalVM for JDK 20
- GraalVM for JDK 17
- GraalVM 22.3
- GraalVM 22.2
- GraalVM 22.1
- GraalVM 22.0
- GraalVM 21.3
- Java on Truffle
- LLVM Languages Reference
- Compiling Native Projects to LLVM Bitcode
- Interaction of GraalVM with Native Code
- GraalVM LLVM Runtime Debugging
- LLI Command Options
- LLVM Compatibility
- Python Reference
- Ruby Reference
- R Reference
- WebAssembly Reference
GraalVM supports LLVM bitcode versions 4.0 to 12.0.1. 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 Graal compiler.
First, the LLVM frontend (e.g.,
clang) performs optimizations on the bitcode level, and then the Graal 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 Graal 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.