Basic Block Predecessor

All,

Is there a fast way to retrieve all of the predecessors to a BasicBlock in a function. Specifically, is there a fast way to iterate through all BasicBlocks which can break to a specific BasicBlock?

Thanks,
Billy

Hi Billy,

Is there a fast way to retrieve all of the predecessors to a BasicBlock
in a function. Specifically, is there a fast way to iterate through all
BasicBlocks which can break to a specific BasicBlock?

CFG.h defines pred_iterator to do just this. So after including llvm/Support/CFG.h you can iterate through the predecessors of a BasicBlock bb using something like

for (pred_iterator PI = pred_begin(bb), E = pred_end(bb); PI != E; ++PI) {
     ....
}

--Stephan