banach-space / llvm-tutor

A collection of out-of-tree LLVM passes for teaching and learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to generate LLVM IR files for a whole project?

meweez opened this issue · comments

Hello
Thank you for your useful repository.
I have a question about generating .ll files, you used this command:

$LLVM_DIR/bin/clang -S -emit-llvm ../inputs/input_for_hello.c -o input_for_hello.ll

The question is how to generate this for all source files of a project, also each file has some included header files.
for example how to generate LLVM IR for all of the source files in Libgd?
I have tried this way but the result was almost empty:

$LLVM_DIR/clang -emit-llvm -S -O0 src/gd_tiff.c -o src/gd_tiff.ll

Thank you very much.

Hello @peach-byte!

Thank you for using llvm-tutor and for submitting this issue. I think that in order to generate LLVM IR files for a larger project you'd have to tweak the corresponding CMake scripts.

Basically, various files within a project will depend on each other. These dependencies are expressed through the build scripts. So basically you'd want to tweak your scripts so that the compiler runs:

  • clang -S -emit-llvm
    instead of e.g.
  • clang

Does this help in any way?

Closing for now. Please feel free to re-open if you have further questions/comments!

Thank you, I also found this useful repo in order to generate a whole project llvm IR.

Looks very interesting, thank you for sharing!