[llvm-dev] Is there a way to pass Optimization passes to clang?

Phil Tomson via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 2 09:56:14 PST 2015


 0 down vote favorite
<http://stackoverflow.com/questions/34049511/how-to-pass-optimization-passes-to-clang#>

I'm trying to debug an issue for a new target where a testcase fails with
-O1 optimization and passes with -O0 optimization.

I got a list of optimization passes being performed when 'clang -O1' is
called like this:

llvm-as < /dev/null | opt -O1 -disable-output -debug-pass=Arguments

Which results in:

Pass Arguments:  -no-aa -tbaa -targetlibinfo -basicaa -notti -preverify
-domtree -verify -simplifycfg -domtree -sroa -early-cse -lower-expect
Pass Arguments:  -targetlibinfo -no-aa -tbaa -basicaa -notti -globalopt
-ipsccp -deadargelim -instcombine -simplifycfg -basiccg -prune-eh
-inline-cost -always-inline -functionattrs -sroa -domtree -early-cse
-simplify-libcalls -lazy-value-info -jump-threading -correlated-propagation
-simplifycfg -instcombine -tailcallelim -simplifycfg -reassociate -domtree
-loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch
-instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom
-loop-deletion -loop-unroll -memdep -memcpyopt -sccp -instcombine
-lazy-value-info -jump-threading -correlated-propagation -domtree -memdep
-dse -adce -simplifycfg -instcombine -strip-dead-prototypes -preverify
-domtree -verify

(BTW: why are there two Pass Arguments lists returned there?)

Now my intent is to figure out which optimization pass is causing the
problem by trying each one until I hit the same problem as with -O1, but
clang itself doesn't seem to allow these commandline options, for example:

clang -loops -lcssa ....

Results in:

clang: warning: -loops: 'linker' input unused
clang: warning: -lcssa: 'linker' input unused


(Makes sense as it conflicts with the -l command line opt)
So is there a way to pass these in on the command line? (or bonus if
there's a way to specify a file which contains a list of optimization
passes to perform)


Note: I realize there must be a way to break everything up into stages and
use *opt* at some point and pass the optimization command line options to
it, but I've got a pretty large set of Makefiles which would need to change
to do that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151202/d86c2e75/attachment.html>


More information about the llvm-dev mailing list