[llvm-branch-commits] [llvm] 87c7863 - Reland "[StackColoring] Remap PseudoSourceValue frame indices via MachineFunction::getPSVManager()""

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 27 16:40:24 PST 2020


Author: Fangrui Song
Date: 2020-01-27T16:39:56-08:00
New Revision: 87c7863c3ec4b66944bfcf39efd666de417f28b8

URL: https://github.com/llvm/llvm-project/commit/87c7863c3ec4b66944bfcf39efd666de417f28b8
DIFF: https://github.com/llvm/llvm-project/commit/87c7863c3ec4b66944bfcf39efd666de417f28b8.diff

LOG: Reland "[StackColoring] Remap PseudoSourceValue frame indices via MachineFunction::getPSVManager()""

Reland 7a8b0b1595e7dc878b48cf9bbaa652087a6895db, with a fix that checks
`!E.value().empty()` to avoid inserting a zero to SlotRemap.

Debugged by rnk@ in https://bugs.chromium.org/p/chromium/issues/detail?id=1045650#c33

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D73510

(cherry picked from commit 68051c122440b556e88a946bce12bae58fcfccb4)
(cherry picked from commit c7c5da6df30141c563e1f5b8ddeabeecdd29e55e)

Added: 
    

Modified: 
    llvm/lib/CodeGen/StackColoring.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 40bc36c3030b..9d4fdc6b624c 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -960,7 +960,8 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
   }
 
   // Remap all instructions to the new stack slots.
-  std::vector<std::vector<MachineMemOperand *>> SSRefs(MFI->getObjectIndexEnd());
+  std::vector<std::vector<MachineMemOperand *>> SSRefs(
+      MFI->getObjectIndexEnd());
   for (MachineBasicBlock &BB : *MF)
     for (MachineInstr &I : BB) {
       // Skip lifetime markers. We'll remove them soon.
@@ -1074,12 +1075,13 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
     }
 
   // Rewrite MachineMemOperands that reference old frame indices.
-  for (auto E : enumerate(SSRefs)) {
-    const PseudoSourceValue *NewSV =
-        MF->getPSVManager().getFixedStack(SlotRemap[E.index()]);
-    for (MachineMemOperand *Ref : E.value())
-      Ref->setValue(NewSV);
-  }
+  for (auto E : enumerate(SSRefs))
+    if (!E.value().empty()) {
+      const PseudoSourceValue *NewSV =
+          MF->getPSVManager().getFixedStack(SlotRemap.find(E.index())->second);
+      for (MachineMemOperand *Ref : E.value())
+        Ref->setValue(NewSV);
+    }
 
   // Update the location of C++ catch objects for the MSVC personality routine.
   if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())


        


More information about the llvm-branch-commits mailing list