Also recompute HasPHIKill flags in LiveInterval::RenumberValues.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 12 Aug 2010 20:38:03 +0000 (20:38 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 12 Aug 2010 20:38:03 +0000 (20:38 +0000)
If a phi-def value were removed from the interval, the phi-kill flags are no
longer valid.

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

include/llvm/CodeGen/LiveInterval.h
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/SplitKit.cpp

index ff1dbc2775284cc45f4f97ba617b6f89f4e2a744..29e689a52145411698b8509f954a9f5e84e71a89 100644 (file)
@@ -338,7 +338,8 @@ namespace llvm {
 
     /// RenumberValues - Renumber all values in order of appearance and remove
     /// unused values.
-    void RenumberValues();
+    /// Recalculate phi-kill flags in case any phi-def values were removed.
+    void RenumberValues(LiveIntervals &lis);
 
     /// isOnlyLROfValNo - Return true if the specified live range is the only
     /// one defined by the its val#.
index 9a853e8eafa7ad72a0fdd47f6b3911efc6ea944a..59f380ad26414325cc75f9df098b2ecd2aa17435 100644 (file)
@@ -182,8 +182,9 @@ void LiveInterval::markValNoForDeletion(VNInfo *ValNo) {
 
 /// RenumberValues - Renumber all values in order of appearance and delete the
 /// remaining unused values.
-void LiveInterval::RenumberValues() {
+void LiveInterval::RenumberValues(LiveIntervals &lis) {
   SmallPtrSet<VNInfo*, 8> Seen;
+  bool seenPHIDef = false;
   valnos.clear();
   for (const_iterator I = begin(), E = end(); I != E; ++I) {
     VNInfo *VNI = I->valno;
@@ -192,6 +193,26 @@ void LiveInterval::RenumberValues() {
     assert(!VNI->isUnused() && "Unused valno used by live range");
     VNI->id = (unsigned)valnos.size();
     valnos.push_back(VNI);
+    VNI->setHasPHIKill(false);
+    if (VNI->isPHIDef())
+      seenPHIDef = true;
+  }
+
+  // Recompute phi kill flags.
+  if (!seenPHIDef)
+    return;
+  for (const_vni_iterator I = vni_begin(), E = vni_end(); I != E; ++I) {
+    VNInfo *VNI = *I;
+    if (!VNI->isPHIDef())
+      continue;
+    const MachineBasicBlock *PHIBB = lis.getMBBFromIndex(VNI->def);
+    assert(PHIBB && "No basic block for phi-def");
+    for (MachineBasicBlock::const_pred_iterator PI = PHIBB->pred_begin(),
+         PE = PHIBB->pred_end(); PI != PE; ++PI) {
+      VNInfo *KVNI = getVNInfoAt(lis.getMBBEndIdx(*PI).getPrevSlot());
+      if (KVNI)
+        KVNI->setHasPHIKill(true);
+    }
   }
 }
 
index af65873807342744317cac09fc12b3eed13da946..a45e7bf3eb89e723d00e97bf75577c3e917308d3 100644 (file)
@@ -645,7 +645,7 @@ void SplitEditor::rewrite() {
 
   // dupli_ goes in last, after rewriting.
   if (dupli_) {
-    dupli_->RenumberValues();
+    dupli_->RenumberValues(lis_);
     intervals_.push_back(dupli_);
   }