aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/VirtRegMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index 608ff8bd8c..0487890bc9 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -38,6 +38,7 @@ namespace {
Statistic<> NumLoads ("spiller", "Number of loads added");
Statistic<> NumReused("spiller", "Number of values reused");
Statistic<> NumDSE ("spiller", "Number of dead stores elided");
+ Statistic<> NumDCE ("spiller", "Number of copies elided");
enum SpillerName { simple, local };
@@ -658,6 +659,18 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
}
}
}
+
+ // Okay, the instruction has been completely processed, input and output
+ // registers have been added. As a final sanity check, make sure this is
+ // not a noop-copy. If it is, nuke it.
+ {
+ unsigned Src, Dst;
+ if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
+ ++NumDCE;
+ DEBUG(std::cerr << "Removing now-noop copy: " << MI);
+ MBB.erase(&MI);
+ }
+ }
ProcessNextInst:
MII = NextMII;
}