[X86] Fix a think-o when checking if the eflags needs to be preserved.
authorQuentin Colombet <qcolombet@apple.com>
Wed, 2 Dec 2015 02:07:00 +0000 (02:07 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Wed, 2 Dec 2015 02:07:00 +0000 (02:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254480 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86FrameLowering.cpp

index cc8bbd09f5077e6222ade9c02537a192b1066441..52cf9fd44cbdeba6c741e00075b50e37a7550044 100644 (file)
@@ -211,6 +211,7 @@ static bool isEAXLiveIn(MachineFunction &MF) {
 static bool
 flagsNeedToBePreservedBeforeTheTerminators(const MachineBasicBlock &MBB) {
   for (const MachineInstr &MI : MBB.terminators()) {
+    bool BreakNext = false;
     for (const MachineOperand &MO : MI.operands()) {
       if (!MO.isReg())
         continue;
@@ -224,8 +225,13 @@ flagsNeedToBePreservedBeforeTheTerminators(const MachineBasicBlock &MBB) {
       if (!MO.isDef())
         return true;
       // This terminator defines the eflags, i.e., we don't need to preserve it.
-      return false;
+      // However, we still need to check this specific terminator does not
+      // read a live-in value.
+      BreakNext = true;
     }
+    // We found a definition of the eflags, no need to preserve them.
+    if (BreakNext)
+      return false;
   }
 
   // None of the terminators use or define the eflags.