llvm.org GIT mirror llvm / cd943e4
Treat BBs that use BBs as proper predecessors and successors in the CFG. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47989 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 12 years ago
1 changed file(s) with 17 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
3333 typedef PredIterator<_Ptr,_USE_iterator> _Self;
3434 typedef typename super::pointer pointer;
3535
36 inline void advancePastNonTerminators() {
37 // Loop to ignore non terminator uses (for example PHI nodes)...
38 while (!It.atEnd() && !isa(*It))
36 inline void advancePastNonPreds() {
37 // Loop to ignore non predecessor uses (for example PHI nodes)...
38 while (!It.atEnd() && !isa(*It) && !isa(*It))
3939 ++It;
4040 }
4141
4242 inline PredIterator(_Ptr *bb) : It(bb->use_begin()) {
43 advancePastNonTerminators();
43 advancePastNonPreds();
4444 }
4545 inline PredIterator(_Ptr *bb, bool) : It(bb->use_end()) {}
4646
4949
5050 inline pointer operator*() const {
5151 assert(!It.atEnd() && "pred_iterator out of range!");
52 return cast(*It)->getParent();
52 if (isa(*It)) // not dyn_cast due to const-correctness
53 return cast(*It)->getParent();
54
55 return cast<_Ptr>(*It);
5356 }
5457 inline pointer *operator->() const { return &(operator*()); }
5558
5659 inline _Self& operator++() { // Preincrement
5760 assert(!It.atEnd() && "pred_iterator out of range!");
58 ++It; advancePastNonTerminators();
61 ++It; advancePastNonPreds();
5962 return *this;
6063 }
6164
99102 inline SuccIterator(Term_ T, bool) // end iterator
100103 : Term(T), idx(Term->getNumSuccessors()) {
101104 assert(T && "getTerminator returned null!");
105 if (Term->getParent()->getUnwindDest())
106 ++idx;
102107 }
103108
104109 inline const _Self &operator=(const _Self &I) {
114119 inline bool operator==(const _Self& x) const { return idx == x.idx; }
115120 inline bool operator!=(const _Self& x) const { return !operator==(x); }
116121
117 inline pointer operator*() const { return Term->getSuccessor(idx); }
122 inline pointer operator*() const {
123 if (idx == Term->getNumSuccessors())
124 return Term->getParent()->getUnwindDest();
125
126 return Term->getSuccessor(idx);
127 }
118128 inline pointer operator->() const { return operator*(); }
119129
120130 inline _Self& operator++() { ++idx; return *this; } // Preincrement