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

Pei Wang uraj.wp at gmail.com
Sun Sep 9 19:05:28 PDT 2012


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."' 

As stated in the documentation I found on LLVM official website, an 
alias analysis pass should subclass both Passand AliasAnalysisclass. I 
used GDB for some debugging, and found why the error emerged.

By MyAAnote the pass class written by me, and by objnote 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 objvia 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120909/1fbec938/attachment.html>

More information about the llvm-dev mailing list