[LLVMdev] First time!
Prabhat Kumar Saraswat
prabhat.saraswat at gmail.com
Thu Dec 20 02:48:45 PST 2007
There are two ways to cound the number of predecessors for each basic block.
You can generate the control flow graph using the CallGraphScc pass with the
granularity of basic block and can simply traverse the graph bottom up till
the root. The number of nodes encountered would be the number of
The second way would be to use the special ;preds marker in the llvm IR.
Each basic block starts with this line which details the name of its
bb5: ; preds bb2, bb3
thus bb5 is preceeded by bb2 and bb3.
but, one word of caution, even bb2 and bb3 can be preceeded by some other
basic blocks, thus the count for bb5 (number of predecessors) won't be 2,
but would be more (depends upon the predecessors of bb2 and bb3).
You can also try to utilize the branching info at the end of each basic
block in llvmIR of the source.
I am working on something similar, do let me know if u need some specific
On Dec 20, 2007 11:36 AM, aditya vishnubhotla <vvaditya12 at yahoo.com> wrote:
> I want to know
> How to count the number of predecessors for each basic
> Thank You
> Never miss a thing. Make Yahoo your home page.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev