Thanks for your reply, John.<div><br></div><div>I am using opt to run my pass. Should opt by default link in the library? Would you please give me some idea on fixing it? Thanks!</div><div><br></div><div>opt -load ../../../Debug+Asserts/lib/LLVMHello.dylib -hello < hello.bc > /dev/null </div>
<div><br></div><div> My pass is just:</div><div><br></div><div><div>#include "llvm/IR/Function.h"</div><div>#include "llvm/Pass.h"</div><div>#include "llvm/Support/raw_ostream.h"</div><div>#include "llvm/Analysis/Dominators.h"</div>
<div><br></div><div>using namespace llvm;</div><div><br></div><div>namespace {</div><div> struct Hello : public FunctionPass { </div><div> static char ID;</div><div> Hello() : FunctionPass(ID) { } </div><div> virtual void getAnalysisUsage(AnalysisUsage &AU) const {</div>
<div> AU.addRequired<DominatorTree>();</div><div> }</div><div> virtual bool runOnFunction(Function &F) {</div><div> DominatorTree& DT = getAnalysis<DominatorTree>();</div><div> BasicBlock* BB = DT.getRoot();</div>
<div> return false;</div><div> }</div><div> };</div><div>}</div><div>char Hello::ID = 0;</div><div>static RegisterPass<Hello> Z("hello", "My test analysis", true, true);</div><div><br></div>
<br><div class="gmail_quote">On Fri, Apr 12, 2013 at 9:32 AM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu" target="_blank">criswell@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><div class="im">
<div>On 4/11/13 10:30 PM, Bill He wrote:<br>
</div>
<blockquote type="cite">
Hi all,
<div><br>
</div>
<div>I am trying to traverse a dominator tree and have encountered
a weird runtime exception:</div>
<div><br>
</div>
<div>Here's my simple code: </div>
<div><br>
</div>
<div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">
virtual bool runOnFunction(Function &F) {</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">
DominatorTree& DT =
getAnalysis<DominatorTree>();</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif"><br>
</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif"> <b><font color="#ff0000"> DomTreeNode* rootNode =
DT.getRootNode();</font></b></div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">
return false.</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">}</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif"><br>
</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">Here's
the documentation page:</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif"><a href="http://llvm.org/docs/doxygen/html/classllvm_1_1DominatorTree.html" style="color:rgb(17,85,204)" target="_blank">http://llvm.org/docs/doxygen/html/classllvm_1_1DominatorTree.html</a><br>
</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif"><br>
</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">And
here's my runtime exception:</div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">
<div>dyld: lazy symbol binding failed: Symbol not found:
__ZN4llvm17DominatorTreeBaseINS_10BasicBlockEE11getRootNodeEv</div>
<div> Referenced from:
/Users/weibohe/Projects/llvm/llvm/Debug+Asserts/lib/LLVMSLVN.dylib</div>
</div>
</div>
</blockquote>
<br></div>
How are you running your pass? Based on the error, it looks like
whatever tool you're using to run your pass doesn't have the library
defining the DominatorTree code linked in.<br>
<br>
-- John T.<br>
<br>
<blockquote type="cite"><div><div class="h5">
<div>
<div style="color:rgb(34,34,34);font-size:12.800000190734863px;font-family:arial,sans-serif">
<div>
Expected in: flat namespace</div>
<div><br>
</div>
<div>dyld: Symbol not found:
__ZN4llvm17DominatorTreeBaseINS_10BasicBlockEE11getRootNodeEv</div>
<div> Referenced from:
/Users/weibohe/Projects/llvm/llvm/Debug+Asserts/lib/LLVMSLVN.dylib</div>
<div> Expected in: flat namespace</div>
<div><br>
</div>
<div>0 opt 0x0000000105f528de
llvm::sys::PrintStackTrace(__sFILE*) + 46</div>
<div>1 opt 0x0000000105f52beb
_ZL28PrintStackTraceSignalHandlerPv + 27</div>
<div>2 opt 0x0000000105f52ef9
_ZL13SignalHandleri + 297</div>
<div>3 libsystem_c.dylib 0x00007fff90d32cfa _sigtramp + 26</div>
<div>4 libsystem_c.dylib 0xfffffffffffffff8 _sigtramp +
1865208600</div>
<div>5 libsystem_c.dylib 0x00007fff64a41948 _sigtramp +
3553684584</div>
<div>6 libdyld.dylib 0x00007fff8afe2716 dyld_stub_binder_
+ 13</div>
<div>7 LLVMSLVN.dylib 0x00000001081a8040 void
std::__destroy_aux<llvm::PassInfo
const**>(llvm::PassInfo const**, llvm::PassInfo const**,
std::__true_type) + 19904</div>
<div>8 LLVMSLVN.dylib 0x00000001081998c1 (anonymous
namespace)::DVN::runOnFunction(llvm::Function&) + 65</div>
<div>9 opt 0x0000000105eb27b2
llvm::FPPassManager::runOnFunction(llvm::Function&) +
434</div>
<div>10 opt 0x0000000105eb2a98
llvm::FPPassManager::runOnModule(llvm::Module&) + 104</div>
<div>11 opt 0x0000000105eb2e9a
llvm::MPPassManager::runOnModule(llvm::Module&) + 634</div>
<div>
12 opt 0x0000000105eb36ae
llvm::PassManagerImpl::run(llvm::Module&) + 302</div>
<div>13 opt 0x0000000105eb3951
llvm::PassManager::run(llvm::Module&) + 33</div>
<div>14 opt 0x0000000104e4d335 main + 6549</div>
<div>15 opt 0x0000000104e3e434 start + 52</div>
<div>Stack dump:</div>
<div>0.<span style="white-space:pre-wrap"> </span>Program
arguments: opt -load
../../../Debug+Asserts/lib/LLVMSLVN.dylib -dvn </div>
<div>1.<span style="white-space:pre-wrap"> </span>Running
pass 'Function Pass Manager' on module '<stdin>'.</div>
<div>2.<span style="white-space:pre-wrap"> </span>Running
pass 'My test analysis' on function '@main'</div>
<div><br>
</div>
<div><br>
</div>
<div>Any idea on why this is happening? Any help or suggestion
is appreciated! Thanks in advance.</div>
<div><br>
</div>
<div>Best,</div>
<div>Weibo</div>
<div><br>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div><br></div>