Index: include/llvm/IR/PredIteratorCache.h =================================================================== --- include/llvm/IR/PredIteratorCache.h +++ include/llvm/IR/PredIteratorCache.h @@ -14,6 +14,7 @@ #ifndef LLVM_IR_PREDITERATORCACHE_H #define LLVM_IR_PREDITERATORCACHE_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/CFG.h" @@ -32,6 +33,13 @@ /// Memory - This is the space that holds cached preds. BumpPtrAllocator Memory; public: + ArrayRef::iterator begin(BasicBlock *BB) { + return makeArrayRef(GetPreds(BB), GetNumPreds(BB)).begin(); + } + + ArrayRef::iterator end(BasicBlock *BB) { + return makeArrayRef(GetPreds(BB), GetNumPreds(BB)).end(); + } /// GetPreds - Get a cached list for the null-terminated predecessor list of /// the specified block. This can be used in a loop like this: @@ -65,6 +73,12 @@ Memory.Reset(); } }; + + iterator_range::iterator> + cached_predecessors(PredIteratorCache &PC, BasicBlock *BB) { + return make_range(PC.begin(BB), PC.end(BB)); + } + } // end namespace llvm #endif