[llvm-commits] [llvm] r44482 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Evan Cheng evan.cheng at apple.com
Fri Nov 30 20:42:39 PST 2007


Author: evancheng
Date: Fri Nov 30 22:42:39 2007
New Revision: 44482

URL: http://llvm.org/viewvc/llvm-project?rev=44482&view=rev
Log:
Fix a bug where splitting cause some unnecessary spilling.

Modified:
    llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=44482&r1=44481&r2=44482&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Nov 30 22:42:39 2007
@@ -995,9 +995,9 @@
           if (VNI)
             HasKill = anyKillInMBBAfterIdx(li, VNI, MBB, getDefIndex(index));
         }
+        std::map<unsigned, std::vector<SRInfo> >::iterator SII =
+          SpillIdxes.find(MBBId);
         if (!HasKill) {
-          std::map<unsigned, std::vector<SRInfo> >::iterator SII =
-            SpillIdxes.find(MBBId);
           if (SII == SpillIdxes.end()) {
             std::vector<SRInfo> S;
             S.push_back(SRInfo(index, NewVReg, true));
@@ -1013,6 +1013,16 @@
             Info.canFold = !HasUse;
           }
           SpillMBBs.set(MBBId);
+        } else if (SII != SpillIdxes.end() &&
+                   SII->second.back().vreg == NewVReg &&
+                   (int)index > SII->second.back().index) {
+          // There is an earlier def that's not killed (must be two-address).
+          // The spill is no longer needed.
+          SII->second.pop_back();
+          if (SII->second.empty()) {
+            SpillIdxes.erase(MBBId);
+            SpillMBBs.reset(MBBId);
+          }
         }
       }
     }





More information about the llvm-commits mailing list