diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -945,6 +945,10 @@ /// insertSpill - Insert a spill of NewVReg after MI. void InlineSpiller::insertSpill(unsigned NewVReg, bool isKill, MachineBasicBlock::iterator MI) { + // Spill are not terminators, so inserting spills after terminators will + // violate invariants in MachineVerifier. This is commonly observed with + // -verify-machineinstrs or even -verify-regalloc. + assert(!MI->isTerminator() && "Inserting a spill after a terminator"); MachineBasicBlock &MBB = *MI->getParent(); MachineInstrSpan MIS(MI, &MBB);