<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>I solved this problem after some painful debugging. VHAsserting, defined in ValueHandler.h and used by CallGraphNode,<div>behaves differently depending on whether NDEBUG is defined or not. My LLVM was compiled using NDEBUG, </div><div>while the pass I was using was not. This explains why calling CallGraph::dump() worked while implementing it in</div><div>user code failed, among other scary inconsistencies.  It had nothing to do with the CallGraph including external</div><div>functions whatsoever, as I had previously thought.</div><div><div><br></div><div>To summarize, it is a good idea to use the Makefile.common in tne LLVM top-level directory (if available) to build your</div><div>passes, as stated in the documentation.</div><div><br></div><div>Best,</div><div>Gabriel</div><div><br></div><div><br><hr id="zwchr"><b>De: </b>"Gabriel Rodríguez" <grodriguez@udc.es><br><b>Para: </b>"llvmdev" <llvmdev@cs.uiuc.edu><br><b>Enviados: </b>Miércoles, 30 de Marzo 2011 14:51:39<br><b>Asunto: </b>[LLVMdev] Trouble traversing the CallGraph<br><br><style>p { margin: 0; }</style><div style="font-family: Times New Roman; font-size: 12pt; color: #000000"><style>p { margin: 0; }</style><div style="font-family: Times New Roman; font-size: 12pt; color: #000000">I am finding some weird behavior in the CallGraph, and am not sure what am I doing wrong. When trying to traverse nodes<br>in the CallGraph I get stuck in nodes representing external functions. Take the following code:<br><br>-----<br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">#include <stdio.h></span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">int main() {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">  printf( "Hello World!\n" );</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">}</span><br>-----<br><br>If I try to traverse the CallGraph using the following code:<br><br>-----<br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">CallGraph CG = this->getAnalysis<CallGraph>();</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">for( CallGraph::const_iterator i = CG.begin(); i != CG.end(); ++i ) {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">        CallGraphNode * cgn = i->second;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">        for( CallGraphNode::const_iterator ii = cgn->begin();</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">          ii != cgn->end(); ++ii ) {}</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">}</span><br>-----<br><br>The CallGraphNode::const_iterator is inconsistent. For starters, the inner loop never exits and, besides, if I<br>try to use the values contained in the iterator (e.g. ii->second) I get segfaults. Calling CG.dump() works<br>flawlessly,  but mimicking the code from CG.dump() in my user code produces inconsistent CGN iterators<br>again. I am at a loss here, any ideas?<br><br>Best,<br>Gabriel<br><br>PS: I have already added the CallGraph analysis to the pass requirements.<br></div></div><br>_______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu         http://llvm.cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev<br></div></div></div></body></html>