[PATCH] D71132: PostRA Machine Sink should count COPY defining register used by another COPY

Alexander via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 10:31:24 PST 2019


alex-t created this revision.
alex-t added reviewers: rampitec, vpykhtin, arsenm, junbuml.
Herald added subscribers: hiraditya, wdng.
Herald added a project: LLVM.

This pass was created with the assumption that all the copy sequences like

x = COPY y
z = COPY x

were already handled by the coalescer and transformed to

z = COPY y

This was true until the sub-registers appeared.

Considering the following pattern:

x = COPY y
z = COPY s
w = COPY x_z

where x_z is a super-reg consisting of x and y

Current implementation does not take into account registers defined by another copies assuming that one COPY cannot define register that is used by another one. As a result in sinks the COPY defining sub-register to one successor but COPY that reads super-register to another providing this later with uninitialized register.


https://reviews.llvm.org/D71132

Files:
  llvm/lib/CodeGen/MachineSink.cpp


Index: llvm/lib/CodeGen/MachineSink.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSink.cpp
+++ llvm/lib/CodeGen/MachineSink.cpp
@@ -1386,9 +1386,10 @@
     if (MI->isCall())
       return false;
 
+    LiveRegUnits::accumulateUsedDefed(*MI, ModifiedRegUnits, UsedRegUnits,
+      TRI);
+
     if (!MI->isCopy() || !MI->getOperand(0).isRenamable()) {
-      LiveRegUnits::accumulateUsedDefed(*MI, ModifiedRegUnits, UsedRegUnits,
-                                        TRI);
       continue;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71132.232603.patch
Type: text/x-patch
Size: 555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191206/c9a460fa/attachment.bin>


More information about the llvm-commits mailing list