summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineCopyPropagation.cpp
diff options
context:
space:
mode:
authorTim Renouf <tpr.ll@botech.co.uk>2019-11-11 11:06:09 +0000
committerTim Renouf <tim.renouf@amd.com>2019-11-12 08:18:11 +0000
commit07ebd741546e399f3db0a7c08a7fb1932e14080c (patch)
treebd3988c86442a72d6bfa7b35d278c5baef271736 /llvm/lib/CodeGen/MachineCopyPropagation.cpp
parent22a535e91a795e52c8b8c01ad04e3577e9f7ae5b (diff)
downloadbcm5719-llvm-07ebd741546e399f3db0a7c08a7fb1932e14080c.tar.gz
bcm5719-llvm-07ebd741546e399f3db0a7c08a7fb1932e14080c.zip
MCP: Fixed bug with dest overlapping copy source
In MachineCopyPropagation, when propagating the source of a copy into the operand of a later instruction, bail if a destination overlaps (partly defines) the copy source. If the instruction where the substitution is happening is also a copy, allowing the propagation confuses the tracking mechanism. Differential Revision: https://reviews.llvm.org/D69953 Change-Id: Ic570754f878f2d91a4a50a9bdcf96fbaa240726d
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCopyPropagation.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index ebe76e31dca..d45dfd065fc 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -432,6 +432,15 @@ void MachineCopyPropagation::forwardUses(MachineInstr &MI) {
if (hasImplicitOverlap(MI, MOUse))
continue;
+ // Check that the instruction is not a copy that partially overwrites the
+ // original copy source that we are about to use. The tracker mechanism
+ // cannot cope with that.
+ if (MI.isCopy() && MI.modifiesRegister(CopySrcReg, TRI) &&
+ !MI.definesRegister(CopySrcReg)) {
+ LLVM_DEBUG(dbgs() << "MCP: Copy source overlap with dest in " << MI);
+ continue;
+ }
+
if (!DebugCounter::shouldExecute(FwdCounter)) {
LLVM_DEBUG(dbgs() << "MCP: Skipping forwarding due to debug counter:\n "
<< MI);
OpenPOWER on IntegriCloud