Skip to content

Commit cc6ae37

Browse files
Fix Debug Info after removing stack slot
1 parent 24f1b7a commit cc6ae37

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,13 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
899899
unsigned FixedMemOp = 0;
900900
unsigned FixedDbg = 0;
901901

902+
// Remove debug information for deleted slots.
903+
erase_if(MF->getVariableDbgInfo(), [&](auto &VI) {
904+
int Slot = VI.getStackSlot();
905+
return Slot >= 0 && Intervals[Slot]->empty() &&
906+
InterestingSlots.test(Slot) && !ConservativeSlots.test(Slot);
907+
});
908+
902909
// Remap debug information that refers to stack slots.
903910
for (auto &VI : MF->getVariableDbgInfo()) {
904911
if (!VI.Var || !VI.inStackSlot())

llvm/test/DebugInfo/COFF/lexicalblock.ll

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,12 @@
6363
; CHECK: LocalSym {
6464
; CHECK: VarName: localA
6565
; CHECK: }
66-
; CHECK: LocalSym {
67-
; CHECK: VarName: localB
68-
; CHECK: }
69-
; CHECK: BlockSym {
70-
; CHECK: Kind: S_BLOCK32 {{.*}}
71-
; CHECK: BlockName:
72-
; CHECK: }
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: }
8366
; CHECK: BlockSym {
8467
; CHECK: Kind: S_BLOCK32 {{.*}}
8568
; CHECK: BlockName:
8669
; CHECK: }
87-
; CHECK: ScopeEndSym {
88-
; CHECK: }
89-
; CHECK: BlockSym {
90-
; CHECK: Kind: S_BLOCK32 {{.*}}
91-
; CHECK: BlockName:
70+
; CHECK: LocalSym {
71+
; CHECK: VarName: localB
9272
; CHECK: }
9373
; CHECK: ScopeEndSym {
9474
; CHECK: Kind: S_END {{.*}}

0 commit comments

Comments
 (0)