[LLVMdev] Reproducing output of llvm-gcc using opt tool

Chris Lattner sabre at nondot.org
Fri Dec 7 20:33:00 PST 2007


On Dec 7, 2007, at 1:43 AM, Wojciech Matyjewicz wrote:
> Recently, I was looking into the bug #1227. I wanted to check if
> reordering optimization passes could solve it. To start with, I  
> tried to
> reproduce the output of llvm-g++ -O3 using the combination of llvm-g++
> -O0 and opt with the appropriate passes. However, I was unable to. I  
> use
> SVN versions of llvm and llvm-gcc-4.2.
>
> First, I compile example.cpp (attached; taken from the bug #1227)  
> with:
> $ llvm-g++ -c -emit-llvm -O3 -fdebug-pass-arguments example.cpp -o
> example1.bc

This looks about right, you can also try opt -debug-pass=Arguments - 
std-compile-opts foo.bc -o foo.out.bc

> Next, I run:
> $ llvm-g++ -c -emit-llvm -O0 example.cpp -o - | opt /switches copied
> from the above command debug output/ > example2.bc
>
> The minor issue is that opt doesn't know -strip-dead-prototypes  
> pass. Is
> it possible that this pass isn't linked into the opt tool because
> opt.cpp doesn't reference any symbol defined in  
> StripDeadPrototypes.cpp.

Yep, that pass is an internal llvm-gcc pass.

> After skipping -strip-dead-prototypes pass bitcode is produced.  
> However,
> the function assign() in example2.bc is much less optimized than in
> example1.bc. Is this the expected behavior? If it is, then, what is  
> the
> correct way to reproduce llvm-gcc -O3 output with the opt tool?

It's a bit complicated, because llvm-gcc runs a couple of local passes  
as it parses and builds the llvm code, then it runs the passes above  
on the whole module afterwards.  I don't know if there is a good way  
to get the prepasses, Devang, do you know?

-Chris



More information about the llvm-dev mailing list