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