[LLVMdev] CallGraphSCCPass

Ryan Taylor ryta1203 at gmail.com
Wed Oct 19 12:19:58 PDT 2011


I'm building a SCCPass below, it appears that the CallGraphNode->getFunction
returns a valid function but seg faults on call like "getName" or "size" but
not on calls like "empty" (which returns false).

My understanding is that the heirarchy is:
CallGraphSCC->CallGraphNode->Function->BasicBlock->Instruction, is this not
the case?

 virtual bool runOnSCC(CallGraphSCC &SCC) {
      errs() << "CDFGPass: " << "\n";
      errs() <<"Size of SCC: "<<SCC.size()<<"\n";
        for(CallGraphSCC::iterator CGNodeItr = SCC.begin(); CGNodeItr !=
SCC.end();++CGNodeItr)
        {
                errs()<<"Iterating CallNodeGraphs"<<"\n";
                const CallGraphNode *CGNode =
cast<CallGraphNode>(&*CGNodeItr);
                errs()<<"Getting Function"<<"\n";
                F = CGNode->getFunction();
                if (F) {
                        errs()<<"function is good"<<"\n"; }
                if (F->empty()) {
                        errs()<<"function is empty"<<"\n"; }
                else {
                        errs()<<"basic blocks in function"<<"\n";
                        size_t F_size = F->size(); }
                for(Function::iterator BBitr=F->begin(); BBitr!=F->end();
++BBitr)
                {
                        errs()<<"basic block begin"<<"\n";
                        const BasicBlock* BB = cast<BasicBlock>(&*BBitr);
                        errs()<<"basic block end"<<"\n";
                }
                errs()<<*CGNodeItr<<"\n";
                errs()<<"Loop Back to Call Graph Node"<<"\n";
        }
        errs()<<"END"<<"\n";
        return false;
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111019/f6ca500c/attachment.html>


More information about the llvm-dev mailing list