[LLVMdev] About writing an alias analysis pass for LLVM 3.1

Will Dietz willdtz at gmail.com
Mon Sep 10 06:08:56 PDT 2012


Hi,

Does your pass use multiple inheritance?  Sounds like your problem is
that you need to define getAdjustedAnalysisPointer, see:

http://llvm.org/docs/doxygen/html/classllvm_1_1Pass.html#a03d3a81b1c46aff7c38ef3a6750ba225

An example implementation (very likely exactly what you want) is in
LibCallAliasAnalysis:

http://llvm.org/docs/doxygen/html/LibCallAliasAnalysis_8h_source.html#l00060

Hope this helps!

~Will

On Sep 9, 2012 9:08 PM, "Pei Wang" <uraj.wp at gmail.com> wrote:
>
> Hi,
>
> I am now trying to write an alias analysis pass for LLVM 3.1. The pass is compiled into a .so library. When I loaded it into opt to perform evaluation with command:
>
> opt -load my-so-lib -aa-eval foo.bc
>
> the following errors occurred:
>
> opt: raw_ostream.cpp:261: void llvm::raw_ostream::flush_nonempty(): Assertion `OutBufCur > OutBufStart && "Invalid call to flush_nonempty."' failed.
>
> As stated in the documentation I found on LLVM official website, an alias analysis pass should subclass both Pass and AliasAnalysis class. I used GDB for some debugging, and found why the error emerged.
>
> By MyAA note the pass class written by me, and by obj note the instance of MyAA. In the crash scene, When LLVM was trying to call obj.alias, a virtual function of class llvm::AliasAnalysis, it actually called obj.print, a virtual function of llvm::Pass, because of the confusion of two virtual function tables. It seems that LLVM assesses obj via a AliasAnalysis* pointer without performing static_cast. However, I have no idea why this happens. I guess it is because I registered the Pass in a wrong way, but still don't know to fix it.
>
> Anyone can help me? I am not a C++ or LLVM expert, so I got really stranded.
>
> Thank you in advance.
>
> Pei Wang
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list