[LLVMdev] First time!

Devang Patel dpatel at apple.com
Thu Dec 20 09:27:28 PST 2007


On Dec 20, 2007, at 2:36 AM, aditya vishnubhotla wrote:

> Hi!
>
> I want to know
>
> How to count the number of predecessors for each basic
> block?

My obvious question is what are you trying to do ?

One way to count predecessor for a basic block BB is

	unsigned count = 0;
	for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; + 
+PI)
	  ++count;


pred_iteraor, pred_begin, pred_end etc.. are available through llvm/ 
Support/CFG.h

-
Devang



More information about the llvm-dev mailing list