aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2013-02-17 11:09:00 +0000
committerCameron Zwarich <zwarich@apple.com>2013-02-17 11:09:00 +0000
commit680c98f6323dde0eae566710ea49497e16499653 (patch)
treec1ecc8c2401a7dfa44dc7bdc773608f5a9145056
parent7324d4e593ee2611ee6b272c03b15541fe2df62e (diff)
downloadexternal_llvm-680c98f6323dde0eae566710ea49497e16499653.zip
external_llvm-680c98f6323dde0eae566710ea49497e16499653.tar.gz
external_llvm-680c98f6323dde0eae566710ea49497e16499653.tar.bz2
Remove use of reverse iterators in repairIntervalsInRange(). While they were
arguably better than forward iterators for this use case, they are confusing and there are some implementation problems with reverse iterators and MI bundles. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175393 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/LiveIntervalAnalysis.h10
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp19
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp10
3 files changed, 18 insertions, 21 deletions
diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h
index 46dfd92..c0de49e 100644
--- a/include/llvm/CodeGen/LiveIntervalAnalysis.h
+++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h
@@ -282,9 +282,9 @@ namespace llvm {
bool UpdateFlags = false);
/// repairIntervalsInRange - Update live intervals for instructions in a
- /// small range of reverse iterators. It is intended for use after target
- /// hooks that may insert or remove instructions, and is only efficient for
- /// a small number of instructions.
+ /// range of iterators. It is intended for use after target hooks that may
+ /// insert or remove instructions, and is only efficient for a small number
+ /// of instructions.
///
/// OrigRegs is a vector of registers that were originally used by the
/// instructions in the range between the two iterators.
@@ -292,8 +292,8 @@ namespace llvm {
/// Currently, the only only changes that are supported are simple removal
/// and addition of uses.
void repairIntervalsInRange(MachineBasicBlock *MBB,
- MachineBasicBlock::reverse_iterator RBegin,
- MachineBasicBlock::reverse_iterator REnd,
+ MachineBasicBlock::iterator Begin,
+ MachineBasicBlock::iterator End,
ArrayRef<unsigned> OrigRegs);
// Register mask functions.
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index e09ac4b..0978d73 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -1035,19 +1035,24 @@ void LiveIntervals::handleMoveIntoBundle(MachineInstr* MI,
void
LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB,
- MachineBasicBlock::reverse_iterator RBegin,
- MachineBasicBlock::reverse_iterator REnd,
+ MachineBasicBlock::iterator Begin,
+ MachineBasicBlock::iterator End,
ArrayRef<unsigned> OrigRegs) {
+ SlotIndex startIdx;
+ if (Begin == MBB->begin())
+ startIdx = getMBBStartIdx(MBB);
+ else
+ startIdx = getInstructionIndex(prior(Begin)).getRegSlot();
+
for (unsigned i = 0, e = OrigRegs.size(); i != e; ++i) {
unsigned Reg = OrigRegs[i];
if (!TargetRegisterInfo::isVirtualRegister(Reg))
continue;
LiveInterval &LI = getInterval(Reg);
- SlotIndex startIdx = (REnd == MBB->rend()) ? getMBBStartIdx(MBB)
- : getInstructionIndex(&*REnd);
- for (MachineBasicBlock::reverse_iterator I = RBegin; I != REnd; ++I) {
- MachineInstr *MI = &*I;
+ for (MachineBasicBlock::iterator I = End; I != Begin;) {
+ --I;
+ MachineInstr *MI = I;
SlotIndex instrIdx = getInstructionIndex(MI);
for (MachineInstr::mop_iterator OI = MI->operands_begin(),
@@ -1059,7 +1064,7 @@ LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB,
assert(MO.isUse() && "Register defs are not yet supported.");
if (!LI.liveAt(instrIdx)) {
- LiveRange *LR = LI.getLiveRangeContaining(startIdx.getRegSlot());
+ LiveRange *LR = LI.getLiveRangeContaining(startIdx);
assert(LR && "Used registers must be live-in.");
LR->end = instrIdx.getRegSlot();
break;
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index f22a707..898e165 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -851,15 +851,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
// Update all intervals for registers whose uses may have been modified by
// updateTerminator().
- iterator FirstTerminator = getFirstTerminator();
- reverse_iterator PreTerminators;
- if (FirstTerminator == begin())
- PreTerminators = rend();
- else if (FirstTerminator == end())
- PreTerminators = rbegin();
- else
- PreTerminators = reverse_iterator(FirstTerminator);
- LIS->repairIntervalsInRange(this, rbegin(), PreTerminators, UsedRegs);
+ LIS->repairIntervalsInRange(this, getFirstTerminator(), end(), UsedRegs);
}
if (MachineDominatorTree *MDT =