Fix a future TwoAddressInstructionPass crash.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 9 Aug 2012 22:08:26 +0000 (22:08 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 9 Aug 2012 22:08:26 +0000 (22:08 +0000)
No test case, the crash only happens when the default use list order is
changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161627 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TwoAddressInstructionPass.cpp

index d22274496abb37e957cd240c5af965c4369170a6..9a219a6b00051874b1998bcf41f24a8ee9b24732 100644 (file)
@@ -235,7 +235,7 @@ bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB,
   // appropriate location, we can try to sink the current instruction
   // past it.
   if (!KillMI || KillMI->getParent() != MBB || KillMI == MI ||
-      KillMI->isTerminator())
+      KillMI == OldPos || KillMI->isTerminator())
     return false;
 
   // If any of the definitions are used by another instruction between the
@@ -278,6 +278,7 @@ bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB,
       }
     }
   }
+  assert(KillMO && "Didn't find kill");
 
   // Update kill and LV information.
   KillMO->setIsKill(false);