From: Geoff Berry Date: Tue, 29 Nov 2016 19:31:35 +0000 (+0000) Subject: [LiveRangeEdit] Handle instructions with no defs correctly. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81e1a9d3831668049f17450a459c44a4903f89f4;p=llvm [LiveRangeEdit] Handle instructions with no defs correctly. Summary: The code in LiveRangeEdit::eliminateDeadDef() that computes isOrigDef doesn't handle instructions in which operand 0 is not a def (e.g. KILL) correctly. Add a check that operand 0 is a def before doing the rest of the isOrigDef computation. Reviewers: qcolombet, MatzeB, wmi Subscribers: mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D27174 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288189 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp index 264e7f713b9..88fed6212d1 100644 --- a/lib/CodeGen/LiveRangeEdit.cpp +++ b/lib/CodeGen/LiveRangeEdit.cpp @@ -272,7 +272,8 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink, bool ReadsPhysRegs = false; bool isOrigDef = false; unsigned Dest; - if (VRM && MI->getOperand(0).isReg()) { + if (VRM && MI->getOperand(0).isReg() && MI->getOperand(0).isDef()) { + assert(MI->getDesc().getNumDefs() == 1); Dest = MI->getOperand(0).getReg(); unsigned Original = VRM->getOriginal(Dest); LiveInterval &OrigLI = LIS.getInterval(Original);