[llvm-dev] Testcase failing when compiled with clang -O2, but passing using opt

Phil Tomson via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 7 14:26:50 PST 2015

On Mon, Dec 7, 2015 at 1:41 PM, Phil Tomson <phil.a.tomson at gmail.com> wrote:

> I'm working on LLVM for a new target processor and we've got a testcase
> that fails with -O2 optimization is used. So I figured I'd figure out what
> optimizations are being applied with -O2 using:
>  $TG_BIN/opt -O2 -disable-output -debug-pass=Arguments some.bc
> then I figured I'd pass these to opt and remove one for each run until,
> though process of elimination, I had found the offending optimization.
> However, when I pass the full list of optimizations returned from that
> command above, I find that our test passes.
> Previously we were running the following in our Makefile to get the .o for
> the testcase (that was then later linked):
>      $(CC) $(CFLAGS) -fno-builtin -c $< -o $@
> (where CC=clang and CFAGS=-O2
> Now I'm running:
>       $(CC) -emit-llvm $(CFLAGS) -fno-builtin -c $< -o $(basename $<).bc
>       $(OPT) $(OPTS) -o $(basename $<).opt.bc $(basename $<).bc
>       $(LLC) $(basename $<).bc -o $(basename $<).s
>       $(AS) $(basename $<).s -o $@

Apologies, I had a typo there,should have been:

        $(LLC) $(basename $<).opt.bc -o $(basename $<).s

...no it fails as expected.

> Where OPTS is:
>      -datalayout -notti -no-aa -tbaa -scoped-noalias
> -assumption-cache-tracker -targetlibinfo -basicaa -verify -simplifycfg
> -domtree -sroa -early-cse -lower-expect -ipsccp -globalopt -deadargelim
> -instcombine -basiccg -prune-eh -inline-cost -inline -functionattrs
> -lazy-value-info -jump-threading -correlated-propagation -tailcallelim
> -reassociate -loops -loop-simplify -lcssa -loop-rotate -licm -loop-unswitch
> -scalar-evolution -indvars -loop-idiom -loop-deletion -function_tti
> -loop-unroll -memdep -mldst-motion -gvn -memcpyopt -sccp -dse -adce
> -barrier -branch-prob -block-freq -loop-vectorize -slp-vectorizer
> -alignment-from-assumptions -strip-dead-prototypes -globaldce -constmerge
> So I'm wondering why the former (passing the -O2 to clang) is failing
> while the latter passes our tests. Is there something I'm missing from the
> list of -O2 optimizations?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151207/2c9f8a1a/attachment.html>

More information about the llvm-dev mailing list