[LLVMdev] Basic Block Predecessor

274 views
Skip to first unread message

William Moses

unread,
Nov 14, 2013, 5:55:08 PM11/14/13
to LLVM Developers Mailing List
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

Stephan Falke

unread,
Nov 14, 2013, 8:32:04 PM11/14/13
to llv...@cs.uiuc.edu
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

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply all
Reply to author
Forward
0 new messages