Make sure a reserved register has a live interval before merging.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Mon, 6 Feb 2012 21:52:18 +0000 (21:52 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Mon, 6 Feb 2012 21:52:18 +0000 (21:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149910 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegisterCoalescer.cpp

index cc9ec3ce1428106b5c5735c7bc5dfd91609fd8d4..c7be0b31e0adc2dfc8f6bb8d5fa2c95ae4ee4379 100644 (file)
@@ -1414,8 +1414,12 @@ bool RegisterCoalescer::JoinIntervals(CoalescerPair &CP) {
       // Deny any overlapping intervals.  This depends on all the reserved
       // register live ranges to look like dead defs.
       for (const unsigned *AS = TRI->getOverlaps(CP.getDstReg()); *AS; ++AS) {
-        if (!LIS->hasInterval(*AS))
+        if (!LIS->hasInterval(*AS)) {
+          // Make sure at least DstReg itself exists before attempting a join.
+          if (*AS == CP.getDstReg())
+            LIS->getOrCreateInterval(CP.getDstReg());
           continue;
+        }
         if (RHS.overlaps(LIS->getInterval(*AS))) {
           DEBUG(dbgs() << "\t\tInterference: " << PrintReg(*AS, TRI) << '\n');
           return false;