Hi all,
I'm discovering LLVM and I want to build a customized CFG with customized nodes (here BasicBlocks).
Simply, the purpose is to enrich CFG with some other informations.
What is the best way to do that ?
Please, tell me if I'm wrong (I'm not familiar enough with c++) but I understand that :
- CFG is a GraphTraits<BasicBlock*>
- it's not allowed to inherit from BasicBlock (never seen in the project)
Maybe it's better to create a new class (like MachineBasicBlock) that contains a pointer to its BasicBlock ?
But this option requires to rewrite similar lines of code, right ?
Thanks,
Thomas
Dear Thomas,
If you can describe more clearly what you are trying to accomplish, it would help people give better advice. As I don't have a clear idea of what you're trying to do, I can't explain the best way to do it.
Regards,
John Criswell
Hi John, thank you for your answer.
Sorry if I was not clear ^^'
I try to build a RCG (Resource Control Graph) which is a CFG with a weight.
In my case, this weight corresponds to the number of heap allocations.
Then I want to add this weight to each node (then basic block) of this graph.
I think that a CFG is a GraphTraits<BasicBlock*> then I suppose that this RCG will be
a GraphTraits<MyBasicBlock*>
"MyBasicBlock" can be an object like BasicBlock with a weight. (inherited or not?)
I think that with this kind of graph it will be easier to detect "non size increasing"
functions or loops.
My question is : what is the best way to build this graph ?
Thanks again,
Thomas
Why not have a hastable mapping llvm::BasicBlock pointers to whatever
metadata you want to track per block?
Hi,
thank for your advice.
This is what I've already done for testing.
I thought there is a better way to do that using LLVM structures.
The goal is to reuse some functionalities offers by GraphTraits<NodeType>.
For instance, I would use GraphWriter, DOTGraphTraits etc... to see my graph.
I want to do it very properly, I think a hashtable will not be enough, right ?
Sorry again if I was not clear ...
Regards