Skip to content

Commit d90f716

Browse files
committed
Revert "[StackColoring] Delete dead stack slots (llvm#75351)"
This reverts commit 08b306d. it causes the following assertion failure: llvm/include/llvm/CodeGen/MachineFrameInfo.h:530: int64_t llvm::MachineFrameInfo::getObjectOffset(int) const: Assertion `!isDeadObjectIndex(ObjectIdx) && "Getting frame offset for a dead object?"' failed.
1 parent 70bcd81 commit d90f716

File tree

6 files changed

+32
-48
lines changed

6 files changed

+32
-48
lines changed

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -900,15 +900,6 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
900900
unsigned FixedMemOp = 0;
901901
unsigned FixedDbg = 0;
902902

903-
// Remove debug information for deleted slots.
904-
erase_if(MF->getVariableDbgInfo(), [&](auto &VI) {
905-
if (!VI.inStackSlot())
906-
return false;
907-
int Slot = VI.getStackSlot();
908-
return Slot >= 0 && Intervals[Slot]->empty() &&
909-
InterestingSlots.test(Slot) && !ConservativeSlots.test(Slot);
910-
});
911-
912903
// Remap debug information that refers to stack slots.
913904
for (auto &VI : MF->getVariableDbgInfo()) {
914905
if (!VI.Var || !VI.inStackSlot())
@@ -1259,15 +1250,8 @@ bool StackColoring::runOnMachineFunction(MachineFunction &Func) {
12591250

12601251
// Do not bother looking at empty intervals.
12611252
for (unsigned I = 0; I < NumSlots; ++I) {
1262-
int Slot = SortedSlots[I];
1263-
if (Intervals[Slot]->empty()) {
1264-
if (InterestingSlots.test(Slot) && !ConservativeSlots.test(Slot)) {
1265-
RemovedSlots += 1;
1266-
ReducedSize += MFI->getObjectSize(Slot);
1267-
MFI->RemoveStackObject(Slot);
1268-
}
1253+
if (Intervals[SortedSlots[I]]->empty())
12691254
SortedSlots[I] = -1;
1270-
}
12711255
}
12721256

12731257
// This is a simple greedy algorithm for merging allocas. First, sort the
@@ -1355,7 +1339,7 @@ bool StackColoring::runOnMachineFunction(MachineFunction &Func) {
13551339

13561340
// Scan the entire function and update all machine operands that use frame
13571341
// indices to use the remapped frame index.
1358-
if (RemovedSlots > 0) {
1342+
if (!SlotRemap.empty()) {
13591343
expungeSlotMap(SlotRemap, NumSlots);
13601344
remapInstructions(SlotRemap);
13611345
}

llvm/test/CodeGen/PowerPC/aix32-cc-abi-vaarg.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ entry:
347347

348348
; 32BIT-LABEL: stack:
349349
; 32BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 4, alignment: 4,
350+
; 32BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 4, alignment: 4,
350351
; 32BIT-DAG: - { id: 2, name: '', type: default, offset: 0, size: 8, alignment: 8,
351352
; 32BIT-DAG: - { id: 3, name: '', type: default, offset: 0, size: 8, alignment: 8,
352353

llvm/test/CodeGen/PowerPC/aix64-cc-abi-vaarg.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@
138138
; 64BIT-LABEL: fixedStack:
139139
; 64BIT-DAG: - { id: 0, type: default, offset: 112, size: 8, alignment: 16, stack-id: default,
140140

141-
; 64BIT-LABEL: stack: []
141+
; 64BIT-LABEL: stack:
142+
; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8, alignment: 8,
143+
; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8, alignment: 8,
142144

143145
; 64BIT-LABEL: body: |
144146
; 64BIT-DAG: liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10
@@ -303,7 +305,9 @@
303305
; 64BIT-LABEL: fixedStack:
304306
; 64BIT-DAG: - { id: 0, type: default, offset: 152, size: 8
305307

306-
; 64BIT-LABEL: stack: []
308+
; 64BIT-LABEL: stack:
309+
; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8
310+
; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8
307311

308312
; 64BIT-LABEL: body: |
309313
; 64BIT-DAG: liveins: $f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8, $f9, $f10, $f11, $f12, $f13

llvm/test/CodeGen/RISCV/dead-stack-slot.ll

Lines changed: 0 additions & 25 deletions
This file was deleted.

llvm/test/CodeGen/X86/StackColoring-tbaa.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ body: |
5353
; CHECK: [[LEA64r:%[0-9]+]]:gr64 = nuw LEA64r %stack.1.agg, 1, $noreg, 24, $noreg
5454
; CHECK-NEXT: CMP8mi %stack.1.agg, 1, $noreg, 47, $noreg, 0, implicit-def $eflags :: (dereferenceable load (s8) from %ir.a22, !tbaa !2)
5555
; CHECK-NEXT: [[CMOV64rm:%[0-9]+]]:gr64 = CMOV64rm [[LEA64r]], %stack.1.agg, 1, $noreg, 24, $noreg, 8, implicit $eflags :: (dereferenceable load (s64) from %ir.a2)
56-
; CHECK-NEXT: [[MOV8rm:%[0-9]+]]:gr8 = MOV8rm killed [[CMOV64rm]], 1, $noreg, 16, $noreg :: (load (s8) from %ir.add.ptr.i)
56+
; CHECK-NEXT: [[MOV8rm:%[0-9]+]]:gr8 = MOV8rm killed [[CMOV64rm]], 1, $noreg, 16, $noreg :: (load (s8) from %ir.add.ptr.i, !tbaa !2)
5757
; CHECK-NEXT: $al = COPY [[MOV8rm]]
5858
; CHECK-NEXT: RET 0, $al
5959
LIFETIME_START %stack.0.padding

llvm/test/DebugInfo/COFF/lexicalblock.ll

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,32 @@
6363
; CHECK: LocalSym {
6464
; CHECK: VarName: localA
6565
; CHECK: }
66+
; CHECK: LocalSym {
67+
; CHECK: VarName: localB
68+
; CHECK: }
6669
; CHECK: BlockSym {
6770
; CHECK: Kind: S_BLOCK32 {{.*}}
6871
; CHECK: BlockName:
6972
; CHECK: }
70-
; CHECK: LocalSym {
71-
; CHECK: VarName: localB
73+
; CHECK: ScopeEndSym {
74+
; CHECK: Kind: S_END {{.*}}
75+
; CHECK: }
76+
; CHECK: BlockSym {
77+
; CHECK: Kind: S_BLOCK32 {{.*}}
78+
; CHECK: BlockName:
79+
; CHECK: }
80+
; CHECK: ScopeEndSym {
81+
; CHECK: Kind: S_END {{.*}}
82+
; CHECK: }
83+
; CHECK: BlockSym {
84+
; CHECK: Kind: S_BLOCK32 {{.*}}
85+
; CHECK: BlockName:
86+
; CHECK: }
87+
; CHECK: ScopeEndSym {
88+
; CHECK: }
89+
; CHECK: BlockSym {
90+
; CHECK: Kind: S_BLOCK32 {{.*}}
91+
; CHECK: BlockName:
7292
; CHECK: }
7393
; CHECK: ScopeEndSym {
7494
; CHECK: Kind: S_END {{.*}}

0 commit comments

Comments
 (0)