How to use LLVM optimizations with clang

Yes. But how exactly code generation (optimized one) be done without
clang. Is it possible that we can specify those optimization
(individual ones instead of standard ones like -O3) some how when
generating code as is done by clang or llc?

llc comb.ll
gcc -o comb comb.s

Variants:
   llc -O0 comb.ll
   llc -O3 comb.ll
etc

Note that the codegen level optimizations done by llc have nothing to do with
the IR level optimizations of the kind performed by opt.

Ciao, Duncan.

Thanks alot. How can we view those optimization which are enabled when we do

llc -O3 comb.ll

Are these the same as the ones produced by the following command line

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

Regards

Shahzad

Hi,

Thanks alot. How can we view those optimization which are enabled when we do

llc -O3 comb.ll

llc -O3 comb.ll -debug-pass=Arguments

Are these the same as the ones produced by the following command line

no, as I mentioned before they are of a completely different nature
to the optimizations that opt does.

Ciao, Duncan.

Thanks again.

I executed the following command line

llc -O3 comb.ll.bc -debug-pass=Arguments

and got

Pass Arguments: -targetdata -targetpassconfig -no-aa -tbaa
-targetlibinfo -basicaa -collector-metadata -machinemoduleinfo
-machine-branch-prob -preverify -domtree -verify -loops -loop-simplify
-scalar-evolution -loop-simplify -iv-users -loop-reduce -gc-lowering
-unreachableblockelim -codegenprepare -stack-protector -preverify
-domtree -verify -loops -branch-prob -expand-isel-pseudos
-tailduplication -opt-phis -localstackalloc -dead-mi-elimination
-machinedomtree -machine-loops -machinelicm -machine-cse -machine-sink
-peephole-opts -unreachable-mbb-elimination -livevars
-phi-node-elimination -twoaddressinstruction -processimpdefs
-slotindexes -liveintervals -livedebugvars -simple-register-coalescing
-calcspillweights -livestacks -virtregmap -edge-bundles
-spill-code-placement -stack-slot-coloring -machinelicm -edge-bundles
-prologepilog -branch-folder -tailduplication -machine-cp
-postrapseudos -machinedomtree -machine-loops -post-RA-sched
-gc-analysis -machine-block-freq -block-placement2 -machinedomtree
-machine-loops

Now, how can I specify these optimization manually along with llc like
we did with opt tool?

Regards

Shahzad

Hi,

I executed the following command line

llc -O3 comb.ll.bc -debug-pass=Arguments

and got

Pass Arguments: -targetdata -targetpassconfig -no-aa -tbaa
-targetlibinfo -basicaa -collector-metadata -machinemoduleinfo
-machine-branch-prob -preverify -domtree -verify -loops -loop-simplify
-scalar-evolution -loop-simplify -iv-users -loop-reduce -gc-lowering
-unreachableblockelim -codegenprepare -stack-protector -preverify
-domtree -verify -loops -branch-prob -expand-isel-pseudos
-tailduplication -opt-phis -localstackalloc -dead-mi-elimination
-machinedomtree -machine-loops -machinelicm -machine-cse -machine-sink
-peephole-opts -unreachable-mbb-elimination -livevars
-phi-node-elimination -twoaddressinstruction -processimpdefs
-slotindexes -liveintervals -livedebugvars -simple-register-coalescing
-calcspillweights -livestacks -virtregmap -edge-bundles
-spill-code-placement -stack-slot-coloring -machinelicm -edge-bundles
-prologepilog -branch-folder -tailduplication -machine-cp
-postrapseudos -machinedomtree -machine-loops -post-RA-sched
-gc-analysis -machine-block-freq -block-placement2 -machinedomtree
-machine-loops

Now, how can I specify these optimization manually along with llc like
we did with opt tool?

you can't.

Ciao, Duncan.

Thanks alot Duncan.

Regards

Shahzad