- Interval *CurInt = getBlockInterval(BB);
- if (CurInt == Int) { // Already in this interval...
- return;
- } else if (CurInt != 0) { // In another interval, add as successor
- if (!Int->isSuccessor(BB)) // Add only if not already in set
- Int->Successors.push_back(BB);
- } else { // Otherwise, not in interval yet
- for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) {
- if (!Int->contains(*I)) { // If pred not in interval, we can't be
- if (!Int->isSuccessor(BB)) // Add only if not already in set
- Int->Successors.push_back(BB);
- return; // See you later
- }
- }
-
- // If we get here, then all of the predecessors of BB are in the interval
- // already. In this case, we must add BB to the interval!
- Int->Nodes.push_back(BB);
- IntervalMap.insert(make_pair(BB, Int));
-
- if (Int->isSuccessor(BB)) {
- // If we were in the successor list from before... remove from succ list
- remove(Int->Successors.begin(), Int->Successors.end(), BB);
- }
-
- // Now that we have discovered that BB is in the interval, perhaps some of
- // its successors are as well?
- for (succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
- ProcessBasicBlock(Int, *I);
- }