<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="WenQuanYi Zen Hei">Hi,<br>
<br>
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:<br>
<br>
</font><tt>opt -load my-so-lib -aa-eval foo.bc</tt><font
face="WenQuanYi Zen Hei"><br>
<br>
the following errors occurred:<br>
</font><tt><br>
</tt><tt>opt: raw_ostream.cpp:261: void
llvm::raw_ostream::flush_nonempty(): Assertion `OutBufCur >
OutBufStart && "Invalid call to flush_nonempty."' failed.</tt><tt><br>
</tt><font face="WenQuanYi Zen Hei"><br>
As stated in the documentation I found on LLVM official website,
an alias analysis pass should subclass both </font><tt>Pass</tt><font
face="WenQuanYi Zen Hei"> and </font><tt>AliasAnalysis</tt><font
face="WenQuanYi Zen Hei"> class. I used GDB for some debugging,
and found why the error emerged.<br>
<br>
By </font><tt>MyAA</tt><font face="WenQuanYi Zen Hei"> note the
pass class written by me, and by </font><tt>obj</tt><font
face="WenQuanYi Zen Hei"> note the instance of </font><tt>MyAA</tt><font
face="WenQuanYi Zen Hei">. In the crash scene, When LLVM was
trying to call </font><tt>obj.alias</tt><font face="WenQuanYi Zen
Hei">, a virtual function of class </font><tt>llvm::AliasAnalysis</tt><font
face="WenQuanYi Zen Hei">, it actually called </font><tt>obj.print</tt><font
face="WenQuanYi Zen Hei">, a virtual function of </font><tt>llvm::Pass</tt><font
face="WenQuanYi Zen Hei">, because of the confusion of two virtual
function tables. It seems that LLVM assesses </font><tt>obj</tt><font
face="WenQuanYi Zen Hei"> via a </font><font face="WenQuanYi Zen
Hei"><tt>AliasAnalysis</tt>* pointer without performing </font><tt>static_cast</tt><font
face="WenQuanYi Zen Hei">. 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.<br>
<br>
Anyone can help me? I am not a C++ or LLVM expert, so I got really
stranded.<br>
<br>
Thank you in advance.<br>
<br>
Pei Wang<br>
</font> <br>
</body>
</html>