<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 2, 2015 at 10:39 AM, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On 2 Dec 2015, at 18:30, Phil Tomson <<a href="mailto:phil.a.tomson@gmail.com">phil.a.tomson@gmail.com</a>> wrote:<br>
><br>
>> If you want to pass LLVM arguments to clang, then you must prefix them with -llvm (e.g. -mllvm -loops -mllvm lcssa).<br>
><br>
><br>
> I just tried this:<br>
> CFLAGS += -mllvm adce -mllvm loops -mllvm loop-simplify -mllvm lcssa -mllvm simplify-libcalls<br>
><br>
> And get:<br>
><br>
> clang (LLVM option parsing): Unknown command line argument 'adce'.  Try: 'clang (LLVM option parsing) -help'<br>
> clang (LLVM option parsing): Unknown command line argument 'loops'.  Try: 'clang (LLVM option parsing) -help'<br>
> clang (LLVM option parsing): Unknown command line argument 'loop-simplify'.  Try: 'clang (LLVM option parsing) -help'<br>
> clang (LLVM option parsing): Unknown command line argument 'lcssa'.  Try: 'clang (LLVM option parsing) -help'<br>
> clang (LLVM option parsing): Unknown command line argument 'simplify-libcalls'.  Try: 'clang (LLVM option parsing) -help'<br>
<br>
</span>Sorry, I wasn’t thinking.  These are options provided by opt, not by LLVM libraries.  Clang has made an explicit design decision not to expose the optimisation pipeline details to consumers (because it’s far from stable and there is no desire to maintain backwards compatibility for things that are implementation details and because it’s very hard for someone to use correctly).  Your best bet if you *really* want this is probably to wrap clang in a shell script that does something along the lines of clang -c -emit-llvm && opt -whatever | llc, with appropriate handling / replacing of the last -o argument to clang.<br></blockquote><div><br></div><div>I have a feeling this would get rather tricky given that there are several libraries linked in to the final executable as well. It would have to look something like:<br><br></div><div>clang -c file.c -emit-llvm > opt -... > llc ... > as > ld (libs to link in)<br><br></div><div>Someone above mentioned modifying PassManagerBuilder and rebuilding clang - I'd guess there's a list of optimization passes performed somewhere that PassManagerBuilder references, but I haven't been in the optimization pass area of LLVM much yet. Any pointers on that approach?<br><br></div><div>Phil<br></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><font color="#888888"><br>
David<br>
<br>
</font></span></blockquote></div><br></div></div>