diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp index 6fcbcf24fcb6..2532fa31c845 100644 --- a/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/llvm/lib/CodeGen/VirtRegMap.cpp @@ -965,7 +965,8 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM, if (WasKill) { const TargetInstrDescriptor *NTID = NextMII->getInstrDescriptor(); - if (NTID->getOperandConstraint(UIdx, TOI::TIED_TO) == -1) + if (UIdx >= NTID->numOperands || + NTID->getOperandConstraint(UIdx, TOI::TIED_TO) == -1) MOU.setIsKill(); } Spills.addLastUse(InReg, &(*NextMII));