[LLVMdev] Cleanest way to do llvm-driven compile with specified passes

Stephen McGruer stephen.mcgruer at gmail.com
Tue Oct 16 06:07:14 PDT 2012

Hi there,

I have a target platform for which I'm compiling code with llvm and my own
backend. My current compilation route to create an executable is to just
call something like:

$ clang -O3 -ccc-host-triple arcompact [-I...] file_to_compile.c
another_file.c [-lm etc]

Importantly, clang here is running with the target version of gcc as the
driver, so that gcc (call it gcc-arcompact) takes care of calling the
correct assembler, linker, etc for the backend output.

Now what I want to do is select my own optimization passes specifically. As
far as I can tell, the following seems to be the only way to do it:

$ clang -S -emit-llvm -ccc-host-triple arcompact [--I... -L... etc]
file_to_compile.c another_file.c
$ opt [passes] file_to_compile.s | llc -march=arcompact -o file_to_compile.s
$ opt [passes] another_file.s | llc -march=arcompact -o another_file.s
$ gcc-arcompact [-L... etc] file_to_compile.s another_file.s [-lm etc]

Is there a cleaner way to do this - i.e. by telling clang what optimization
passes to run (or to pass onto the backend to run), or by not having to run
a unique opt command for each input file (of which there may be a few...)?

Thanks for any help,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121016/ff73fcb2/attachment.html>

More information about the llvm-dev mailing list