Teach coalescer about earlyclobber bits.
authorDale Johannesen <dalej@apple.com>
Sat, 20 Sep 2008 02:03:04 +0000 (02:03 +0000)
committerDale Johannesen <dalej@apple.com>
Sat, 20 Sep 2008 02:03:04 +0000 (02:03 +0000)
Check bits for preferred register.

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

lib/CodeGen/RegAllocLinearScan.cpp
lib/CodeGen/SimpleRegisterCoalescing.cpp

index df9d393a8f4fa9157cfcc0b083cfe77b799341f0..5a1944fd5f9bb5ffff0774e55dea39ea319b52e1 100644 (file)
@@ -1122,9 +1122,12 @@ unsigned RALinScan::getFreePhysReg(LiveInterval *cur) {
   unsigned FreeRegInactiveCount = 0;
 
   // If copy coalescer has assigned a "preferred" register, check if it's
-  // available first.
+  // available first.  Coalescer can create new earlyclobber interferences,
+  // so we need to check that.
   if (cur->preference) {
-    if (prt_->isRegAvail(cur->preference) && RC->contains(cur->preference)) {
+    if (prt_->isRegAvail(cur->preference) && 
+        RC->contains(cur->preference) &&
+        noEarlyClobberConflict(cur, cur->preference)) {
       DOUT << "\t\tassigned the preferred register: "
            << tri_->getName(cur->preference) << "\n";
       return cur->preference;
index 33061890c09502a580b16c4378b8f9ca68b385d6..88996575db86540fa0723b6a4192d6a1f981bf53 100644 (file)
@@ -1206,6 +1206,14 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
   DOUT << " and "; DstInt.print(DOUT, tri_);
   DOUT << ": ";
 
+  // If one interval is earlyclobber and the other is overlaps-earlyclobber,
+  // we cannot coalesce them.
+  if ((SrcInt.isEarlyClobber && DstInt.overlapsEarlyClobber) ||
+      (DstInt.isEarlyClobber && SrcInt.overlapsEarlyClobber)) {
+    DOUT << "\t\tCannot join due to earlyclobber.";
+    return false;
+  }
+
   // Check if it is necessary to propagate "isDead" property.
   if (!isExtSubReg && !isInsSubReg) {
     MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg, false);
@@ -1366,6 +1374,10 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
   if (TargetRegisterInfo::isVirtualRegister(DstReg))
     RemoveUnnecessaryKills(DstReg, *ResDstInt);
 
+  // Merge the earlyclobber bits.
+  ResDstInt->isEarlyClobber |= ResSrcInt->isEarlyClobber;
+  ResDstInt->overlapsEarlyClobber |= ResSrcInt->overlapsEarlyClobber;
+
   if (isInsSubReg)
     // Avoid:
     // r1024 = op