summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineCopyPropagation.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2018-03-30 00:56:03 +0000
committerEli Friedman <efriedma@codeaurora.org>2018-03-30 00:56:03 +0000
commit208fe67a7861a7db659c3849ab31b9c2e83cbfb9 (patch)
tree905283947cff958a49a09f33160b4e1682e3a2b5 /llvm/lib/CodeGen/MachineCopyPropagation.cpp
parent7fb5d41e449cad3db498a44054a652e0c2955f53 (diff)
downloadbcm5719-llvm-208fe67a7861a7db659c3849ab31b9c2e83cbfb9.tar.gz
bcm5719-llvm-208fe67a7861a7db659c3849ab31b9c2e83cbfb9.zip
[MachineCopyPropagation] Handle COPY with overlapping source/dest.
MachineCopyPropagation::CopyPropagateBlock has a bunch of special handling for COPY instructions. This handling assumes that COPY instructions do not modify the source of the copy; this is wrong if the COPY destination overlaps the source. To fix the bug, check explicitly for this situation, and fall back to the generic instruction handling. This bug can't happen for most register classes because they don't have this sort of overlap, but there are a few register classes where this is possible. The testcase uses the AArch64 QQQQ register class. Differential Revision: https://reviews.llvm.org/D44911 llvm-svn: 328851
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCopyPropagation.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 4c1717e1ec3..8b6777f06db 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -399,7 +399,9 @@ void MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
MachineInstr *MI = &*I;
++I;
- if (MI->isCopy()) {
+ // Analyze copies (which don't overlap themselves).
+ if (MI->isCopy() && !TRI->regsOverlap(MI->getOperand(0).getReg(),
+ MI->getOperand(1).getReg())) {
unsigned Def = MI->getOperand(0).getReg();
unsigned Src = MI->getOperand(1).getReg();
OpenPOWER on IntegriCloud