When hoisting common code, watch out for uses which are marked "kill". If the
authorEvan Cheng <evan.cheng@apple.com>
Thu, 12 Jan 2012 20:31:24 +0000 (20:31 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 12 Jan 2012 20:31:24 +0000 (20:31 +0000)
killed registers are needed below the insertion point, then unset the kill
marker.

Sorry I'm not able to find a reduced test case.

rdar://10660944

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

lib/CodeGen/BranchFolding.cpp

index 89894c37ee0e629718783050ad0344e8583e7c4f..793e4f07063680488a5241d9e6e456243a3a3c48 100644 (file)
@@ -1618,6 +1618,11 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
           IsSafe = false;
           break;
         }
+
+        if (MO.isKill() && Uses.count(Reg))
+          // Kills a register that's read by the instruction at the point of
+          // insertion. Remove the kill marker.
+          MO.setIsKill(false);
       }
     }
     if (!IsSafe)