Assert that the last operand is actually EFLAGS
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 17 Dec 2013 20:28:21 +0000 (20:28 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 17 Dec 2013 20:28:21 +0000 (20:28 +0000)
This is another follow-up to r197503, after a post-commit review by
Andy.

<rdar://problem/15627766>

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

lib/Target/X86/X86ISelLowering.cpp

index c780c14abbc3c19b8fa74c43da5767698af22027..e3f9963a7155b8fbc40fc35e9e2ccd3eaca3488a 100644 (file)
@@ -15338,6 +15338,12 @@ X86TargetLowering::EmitVAStartSaveXMMRegsWithCustomInserter(
     MBB->addSuccessor(EndMBB);
   }
 
+  // Make sure the last operand is EFLAGS, which gets clobbered by the branch
+  // that was just emitted, but clearly shouldn't be "saved".
+  assert((MI->getNumOperands() <= 3 ||
+          !MI->getOperand(MI->getNumOperands() - 1).isReg() ||
+          MI->getOperand(MI->getNumOperands() - 1).getReg() == X86::EFLAGS)
+         && "Expected last argument to be EFLAGS");
   unsigned MOVOpc = Subtarget->hasFp256() ? X86::VMOVAPSmr : X86::MOVAPSmr;
   // In the XMM save block, save all the XMM argument registers.
   for (int i = 3, e = MI->getNumOperands() - 1; i != e; ++i) {