[llvm] r289861 - [LiveRangeEdit] Change eliminateDeadDef assert to if condition.

Geoff Berry via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 11:55:19 PST 2016


Author: gberry
Date: Thu Dec 15 13:55:19 2016
New Revision: 289861

URL: http://llvm.org/viewvc/llvm-project?rev=289861&view=rev
Log:
[LiveRangeEdit] Change eliminateDeadDef assert to if condition.

The assert could potentially fire (though no cases have been
encountered), so just check that the instruction we're handling
specially for rematerialization only has one def to begin with.

Reviewed by Wei Mi over email.

Modified:
    llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp

Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=289861&r1=289860&r2=289861&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Thu Dec 15 13:55:19 2016
@@ -272,10 +272,11 @@ void LiveRangeEdit::eliminateDeadDef(Mac
   bool ReadsPhysRegs = false;
   bool isOrigDef = false;
   unsigned Dest;
-  if (VRM && MI->getOperand(0).isReg() && MI->getOperand(0).isDef()) {
-    // It is assumed that callers of eliminateDeadDefs() will never pass in dead
-    // instructions with multiple virtual register defs.
-    assert(MI->getDesc().getNumDefs() == 1 && "Unexpected instruction with multiple defs.");
+  // Only optimize rematerialize case when the instruction has one def, since
+  // otherwise we could leave some dead defs in the code.  This case is
+  // extremely rare.
+  if (VRM && MI->getOperand(0).isReg() && MI->getOperand(0).isDef() &&
+      MI->getDesc().getNumDefs() == 1) {
     Dest = MI->getOperand(0).getReg();
     unsigned Original = VRM->getOriginal(Dest);
     LiveInterval &OrigLI = LIS.getInterval(Original);




More information about the llvm-commits mailing list