[LLVMdev] Trouble traversing the CallGraph
Gabriel Rodríguez
grodriguez at udc.es
Wed Mar 30 15:28:35 PDT 2011
I solved this problem after some painful debugging. VHAsserting, defined in ValueHandler.h and used by CallGraphNode,
behaves differently depending on whether NDEBUG is defined or not. My LLVM was compiled using NDEBUG,
while the pass I was using was not. This explains why calling CallGraph::dump() worked while implementing it in
user code failed, among other scary inconsistencies. It had nothing to do with the CallGraph including external
functions whatsoever, as I had previously thought.
To summarize, it is a good idea to use the Makefile.common in tne LLVM top-level directory (if available) to build your
passes, as stated in the documentation.
Best,
Gabriel
De: "Gabriel Rodríguez" <grodriguez at udc.es>
Para: "llvmdev" <llvmdev at cs.uiuc.edu>
Enviados: Miércoles, 30 de Marzo 2011 14:51:39
Asunto: [LLVMdev] Trouble traversing the CallGraph
I am finding some weird behavior in the CallGraph, and am not sure what am I doing wrong. When trying to traverse nodes
in the CallGraph I get stuck in nodes representing external functions. Take the following code:
-----
#include <stdio.h>
int main() {
printf( "Hello World!\n" );
}
-----
If I try to traverse the CallGraph using the following code:
-----
CallGraph CG = this->getAnalysis<CallGraph>();
for( CallGraph::const_iterator i = CG.begin(); i != CG.end(); ++i ) {
CallGraphNode * cgn = i->second;
for( CallGraphNode::const_iterator ii = cgn->begin();
ii != cgn->end(); ++ii ) {}
}
-----
The CallGraphNode::const_iterator is inconsistent. For starters, the inner loop never exits and, besides, if I
try to use the values contained in the iterator (e.g. ii->second) I get segfaults. Calling CG.dump() works
flawlessly, but mimicking the code from CG.dump() in my user code produces inconsistent CGN iterators
again. I am at a loss here, any ideas?
Best,
Gabriel
PS: I have already added the CallGraph analysis to the pass requirements.
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110331/f27c1e89/attachment.html>
More information about the llvm-dev
mailing list