I'm new to world of static analysis and am trying to build a new analysis of C programs for llvm compiler.
I've started with the build of the graph of the constraints of the program: The edges represent the flow of data through the program (according to the statements or function calls) and the nodes the run-time memory locations.
I'm wondering if for the labeling of the constraints I do need a symbol table with all the constraints and their labels. I found out that we can build a CFG on top of the LLVM by only parsing the LLVM IR.
for example, we could just have:
//Build list nodes without successors.
for (Function::iterator e = F.end() ; e != BB ; ++BB) {
BI = BB->begin();
for(BasicBlock::iterator BE = BB->end(); BI != BE; ++BI){
Instruction * instruction = dyn_cast<Instruction>(BI);
StaticAnalysis::ListNode* node = new StaticAnalysis::ListNode(counter++);
node->inst = instruction;
helper.insert(pair<Instruction*,StaticAnalysis::ListNode*>(instruction,node));
CFGNodes.push_back(node);
}
}
So, my question is: Would this be possible also for a flow graph? Or a symbol table is needed to construct one?