Fix a crash in the pre-alloc splitter exposed by recent codegen changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65121 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index ef2cfdb..9e955bd 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -224,6 +224,9 @@
if (RefsInMBB.empty() && !DefMI) {
MachineBasicBlock::iterator MII = MBB->begin();
MachineBasicBlock::iterator EndPt = MI;
+
+ if (MII == EndPt) return Pt;
+
do {
++MII;
unsigned Index = LIs->getInstructionIndex(MII);
@@ -303,6 +306,9 @@
if (RefsInMBB.empty() && LastIdx >= EndIdx) {
MachineBasicBlock::iterator MII = MBB->getFirstTerminator();
MachineBasicBlock::iterator EndPt = MI;
+
+ if (MII == EndPt) return Pt;
+
--MII;
do {
unsigned Index = LIs->getInstructionIndex(MII);