[llvm] cd2bff1 - [StackColoring] Fix a debug invariance problem

Bjorn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 14 10:25:10 PDT 2021


Author: Bjorn Pettersson
Date: 2021-09-14T19:21:56+02:00
New Revision: cd2bff1ef10563bc710ca7a97aeb20297fc99597

URL: https://github.com/llvm/llvm-project/commit/cd2bff1ef10563bc710ca7a97aeb20297fc99597
DIFF: https://github.com/llvm/llvm-project/commit/cd2bff1ef10563bc710ca7a97aeb20297fc99597.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/CodeGen/StackColoring.cpp
    llvm/test/CodeGen/X86/StackColoring-dbg-invariance.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 162f3aab024d4..623d5da9831e9 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -687,6 +687,8 @@ unsigned StackColoring::collectMarkers(unsigned NumSlot) {
 
     // Walk the instructions in the block to look for start/end ops.
     for (MachineInstr &MI : *MBB) {
+      if (MI.isDebugInstr())
+        continue;
       if (MI.getOpcode() == TargetOpcode::LIFETIME_START ||
           MI.getOpcode() == TargetOpcode::LIFETIME_END) {
         int Slot = getStartOrEndSlot(MI);

diff  --git a/llvm/test/CodeGen/X86/StackColoring-dbg-invariance.mir b/llvm/test/CodeGen/X86/StackColoring-dbg-invariance.mir
index 8f250a690c33f..0fdddeb7257e4 100644
--- a/llvm/test/CodeGen/X86/StackColoring-dbg-invariance.mir
+++ b/llvm/test/CodeGen/X86/StackColoring-dbg-invariance.mir
@@ -74,9 +74,9 @@ body:             |
 
     ; CHECK-LABEL: name: test_1
     ; CHECK: liveins: $edi
-    ; CHECK: DBG_VALUE %stack.1.a4, $noreg, !9, !DIExpression(), debug-location !11
+    ; CHECK: DBG_VALUE %stack.0.a1, $noreg, !9, !DIExpression(), debug-location !11
     ; CHECK: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
-    ; CHECK: [[LEA64r1:%[0-9]+]]:gr64 = LEA64r %stack.1.a4, 1, $noreg, 0, $noreg
+    ; CHECK: [[LEA64r1:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
     ; CHECK: RET 0
     DBG_VALUE %stack.3.a4, $noreg, !9, !DIExpression(), debug-location !11
     LIFETIME_START %stack.3.a4


        


More information about the llvm-commits mailing list