LinuxCommandLibrary

llc

Compile LLVM IR to assembly language

TLDR

Compile a bitcode or IR file to an assembly file with the same base name

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

Enable all optimizations
$ llc -O3 [path/to/input.ll]
copy

Output assembly to a specific file
$ llc --output [path/to/output.s]
copy

Emit fully relocatable, position independent code
$ llc -relocation-model=pic [path/to/input.ll]
copy

SYNOPSIS

llc [options]

PARAMETERS

-O=
    Optimization level.
Possible values are: 0 (no optimization), 1 (basic optimization), 2 (aggressive optimization), 3 (heavy optimization).

-march=
    Target architecture. Examples: x86-64, arm64, riscv32.

-filetype=
    Output file type. Possible values include: asm (assembly code), obj (object file).

-relocation-model=
    Relocation model. Controls how the code is positioned in memory. Common values are: static, pic (position-independent code).

-mattr=
    Target specific attributes. Allows enabling/disabling specific CPU features. Example: +avx, -sse4.2.

-debug
    Enable debug information generation.

-help
    Display available command options

-version
    Display the version of the llc compiler.

DESCRIPTION

llc is a static single assignment (SSA) based compiler. It takes LLVM Intermediate Representation (IR) as input and produces assembly language code for a specified target architecture.

It is a crucial component of the LLVM toolchain, enabling developers to compile high-level code (like C, C++, Rust, or Swift) into machine-executable instructions. The command can generate code for multiple architectures. llc is typically used by other tools in the LLVM toolchain, such as clang, but can be invoked directly for specific optimization or code generation purposes. It allows control over various compilation parameters and optimization levels to achieve the desired performance characteristics.
llc allows you to explore and compare different backends supported by LLVM.
llc primarily focuses on lowering LLVM IR into machine code.

INPUT FILE FORMAT

llc requires a valid LLVM IR file as input. This can be in either text (.ll) or bitcode (.bc) format. The file can be specified directly on the command line.

TARGET TRIPLES

The target architecture can also be specified using the -mtriple option. This provides a more complete description of the target, including the architecture, vendor, and operating system.

SEE ALSO

clang(1), llvm-as(1), llvm-link(1)

Copied to clipboard