Skip to content

Commit 87c7863

Browse files
committed
Reland "[StackColoring] Remap PseudoSourceValue frame indices via MachineFunction::getPSVManager()""
Reland 7a8b0b1, 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 68051c1) (cherry picked from commit c7c5da6)
1 parent c23212a commit 87c7863

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,8 @@ 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());
963+
std::vector<std::vector<MachineMemOperand *>> SSRefs(
964+
MFI->getObjectIndexEnd());
964965
for (MachineBasicBlock &BB : *MF)
965966
for (MachineInstr &I : BB) {
966967
// Skip lifetime markers. We'll remove them soon.
@@ -1074,12 +1075,13 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
10741075
}
10751076

10761077
// 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-
}
1078+
for (auto E : enumerate(SSRefs))
1079+
if (!E.value().empty()) {
1080+
const PseudoSourceValue *NewSV =
1081+
MF->getPSVManager().getFixedStack(SlotRemap.find(E.index())->second);
1082+
for (MachineMemOperand *Ref : E.value())
1083+
Ref->setValue(NewSV);
1084+
}
10831085

10841086
// Update the location of C++ catch objects for the MSVC personality routine.
10851087
if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())

0 commit comments

Comments
 (0)