Add debug output and asserts to the phi-connecting code.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 3 Feb 2011 20:29:39 +0000 (20:29 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 3 Feb 2011 20:29:39 +0000 (20:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124813 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SplitKit.cpp

index 8bd62800e0275039ab192b4820fe202291457599..3ffb079acd325a7323305d324c79aa17af082419 100644 (file)
@@ -978,16 +978,27 @@ void SplitEditor::finish() {
     const VNInfo *PHIVNI = *I;
     if (!PHIVNI->isPHIDef())
       continue;
-    LiveIntervalMap &LIM = LIMappers[RegAssign.lookup(PHIVNI->def)];
+    unsigned RegIdx = RegAssign.lookup(PHIVNI->def);
+    LiveIntervalMap &LIM = LIMappers[RegIdx];
     MachineBasicBlock *MBB = LIS.getMBBFromIndex(PHIVNI->def);
+    DEBUG(dbgs() << "  map phi in BB#" << MBB->getNumber() << '@' << PHIVNI->def
+                 << " -> " << RegIdx << '\n');
     for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(),
          PE = MBB->pred_end(); PI != PE; ++PI) {
       SlotIndex End = LIS.getMBBEndIdx(*PI).getPrevSlot();
+      DEBUG(dbgs() << "    pred BB#" << (*PI)->getNumber() << '@' << End);
       // The predecessor may not have a live-out value. That is OK, like an
       // undef PHI operand.
-      if (VNInfo *VNI = Edit.getParent().getVNInfoAt(End))
+      if (VNInfo *VNI = Edit.getParent().getVNInfoAt(End)) {
+        DEBUG(dbgs() << " has parent valno #" << VNI->id << " live out\n");
+        assert(RegAssign.lookup(End) == RegIdx &&
+               "Different register assignment in phi predecessor");
         LIM.mapValue(VNI, End);
+      }
+      else
+        DEBUG(dbgs() << " is not live-out\n");
     }
+    DEBUG(dbgs() << "    " << *LIM.getLI() << '\n');
   }
 
   // Rewrite instructions.