[LLVMdev] TBAA fail on optimization, why?

Jun Koi junkoi2004 at gmail.com
Thu Sep 27 01:04:46 PDT 2012

On Thu, Sep 27, 2012 at 4:01 PM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Jun,
>> ok, below is my code. i run this through "opt" with option: "-basicaa
>> -mem2reg -tbaa"
>> however, the resulted bitcode file is still the same; no optimization is
>> done.
> that's because you didn't specify any optimization that uses alias analysis!
> LLVM makes a distinction between analyses and transforms.  Analyses, like
> tbaa,
> are passes which look at your IR but don't modify it: instead they deduce
> things about it (eg which memory accesses alias each other) and provide
> that information to other passes.  Transforms are passes that modify the IR,
> i.e. these are the passes that do the actual optimizing.  Consider the -dse
> (dead store elimination pass).  This is a transform pass, however it needs
> to know which memory accesses alias each other.  It doesn't compute this
> itself,
> instead it requests this information from the alias analysis subsystem,
> which
> queries any alias analysis passes that may have run.  By specifying -tbaa
> you
> have only done the analysis part, not the transform part.

thanks, now i got it.

>> meanwhile, the last "store" instruction is easily eliminated with "-O3"
>> option.

> Try -tbaa -basicaa mem2reg -dse

this indeed works, thanks!!!


More information about the llvm-dev mailing list