[LLVMdev] Running opt pass at compile time

hdwivedi at codeaurora.org hdwivedi at codeaurora.org
Thu Feb 20 06:25:00 PST 2014


Hi,
To generate a call graph for a file(say foo.c), I can do:

clang -S -emit-llvm foo.c -o - | opt -analyze -dot-callgraph

However with this approach I have to run this command and pipe to opt
every single time I need to generate a callgraph.

For a project with many files and a complex build system, it would be
preferable for me to be able to invoke this transform as part of normal
build process by the use of some clang flag. Can I do something like:

clang -run-dot-callgraph-transform-flag foo.c ?
This would allow me to just modify the CFLAGS in Makefile and get results
as part of normal build process?

If this can't be done with stock clang, what can I modify in llvm source
to get something like this?

Thanks,
Harsh




More information about the llvm-dev mailing list