Skip to content

Commit cd2bff1

Browse files
committed
[StackColoring] Fix a debug invariance problem
Ignore dbg instructions when collecting stack slot markers. This is to make sure the coloring is invariant regarding presence of dbg instructions (even in cases when the dbg instructions might be badly placed in the input). Differential Revision: https://reviews.llvm.org/D109758
1 parent 1de516d commit cd2bff1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ unsigned StackColoring::collectMarkers(unsigned NumSlot) {
687687

688688
// Walk the instructions in the block to look for start/end ops.
689689
for (MachineInstr &MI : *MBB) {
690+
if (MI.isDebugInstr())
691+
continue;
690692
if (MI.getOpcode() == TargetOpcode::LIFETIME_START ||
691693
MI.getOpcode() == TargetOpcode::LIFETIME_END) {
692694
int Slot = getStartOrEndSlot(MI);

llvm/test/CodeGen/X86/StackColoring-dbg-invariance.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ body: |
7474
7575
; CHECK-LABEL: name: test_1
7676
; CHECK: liveins: $edi
77-
; CHECK: DBG_VALUE %stack.1.a4, $noreg, !9, !DIExpression(), debug-location !11
77+
; CHECK: DBG_VALUE %stack.0.a1, $noreg, !9, !DIExpression(), debug-location !11
7878
; CHECK: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
79-
; CHECK: [[LEA64r1:%[0-9]+]]:gr64 = LEA64r %stack.1.a4, 1, $noreg, 0, $noreg
79+
; CHECK: [[LEA64r1:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
8080
; CHECK: RET 0
8181
DBG_VALUE %stack.3.a4, $noreg, !9, !DIExpression(), debug-location !11
8282
LIFETIME_START %stack.3.a4

0 commit comments

Comments
 (0)