Run LLVM Bitcode with GraalVM Enterprise

Oracle GraalVM Enterprise Edition ships with the LLVM runtime. It provides an implementation of the lli tool to directly execute programs from LLVM bitcode. The LLVM runtime is written in Java on top of the Truffle Language Implementation framework and uses the GraalVM dynamic compiler. You can execute C/C++, Rust and any programming language that can be compiled to LLVM bitcode by the LLVM front end such as clang.

Note: LLVM bitcode is platform dependent. The program must be compiled to bitcode for the appropriate platform.

To run programs in LLVM bitcode format:

lli [LLI option] filename.bc [program args]

Where filename.bc is a single program source file in LLVM bitcode format. Mandatory arguments to long options are mandatory for short options too.

GraalVM and Polyglot options are to be placed after LLI options, but before the bitcode file name: lli [LLI Options] [GraalVM Options] [Polyglot Options] filename.bc [program args]

LLI Options

Option Description
-L /--llvm.libraryPath= Add a list of paths where GraalVM will search for library dependencies. Paths are delimited by :.
–lib /--llvm.libraries= Add a list of libraries to load. The list can contain precompiled native libraries (.so/.dylib) and bitcode libraries (.bc). Files with a relative path are looked up relative to llvm.libraryPath. Entries are delimited by :.
--llvm.libraries= List of libraries (precompiled libraries .dylib/.so as well as bitcode libraries .bc). Files with a relative path will be looked up relative to llvm.libraryPath. Libraries are delimited by :.
--llvm.libraryPath= A list of paths where the LLVM runtime will search for relative libraries. Paths are delimited by :.
--llvm.managed Enable an experimental managed mode, which means memory allocations from LLVM bitcode are done on the managed heap.
--llvm.stackSize= The stack size, please end the input with one of: k, m, g, or t. Note: the stack size will be in bytes if no appropriate suffix is given.

GraalVM Options

Option Description
--jvm Execute an application in the JVM mode.
–-vm.<option> Pass JVM options to GraalVM. List available JVM options with
–-vm.Dgraal.<option> Pass settings to the GraalVM compiler. For example, --graal.DumpOnError=true sends the compiler intermediate representation (IR) to dump handlers if errors occur.
--engine.Mode=default Configure the execution mode of the engine. The execution mode automatically tunes the polyglot engine towards latency or throughput. throughput - collects the maximum amount of profiling information and compile using the maximum number of optimizations. This mode results in slower application startup but better throughput. This mode uses the compiler configuration community or enterprise if not specified otherwise. default - uses a balanced engine configuration. This mode uses the compiler configuration community or enterprise if not specified otherwise. latency - collects only minimal profiling information and compile as fast as possible with less optimal generated code. This mode results in faster application startup but less optimal throughput. This mode uses the compiler configuration economy if not specified otherwise.
--engine.CompilerConfiguration=name Select the GraalVM compiler configuration to use for polyglot application code. If omitted, the compiler configuration with the highest auto-selection priority is used. To see the set of available configurations, supply the value help to this option. The current configurations and their semantics are: enterprise - produces highly optimized code with a possible trade-off to compilation time. This value is only available in GraalVM Enterprise. community - produces reasonably optimized code with a faster compilation time. economy - compiles as fast as possible with less optimal throughput of the generated code.
--engine.TraceCompilation=false Print an informational line to the console for each completed compilation.
--experimental-options Unlock experimental features that are behind flags. For example, to use --memtracer, the memory allocations profiling tool, run lli --experimental-options --memtracer program.bc. The option is experimental.

Polyglot options

Option Description
--polyglot Run with all other guest languages accessible.
--<languageID>.<property>=<value> Pass properties to guest languages through the GraalVM Polyglot SDK.

The --<languageID>.<property>=<value> syntax is to allow any language launcher to access the options of other GraalVM supported languages.

More information on supported languages, runtimes and examples can be found in the reference manual for LLVM Runtime.

Warning: If the option is entitled as experimental, it might never be included in a production version, or might change significantly before being considered production-ready.