Skip to content

Commit 68051c1

Browse files
committed
Revert "[StackColoring] Remap PseudoSourceValue frame indices via MachineFunction::getPSVManager()"
This reverts commit 7a8b0b1. It seems to break exception handling on 32-bit Windows, see https://crbug.com/1045650
1 parent 4e69df0 commit 68051c1

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

llvm/include/llvm/CodeGen/PseudoSourceValue.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PseudoSourceValue {
9393
/// A specialized PseudoSourceValue for holding FixedStack values, which must
9494
/// include a frame index.
9595
class FixedStackPseudoSourceValue : public PseudoSourceValue {
96-
const int FI;
96+
int FI;
9797

9898
public:
9999
explicit FixedStackPseudoSourceValue(int FI, const TargetInstrInfo &TII)
@@ -112,6 +112,7 @@ class FixedStackPseudoSourceValue : public PseudoSourceValue {
112112
void printCustom(raw_ostream &OS) const override;
113113

114114
int getFrameIndex() const { return FI; }
115+
void setFrameIndex(int FI) { this->FI = FI; }
115116
};
116117

117118
class CallEntryPseudoSourceValue : public PseudoSourceValue {

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,6 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
960960
}
961961

962962
// Remap all instructions to the new stack slots.
963-
std::vector<std::vector<MachineMemOperand *>> SSRefs(MFI->getObjectIndexEnd());
964963
for (MachineBasicBlock &BB : *MF)
965964
for (MachineInstr &I : BB) {
966965
// Skip lifetime markers. We'll remove them soon.
@@ -1026,14 +1025,13 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
10261025
SmallVector<MachineMemOperand *, 2> NewMMOs;
10271026
bool ReplaceMemOps = false;
10281027
for (MachineMemOperand *MMO : I.memoperands()) {
1029-
// Collect MachineMemOperands which reference
1030-
// FixedStackPseudoSourceValues with old frame indices.
10311028
if (const auto *FSV = dyn_cast_or_null<FixedStackPseudoSourceValue>(
10321029
MMO->getPseudoValue())) {
10331030
int FI = FSV->getFrameIndex();
10341031
auto To = SlotRemap.find(FI);
10351032
if (To != SlotRemap.end())
1036-
SSRefs[FI].push_back(MMO);
1033+
const_cast<FixedStackPseudoSourceValue *>(FSV)->setFrameIndex(
1034+
To->second);
10371035
}
10381036

10391037
// If this memory location can be a slot remapped here,
@@ -1073,14 +1071,6 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
10731071
I.setMemRefs(*MF, NewMMOs);
10741072
}
10751073

1076-
// Rewrite MachineMemOperands that reference old frame indices.
1077-
for (auto E : enumerate(SSRefs)) {
1078-
const PseudoSourceValue *NewSV =
1079-
MF->getPSVManager().getFixedStack(SlotRemap[E.index()]);
1080-
for (MachineMemOperand *Ref : E.value())
1081-
Ref->setValue(NewSV);
1082-
}
1083-
10841074
// Update the location of C++ catch objects for the MSVC personality routine.
10851075
if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
10861076
for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)

llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
# RUN: llc -run-pass=stack-coloring %s -o - | FileCheck %s
2-
3-
## Test %stack.1 is merged into %stack.0 and there is no MemoryMemOperand
4-
## referencing %stack.1. This regression test is sensitive to the StackColoring
5-
## algorithm. Please adjust or delete this test if the merging strategy
6-
## changes.
7-
8-
# CHECK: {{^}}stack:
9-
# CHECK-NEXT: - { id: 0,
10-
# CHECK-NOT: - { id: 1,
11-
# CHECK: - { id: 2,
12-
# CHECK-NOT: %stack.1
13-
1+
# RUN: llc -o - %s -start-before=stack-coloring
142
--- |
153
; ModuleID = '<stdin>'
164
source_filename = "<stdin>"

0 commit comments

Comments
 (0)