[LLVMdev] understanding the opt tool

kalyan ponnala ponnala.kalyan at gmail.com
Sat Apr 17 11:17:17 PDT 2010


Thanks duncan and samuel. I guess the optimization about striping dead
prototypes was not working because of "no dead prototypes" to strip. The
-std-compile-opts option works. I can see a change. And @samuel, I tried the
clang's -o0 optimization level compiling, but I could not find any
difference with or without that switch in the bitcode file generated. I used
this command:

 clang filename.c -o0 -emit-llvm

Is this the correct way to use it? If yes then i guess clang does not
optimize the source by default.

And one more thing,
When I try a loop optimization on a program like the following, I can't see
any optimizations performed on the code,

int main()
{
    int A[10], B[10];
    int i;

    for(i=0; i<10; i++)
    {
        A[i] = 1+ i;
    }
    for (i=0; i<10 ; i++)
    {
        B[i] = A[i] +1;
        printf("\n %d is B[%d] ", B[i] , i);
    }
return 0;
}

The commands that I used to do the opts are:
clang -c -emit-llvm filename.c -o filename.bc

opt -loop-unroll -f <filename.bc> filename2.bc

This does not give me any different output when compared to no
optimizations. I mean filename.bc and filename2.bc are the same.
Is my program wrong when it comes to a loop optimization or is the procedure
to perform the optimization wrong. ?

Thanks.

On Sat, Apr 17, 2010 at 1:02 PM, Samuel Crow <samuraileumas at yahoo.com>wrote:

> Hello Kalyan,
>
> There is one more thing you should know:  Clang has maximum optimization
> turned on by default.  You need to specify -O0 to turn it off if you want to
> see what opt does without clang running all of the optimizations first.
>
> --Sam
>
>
>
> ----- Original Message ----
> > From: Duncan Sands <baldrick at free.fr>
> > To: llvmdev at cs.uiuc.edu
> > Sent: Sat, April 17, 2010 2:00:00 AM
> > Subject: Re: [LLVMdev] understanding the opt tool
> >
> > Hi Kalyan,
>
> > opt -strip-dead-prototypes -f <filename.bc>
> > filename2.bc
>
> you have to specify the list of passes to run.
> > -strip-dead-prototypes
> only removes unused declarations.  If there are
> > none, it will do nothing.
> Try:
>   opt -std-compile-opts -f
> > <filename.bc>
> > filename2.bc
>
> Ciao,
>
> Duncan.
> _______________________________________________
> LLVM
> > Developers mailing list
>
> > href="mailto:LLVMdev at cs.uiuc.edu">LLVMdev at cs.uiuc.edu
> >
> > http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
Kalyan Ponnala
phone: 8163772059
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100417/b0bc8284/attachment.html>


More information about the llvm-dev mailing list