'How to count the number of edges in a CFG in LLVM
I am just learning how to implement a pass in LLVM. I have generated the CFG for the code and now I want to count the number of edges in the CFG in each function.
I was hoping there would be an API that I can I can use to count the number of edges in the CFG or do I have to do some sort of a tree traversal.
Thank you.
Solution 1:[1]
There's no API that gives you that directly, IMHO. But it's easy to implement.
This sample is a LLVM pass that sorts the basic blocks of a function in topological order. It demonstrates how to run over BBs in a function and look at BB successors, so it has all the building blocks to implement what you need, and more.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eli Bendersky |
