I'm writing an LLVM Pass. My pass needs to know which block is a merge block, that is, a block which has more than 1 predecessors. How can I test for this in my code?
You can iterate over all predecessors like this:
#include "llvm/Support/CFG.h"
BasicBlock *BB = ...;
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
BasicBlock *Pred = *PI;
// ...
}
you can verify if an BB have more than one predecessor using this:
BasicBlock *BB = ...;
if (BB->getSinglePredecessor() != null) /// one predecessor
{ ... }
else /// more than one predecessor
{ ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With