]> granicus.if.org Git - llvm/commitdiff
LiveIntervalAnalysis: Fix handleMove() extending liverange for undef inputs
authorMatthias Braun <matze@braunis.de>
Fri, 6 May 2016 21:47:41 +0000 (21:47 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 6 May 2016 21:47:41 +0000 (21:47 +0000)
Fix handleMove() incorrectly extending liveranges when an undef input of
a vreg was moved past the (current) end of the liverange.

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

lib/CodeGen/LiveIntervalAnalysis.cpp
unittests/MI/LiveIntervalTest.cpp

index 9b01356a24e52ca866124bf0ce125e344f1c27c5..3d22f709a459b349b3f90d4b28ee7a4e4e1e2426 100644 (file)
@@ -939,10 +939,13 @@ public:
         hasRegMask = true;
       if (!MO.isReg())
         continue;
-      // Aggressively clear all kill flags.
-      // They are reinserted by VirtRegRewriter.
-      if (MO.isUse())
+      if (MO.isUse()) {
+        if (!MO.readsReg())
+          continue;
+        // Aggressively clear all kill flags.
+        // They are reinserted by VirtRegRewriter.
         MO.setIsKill(false);
+      }
 
       unsigned Reg = MO.getReg();
       if (!Reg)
index 104bd7fe7fb32c9e66f1e9b13b9127d9673165e4..afd3b51793b2f807b1a5e02d63040d9112251c52 100644 (file)
@@ -300,6 +300,17 @@ TEST(LiveIntervalTest, MoveDownKillFollowing) {
   });
 }
 
+TEST(LiveIntervalTest, MoveUndefUse) {
+  liveIntervalTest(
+"    %0 = IMPLICIT_DEF\n"
+"    NOOP implicit undef %0\n"
+"    NOOP implicit %0\n"
+"    NOOP\n",
+  [](MachineFunction &MF, LiveIntervals &LIS) {
+    testHandleMove(MF, LIS, 1, 3);
+  });
+}
+
 int main(int argc, char **argv) {
   ::testing::InitGoogleTest(&argc, argv);
   initLLVM();