diff options
Diffstat (limited to 'lib/CodeGen/PreAllocSplitting.cpp')
-rw-r--r-- | lib/CodeGen/PreAllocSplitting.cpp | 67 |
1 files changed, 21 insertions, 46 deletions
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp index 1c5222c..8cbc8c2 100644 --- a/lib/CodeGen/PreAllocSplitting.cpp +++ b/lib/CodeGen/PreAllocSplitting.cpp @@ -481,32 +481,21 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI, // Search for the use in this block that precedes the instruction we care // about, going to the fallback case if we don't find it. - if (UseI == MBB->begin()) - return PerformPHIConstructionFallBack(UseI, MBB, LI, Visited, Defs, - Uses, NewVNs, LiveOut, Phis, - IsTopLevel, IsIntraBlock); - MachineBasicBlock::iterator Walker = UseI; - --Walker; bool found = false; while (Walker != MBB->begin()) { + --Walker; if (BlockUses.count(Walker)) { found = true; break; } - --Walker; - } - - // Must check begin() too. - if (!found) { - if (BlockUses.count(Walker)) - found = true; - else - return PerformPHIConstructionFallBack(UseI, MBB, LI, Visited, Defs, - Uses, NewVNs, LiveOut, Phis, - IsTopLevel, IsIntraBlock); } + if (!found) + return PerformPHIConstructionFallBack(UseI, MBB, LI, Visited, Defs, + Uses, NewVNs, LiveOut, Phis, + IsTopLevel, IsIntraBlock); + SlotIndex UseIndex = LIs->getInstructionIndex(Walker); UseIndex = UseIndex.getUseIndex(); SlotIndex EndIndex; @@ -533,17 +522,11 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI, // This case is basically a merging of the two preceding case, with the // special note that checking for defs must take precedence over checking // for uses, because of two-address instructions. - - if (UseI == MBB->begin()) - return PerformPHIConstructionFallBack(UseI, MBB, LI, Visited, Defs, Uses, - NewVNs, LiveOut, Phis, - IsTopLevel, IsIntraBlock); - MachineBasicBlock::iterator Walker = UseI; - --Walker; bool foundDef = false; bool foundUse = false; while (Walker != MBB->begin()) { + --Walker; if (BlockDefs.count(Walker)) { foundDef = true; break; @@ -551,21 +534,13 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI, foundUse = true; break; } - --Walker; - } - - // Must check begin() too. - if (!foundDef && !foundUse) { - if (BlockDefs.count(Walker)) - foundDef = true; - else if (BlockUses.count(Walker)) - foundUse = true; - else - return PerformPHIConstructionFallBack(UseI, MBB, LI, Visited, Defs, - Uses, NewVNs, LiveOut, Phis, - IsTopLevel, IsIntraBlock); } + if (!foundDef && !foundUse) + return PerformPHIConstructionFallBack(UseI, MBB, LI, Visited, Defs, + Uses, NewVNs, LiveOut, Phis, + IsTopLevel, IsIntraBlock); + SlotIndex StartIndex = LIs->getInstructionIndex(Walker); StartIndex = foundDef ? StartIndex.getDefIndex() : StartIndex.getUseIndex(); SlotIndex EndIndex; @@ -1022,7 +997,7 @@ MachineInstr* PreAllocSplitting::FoldRestore(unsigned vreg, /// so it would not cross the barrier that's being processed. Shrink wrap /// (minimize) the live interval to the last uses. bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { - DEBUG(errs() << "Pre-alloc splitting " << LI->reg << " for " << *Barrier + DEBUG(dbgs() << "Pre-alloc splitting " << LI->reg << " for " << *Barrier << " result: "); CurrLI = LI; @@ -1039,7 +1014,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { // If this would create a new join point, do not split. if (DefMI && createsNewJoin(LR, DefMI->getParent(), Barrier->getParent())) { - DEBUG(errs() << "FAILED (would create a new join point).\n"); + DEBUG(dbgs() << "FAILED (would create a new join point).\n"); return false; } @@ -1056,13 +1031,13 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { MachineBasicBlock::iterator RestorePt = findRestorePoint(BarrierMBB, Barrier, LR->end, RefsInMBB); if (RestorePt == BarrierMBB->end()) { - DEBUG(errs() << "FAILED (could not find a suitable restore point).\n"); + DEBUG(dbgs() << "FAILED (could not find a suitable restore point).\n"); return false; } if (DefMI && LIs->isReMaterializable(*LI, ValNo, DefMI)) if (Rematerialize(LI->reg, ValNo, DefMI, RestorePt, RefsInMBB)) { - DEBUG(errs() << "success (remat).\n"); + DEBUG(dbgs() << "success (remat).\n"); return true; } @@ -1081,7 +1056,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { MachineBasicBlock::iterator SpillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB); if (SpillPt == BarrierMBB->begin()) { - DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); + DEBUG(dbgs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. } // Add spill. @@ -1096,7 +1071,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { // If it's already split, just restore the value. There is no need to spill // the def again. if (!DefMI) { - DEBUG(errs() << "FAILED (def is dead).\n"); + DEBUG(dbgs() << "FAILED (def is dead).\n"); return false; // Def is dead. Do nothing. } @@ -1111,13 +1086,13 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { SpillPt = findSpillPoint(BarrierMBB, Barrier, DefMI, RefsInMBB); if (SpillPt == DefMBB->begin()) { - DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); + DEBUG(dbgs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. } } else { SpillPt = llvm::next(MachineBasicBlock::iterator(DefMI)); if (SpillPt == DefMBB->end()) { - DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); + DEBUG(dbgs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. } } @@ -1160,7 +1135,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { } ++NumSplits; - DEBUG(errs() << "success.\n"); + DEBUG(dbgs() << "success.\n"); return true; } |