Count correctly when a COPY turns into a spill or reload.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 15 Sep 2011 18:22:52 +0000 (18:22 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 15 Sep 2011 18:22:52 +0000 (18:22 +0000)
The number of spills could go negative since a folded COPY is just a
spill, and it may be eliminated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139815 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/InlineSpiller.cpp

index 5078f3a4bd0b186acef28e7895bc76064d2af4c8..169a867aa7a5500eabc2eeb1936fc5c1b657c947 100644 (file)
@@ -1002,6 +1002,7 @@ bool InlineSpiller::coalesceStackAccess(MachineInstr *MI, unsigned Reg) {
 bool InlineSpiller::foldMemoryOperand(MachineBasicBlock::iterator MI,
                                       const SmallVectorImpl<unsigned> &Ops,
                                       MachineInstr *LoadMI) {
+  bool WasCopy = MI->isCopy();
   // TargetInstrInfo::foldMemoryOperand only expects explicit, non-tied
   // operands.
   SmallVector<unsigned, 8> FoldOps;
@@ -1031,7 +1032,12 @@ bool InlineSpiller::foldMemoryOperand(MachineBasicBlock::iterator MI,
     VRM.addSpillSlotUse(StackSlot, FoldMI);
   MI->eraseFromParent();
   DEBUG(dbgs() << "\tfolded: " << *FoldMI);
-  ++NumFolded;
+  if (!WasCopy)
+    ++NumFolded;
+  else if (Ops.front() == 0)
+    ++NumSpills;
+  else
+    ++NumReloads;
   return true;
 }