[PATCH] D26616: [Stack Slot Coloring] Skip pseudo debug instructions in removing dead stores

Sumanth Gundapaneni via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 09:56:04 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL291455: In the below scenario, we must be able to skip the a DBG_VALUE instruction and (authored by sgundapa).

Changed prior to commit:
  https://reviews.llvm.org/D26616?vs=77834&id=83644#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26616

Files:
  llvm/trunk/lib/CodeGen/StackSlotColoring.cpp


Index: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
+++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
@@ -381,7 +381,6 @@
        I != E; ++I) {
     if (DCELimit != -1 && (int)NumDead >= DCELimit)
       break;
-
     int FirstSS, SecondSS;
     if (TII->isStackSlotCopy(*I, FirstSS, SecondSS) && FirstSS == SecondSS &&
         FirstSS != -1) {
@@ -392,12 +391,18 @@
     }
 
     MachineBasicBlock::iterator NextMI = std::next(I);
-    if (NextMI == MBB->end()) continue;
+    MachineBasicBlock::iterator ProbableLoadMI = I;
 
     unsigned LoadReg = 0;
     unsigned StoreReg = 0;
     if (!(LoadReg = TII->isLoadFromStackSlot(*I, FirstSS)))
       continue;
+    // Skip the ...pseudo debugging... instructions between a load and store.
+    while ((NextMI != E) && NextMI->isDebugValue()) {
+      ++NextMI;
+      ++I;
+    }
+    if (NextMI == E) continue;
     if (!(StoreReg = TII->isStoreToStackSlot(*NextMI, SecondSS)))
       continue;
     if (FirstSS != SecondSS || LoadReg != StoreReg || FirstSS == -1) continue;
@@ -407,7 +412,7 @@
 
     if (NextMI->findRegisterUseOperandIdx(LoadReg, true, nullptr) != -1) {
       ++NumDead;
-      toErase.push_back(&*I);
+      toErase.push_back(&*ProbableLoadMI);
     }
 
     toErase.push_back(&*NextMI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26616.83644.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170109/b8772723/attachment.bin>


More information about the llvm-commits mailing list