Intermediate representation
clang --help
-emit-llvm Use the LLVM representation for assembler and object files
-S Only run preprocess and compilation steps
clang -S -emit-llvm ex.c
generates a text fileex.ll
.clang -c -emit-llvm ex.c
generates a binary fileex.bc
.llvm-dis ex.bc
generates a fileex.ll
, which is identical with the file generated using ``clang -S -emit-llvm ex.c`.llvm-as ex.ll
generates a fileex.bc
, which is identical with the file generated usingclang -c -emit-llvm ex.c
.llc ex.ll
generates the assembly fileex.s
lli ex.ll
can run this file. Useecho $?
to see the return value.
See https://llvm.org/devmtg/2019-04/slides/Tutorial-Bridgers-LLVM_IR_tutorial.pdf.