[llvm] r261175 - AArch64: always clear kill flags up to last eliminated copy

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 15:07:05 PST 2016


Author: tnorthover
Date: Wed Feb 17 17:07:04 2016
New Revision: 261175

URL: http://llvm.org/viewvc/llvm-project?rev=261175&view=rev
Log:
AArch64: always clear kill flags up to last eliminated copy

After r261154, we were only clearing flags if the known-zero register was
originally live-in to the basic block, but we have to do it even if not when
more than one COPY has been eliminated, otherwise the user of the first COPY
may still have <kill> marked.

E.g.

BB#N:
    %X0 = COPY %XZR
    STRXui %X0<kill>, <fi#0>
    %X0 = COPY %XZR
    STRXui %X0<kill>, <fi#1>

We can eliminate both copies, X0 is not live-in, but we must clear the kill on
the first store.

Unfortunately, I've been unable to come up with a non-fragile test for this.
I've only seen it in the wild with regalloc-created spills, and attempts to
reproduce that in a reasonable way run afoul of COPY coalescing. Even volatile
asm clobbers were moved around. Should fix the aarch64 bot though.

Modified:
    llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
    llvm/trunk/test/CodeGen/AArch64/machine-copy-remove.ll

Modified: llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp?rev=261175&r1=261174&r2=261175&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp Wed Feb 17 17:07:04 2016
@@ -149,15 +149,15 @@ bool AArch64RedundantCopyElimination::op
   // CBZ/CBNZ. Conservatively mark as much as we can live.
   CompBr->clearRegisterKills(SmallestDef, TRI);
 
-  // Clear any kills of TargetReg between CompBr and MI.
-  if (std::any_of(TargetRegs.begin(), TargetRegs.end(),
-                  [&](unsigned Reg) { return MBB->isLiveIn(Reg); })) {
-    for (MachineInstr &MMI :
-         make_range(MBB->begin()->getIterator(), LastChange->getIterator()))
-      MMI.clearRegisterKills(SmallestDef, TRI);
-  } else
+  if (std::none_of(TargetRegs.begin(), TargetRegs.end(),
+                   [&](unsigned Reg) { return MBB->isLiveIn(Reg); }))
     MBB->addLiveIn(TargetReg);
 
+  // Clear any kills of TargetReg between CompBr and the last removed COPY.
+  for (MachineInstr &MMI :
+       make_range(MBB->begin()->getIterator(), LastChange->getIterator()))
+    MMI.clearRegisterKills(SmallestDef, TRI);
+
   return true;
 }
 

Modified: llvm/trunk/test/CodeGen/AArch64/machine-copy-remove.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/machine-copy-remove.ll?rev=261175&r1=261174&r2=261175&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/machine-copy-remove.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/machine-copy-remove.ll Wed Feb 17 17:07:04 2016
@@ -91,4 +91,4 @@ false:
 true:
   store volatile i64 %in, i64* %dest
   ret i32 0
-}
\ No newline at end of file
+}




More information about the llvm-commits mailing list