📝How-to: inspect LLVM IR

tags

#how-to LLVM IR

Compile with clang.

# generate bit-code
clang test.c -emit-llvm -c -o test.bc

# generate llvm assembly
clang test.c -emit-llvm -S -c -o test.ll

Bitcode to assembly:

llvm-dis test.bc -o test.ll

Extract specific globals:

llvm-extract -func=main test.bc -o test-main.bc

See also