/// canSplitCriticalExits - Return true if it is possible to insert new exit /// blocks before the blocks in CriticalExits. bool SplitAnalysis::canSplitCriticalExits(const SplitAnalysis::LoopBlocks &Blocks, BlockPtrSet &CriticalExits) { // If we don't allow critical edge splitting, require no critical exits. if (!AllowSplit) return CriticalExits.empty(); for (BlockPtrSet::iterator I = CriticalExits.begin(), E = CriticalExits.end(); I != E; ++I) { const MachineBasicBlock *Succ = *I; // We want to insert a new pre-exit MBB before Succ, and change all the // in-loop blocks to branch to the pre-exit instead of Succ. // Check that all the in-loop predecessors can be changed. for (MachineBasicBlock::const_pred_iterator PI = Succ->pred_begin(), PE = Succ->pred_end(); PI != PE; ++PI) { const MachineBasicBlock *Pred = *PI; // The external predecessors won't be altered. if (!Blocks.Loop.count(Pred) && !Blocks.Preds.count(Pred)) continue; if (!canAnalyzeBranch(Pred)) return false; } // If Succ's layout predecessor falls through, that too must be analyzable. // We need to insert the pre-exit block in the gap. MachineFunction::const_iterator MFI = Succ; if (MFI == mf_.begin()) continue; if (!canAnalyzeBranch(--MFI)) return false; } // No problems found. return true; }
void SplitAnalysis::print(const BlockPtrSet &B, raw_ostream &OS) const { for (BlockPtrSet::const_iterator I = B.begin(), E = B.end(); I != E; ++I) { unsigned count = usingBlocks_.lookup(*I); OS << " BB#" << (*I)->getNumber(); if (count) OS << '(' << count << ')'; } }