Apply final part of Chris' patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11040 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index a762ede..2eb9626 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -168,17 +168,15 @@
         interval = &*r2iit->second;
     }
 
-    for (MbbIndex2MbbMap::iterator
-             it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end();
-         it != itEnd; ++it) {
-        unsigned liveBlockIndex = it->first;
-        MachineBasicBlock* liveBlock = it->second;
-        if (liveBlockIndex < vi.AliveBlocks.size() &&
-            vi.AliveBlocks[liveBlockIndex] &&
-            !liveBlock->empty()) {
-            unsigned start =  getInstructionIndex(liveBlock->front());
-            unsigned end = getInstructionIndex(liveBlock->back()) + 1;
-            interval->addRange(start, end);
+    // iterate over all of the blocks that the variable is completely
+    // live in, adding them to the live interval
+    for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) {
+        if (vi.AliveBlocks[i]) {
+            MachineBasicBlock* mbb = lv_->getIndexMachineBasicBlock(i);
+            if (!mbb->empty()) {
+                interval->addRange(getInstructionIndex(mbb->front()),
+                                   getInstructionIndex(mbb->back()) + 1);
+            }
         }
     }