[llvm] 68051c1 - Revert "[StackColoring] Remap PseudoSourceValue frame indices via MachineFunction::getPSVManager()"

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 08:22:46 PST 2020


Author: Nico Weber
Date: 2020-01-27T11:22:33-05:00
New Revision: 68051c122440b556e88a946bce12bae58fcfccb4

URL: https://github.com/llvm/llvm-project/commit/68051c122440b556e88a946bce12bae58fcfccb4
DIFF: https://github.com/llvm/llvm-project/commit/68051c122440b556e88a946bce12bae58fcfccb4.diff

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

This reverts commit 7a8b0b1595e7dc878b48cf9bbaa652087a6895db.
It seems to break exception handling on 32-bit Windows, see
https://crbug.com/1045650

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/PseudoSourceValue.h
    llvm/lib/CodeGen/StackColoring.cpp
    llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/PseudoSourceValue.h b/llvm/include/llvm/CodeGen/PseudoSourceValue.h
index 593a865ea545..c5057fbcc8a7 100644
--- a/llvm/include/llvm/CodeGen/PseudoSourceValue.h
+++ b/llvm/include/llvm/CodeGen/PseudoSourceValue.h
@@ -93,7 +93,7 @@ class PseudoSourceValue {
 /// A specialized PseudoSourceValue for holding FixedStack values, which must
 /// include a frame index.
 class FixedStackPseudoSourceValue : public PseudoSourceValue {
-  const int FI;
+  int FI;
 
 public:
   explicit FixedStackPseudoSourceValue(int FI, const TargetInstrInfo &TII)
@@ -112,6 +112,7 @@ class FixedStackPseudoSourceValue : public PseudoSourceValue {
   void printCustom(raw_ostream &OS) const override;
 
   int getFrameIndex() const { return FI; }
+  void setFrameIndex(int FI) { this->FI = FI; }
 };
 
 class CallEntryPseudoSourceValue : public PseudoSourceValue {

diff  --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 40bc36c3030b..b091e6ffe069 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -960,7 +960,6 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
   }
 
   // Remap all instructions to the new stack slots.
-  std::vector<std::vector<MachineMemOperand *>> SSRefs(MFI->getObjectIndexEnd());
   for (MachineBasicBlock &BB : *MF)
     for (MachineInstr &I : BB) {
       // Skip lifetime markers. We'll remove them soon.
@@ -1026,14 +1025,13 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
       SmallVector<MachineMemOperand *, 2> NewMMOs;
       bool ReplaceMemOps = false;
       for (MachineMemOperand *MMO : I.memoperands()) {
-        // Collect MachineMemOperands which reference
-        // FixedStackPseudoSourceValues with old frame indices.
         if (const auto *FSV = dyn_cast_or_null<FixedStackPseudoSourceValue>(
                 MMO->getPseudoValue())) {
           int FI = FSV->getFrameIndex();
           auto To = SlotRemap.find(FI);
           if (To != SlotRemap.end())
-            SSRefs[FI].push_back(MMO);
+            const_cast<FixedStackPseudoSourceValue *>(FSV)->setFrameIndex(
+                To->second);
         }
 
         // If this memory location can be a slot remapped here,
@@ -1073,14 +1071,6 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
         I.setMemRefs(*MF, NewMMOs);
     }
 
-  // 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);
-  }
-
   // Update the location of C++ catch objects for the MSVC personality routine.
   if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
     for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)

diff  --git a/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir b/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
index 0085369e1978..87a1f0d8b83d 100644
--- a/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
+++ b/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
@@ -1,16 +1,4 @@
-# RUN: llc -run-pass=stack-coloring %s -o - | FileCheck %s
-
-## Test %stack.1 is merged into %stack.0 and there is no MemoryMemOperand
-## referencing %stack.1. This regression test is sensitive to the StackColoring
-## algorithm. Please adjust or delete this test if the merging strategy
-## changes.
-
-# CHECK:    {{^}}stack:
-# CHECK-NEXT: - { id: 0,
-# CHECK-NOT:  - { id: 1,
-# CHECK:      - { id: 2,
-# CHECK-NOT: %stack.1
-
+# RUN: llc -o - %s -start-before=stack-coloring
 --- |
   ; ModuleID = '<stdin>'
   source_filename = "<stdin>"


        


More information about the llvm-commits mailing list