llvm-dis
Disassemble LLVM bitcode into assembly language
TLDR
Convert a bitcode file as LLVM IR and write the result to stdout
Convert a bitcode file to an LLVM IR file with the same filename
Convert a bitcode file to LLVM IR, writing the result to the specified file
SYNOPSIS
llvm-dis [options] <input LLVM bitcode file>
PARAMETERS
-o <filename>
Specifies the output filename. If <filename> is "-", output goes to standard output. If this option is omitted, output defaults to standard output.
-force
Forces disassembly even if the input file does not have a standard LLVM bitcode extension (e.g., .bc or .ll).
-help
Displays a summary of command-line options.
-version
Prints the version of llvm-dis.
-stats
Prints statistics about the processed bitcode file.
-time-passes
Times each pass during the disassembly process, useful for performance analysis.
-disable-output
Discards the disassembled output, primarily used in conjunction with -time-passes for benchmarking purposes.
DESCRIPTION
llvm-dis is a fundamental utility within the LLVM compiler infrastructure, designed to translate LLVM bitcode files back into human-readable LLVM assembly language (LLVM IR). LLVM bitcode is a platform-independent binary representation of compiled code. This tool is invaluable for developers, debuggers, and researchers who need to inspect the intermediate representation of code, understand compiler optimizations, or debug issues at a low level.
It effectively allows one to see the "assembly" generated by the LLVM frontend before it's compiled down to native machine code by the backend. By default, llvm-dis prints the disassembled output to standard output, but an output file can be specified using the -o option. It supports various options for fine-tuning the disassembly process or for obtaining additional diagnostic information.
CAVEATS
The input file must be valid LLVM bitcode; otherwise, llvm-dis will report an error. Note that this tool disassembles to LLVM IR, not native machine code assembly. For native assembly, consider using llc or llvm-objdump.
DEFAULT OUTPUT
By default, the disassembled LLVM IR is printed to standard output. Redirecting it to a file using shell redirection (e.g., `>`) or the -o option is common practice for saving the output.
EXIT STATUS
The command exits with a zero status code upon successful execution. A non-zero status code indicates an error, such as an invalid or corrupted input bitcode file.
HISTORY
llvm-dis is a fundamental tool that has been an integral part of the LLVM project since its early days. LLVM, initiated by Chris Lattner at the University of Illinois in 2000, was designed from the ground up with a robust intermediate representation (IR). Tools like llvm-dis were essential from the start to allow developers to inspect and debug this IR, making the LLVM toolchain transparent and extensible. Its development closely mirrors the evolution of the LLVM IR itself.
SEE ALSO
llvm-as(1), lli(1), opt(1), llc(1), llvm-objdump(1), llvm-link(1)