LinuxCommandLibrary

lli

Execute LLVM bitcode directly

TLDR

Execute a bitcode or IR file

$ lli [path/to/file.ll]
copy

Execute with command-line arguments
$ lli [path/to/file.ll] [argument1 argument2 ...]
copy

Enable all optimizations
$ lli -O3 [path/to/file.ll]
copy

Load a dynamic library before linking
$ lli --dlopen=[path/to/library.dll] [path/to/file.ll]
copy

SYNOPSIS

lli [options] filename [program arguments]

PARAMETERS

-help
    Display available options.

-version
    Display the version of lli.

-jit-kind=
    Specify which kind of JIT compiler to use. Values include: mcjit, or lli.

filename
    The LLVM bitcode file (.bc) or LLVM assembly file (.ll) to execute.

[program arguments]
    Arguments passed to the interpreted program.

DESCRIPTION

The `lli` command is part of the LLVM (Low Level Virtual Machine) project. It's an interpreter that directly executes LLVM bitcode files (.bc) or LLVM assembly language files (.ll). Unlike a traditional compiler which translates code into machine-specific instructions, `lli` interprets the bitcode at runtime. This is useful for rapid prototyping, testing, and debugging LLVM code without the overhead of compiling to native machine code. lli directly interprets LLVM bitcode, making it suitable for scenarios where compilation to native code is not desirable or feasible. For example, when targeting esoteric or unavailable architectures. While `lli` can be convenient, it typically performs slower than native executables compiled from LLVM bitcode using `llc` because of the interpretation overhead. However, it provides a simpler and faster development cycle for quick iterations and proof-of-concept implementations.

CAVEATS

lli execution speed is significantly slower than native code generated by llc. It's designed for debugging and testing, not for production deployment. It requires LLVM to be installed on the system.

DEBUGGING

lli can be used in conjunction with LLVM's debugging tools, such as the LLVM debugger (LLDB), to step through and inspect the execution of LLVM bitcode. This allows for detailed analysis of the program's behavior.

SECURITY CONSIDERATIONS

Running untrusted bitcode with lli can pose security risks, especially if the bitcode contains malicious code. Exercise caution when executing bitcode from unknown sources.

HISTORY

lli has been part of the LLVM project since its early days. It was initially designed as a simple way to execute LLVM bitcode without requiring a full-fledged compiler. Over time, it has been refined and optimized, but its primary purpose remains the same: to provide a convenient interpreter for LLVM bitcode. It helps developers rapidly test and debug LLVM IR transformations.

SEE ALSO

llc(1), opt(1), llvm-dis(1)

Copied to clipboard