[llvm] r309773 - Update LiveDebugValues to generate DIExpressions for spill offsets

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 17:16:56 PDT 2017


Author: adrian
Date: Tue Aug  1 17:16:56 2017
New Revision: 309773

URL: http://llvm.org/viewvc/llvm-project?rev=309773&view=rev
Log:
Update LiveDebugValues to generate DIExpressions for spill offsets
instead of using the deprecated offset field of DBG_VALUE.

This has no observable effect on the generated DWARF, but the
assembler comments will look different.

rdar://problem/33580047

Modified:
    llvm/trunk/lib/CodeGen/LiveDebugValues.cpp
    llvm/trunk/test/DebugInfo/MIR/X86/live-debug-values-spill.mir

Modified: llvm/trunk/lib/CodeGen/LiveDebugValues.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugValues.cpp?rev=309773&r1=309772&r2=309773&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveDebugValues.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveDebugValues.cpp Tue Aug  1 17:16:56 2017
@@ -29,6 +29,7 @@
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineMemOperand.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/Support/Debug.h"
@@ -446,11 +447,15 @@ void LiveDebugValues::transferSpillInst(
       // iterator in our caller.
       unsigned SpillBase;
       int SpillOffset = extractSpillBaseRegAndOffset(MI, SpillBase);
+      const Module *M = MF->getMMI().getModule();
       const MachineInstr *DMI = &VarLocIDs[ID].MI;
+      auto *SpillExpr = DIExpression::prepend(
+          DMI->getDebugExpression(), DIExpression::NoDeref, SpillOffset);
+      // Add the expression to the metadata graph so isn't lost in MIR dumps.
+      M->getNamedMetadata("llvm.dbg.mir")->addOperand(SpillExpr);
       MachineInstr *SpDMI =
           BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(), true, SpillBase,
-                  DMI->getDebugVariable(), DMI->getDebugExpression());
-      SpDMI->getOperand(1).setImm(SpillOffset);
+                  DMI->getDebugVariable(), SpillExpr);
       DEBUG(dbgs() << "Creating DBG_VALUE inst for spill: ";
             SpDMI->print(dbgs(), false, TII));
 

Modified: llvm/trunk/test/DebugInfo/MIR/X86/live-debug-values-spill.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/MIR/X86/live-debug-values-spill.mir?rev=309773&r1=309772&r2=309773&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/MIR/X86/live-debug-values-spill.mir (original)
+++ llvm/trunk/test/DebugInfo/MIR/X86/live-debug-values-spill.mir Tue Aug  1 17:16:56 2017
@@ -47,31 +47,34 @@
 # llc -stop-after=funclet-layout < spill1.ll > spill1.mir                
 #
 # Make sure that we generated DBG_VALUE instructions for the spills
+# GENERATE: ![[MINUS48:.*]] = !DIExpression(DW_OP_constu, 48, DW_OP_minus)
+# GENERATE: ![[MINUS52:.*]] = !DIExpression(DW_OP_constu, 52, DW_OP_minus)
+# GENERATE: ![[MINUS56:.*]] = !DIExpression(DW_OP_constu, 56, DW_OP_minus)
 # GENERATE:      bb.1.if.end:
 # GENERATE:      MOV32mr %rbp, 1, _, -48, _, killed %edx :: (store 4 into %stack.5)
-# GENERATE-NEXT: DBG_VALUE debug-use %rbp, -48, !26, !38
+# GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, !29, ![[MINUS48]]
 # GENERATE:      MOV32mr %rbp, 1, _, -52, _, killed %r8d :: (store 4 into %stack.4)
-# GENERATE-NEXT: DBG_VALUE debug-use %rbp, -52, !32, !38
+# GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
 # GENERATE:      MOV32mr %rbp, 1, _, -56, _, killed %esi :: (store 4 into %stack.3)
-# GENERATE-NEXT: DBG_VALUE debug-use %rbp, -56, !34, !38
+# GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
 #
 # Check that the spill locations that are valid at the end of bb.1.if.end are
 # propagated to subsequent BBs.
 #
 # GENERATE:      bb.2.if.then4:
 # GENERATE-NOT:  bb.3:
-# GENERATE-DAG:  DBG_VALUE debug-use %rbp, -56, !34, !38
-# GENERATE-DAG:  DBG_VALUE debug-use %rbp, -52, !32, !38
+# GENERATE-DAG:  DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
+# GENERATE-DAG:  DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
 #
 # GENERATE:      bb.3:
 # GENERATE-NOT:  bb.4.if.end13:
-# GENERATE-DAG:  DBG_VALUE debug-use %rbp, -56, !34, !38
-# GENERATE-DAG:  DBG_VALUE debug-use %rbp, -52, !32, !38
+# GENERATE-DAG:  DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
+# GENERATE-DAG:  DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
 #
 # GENERATE:      bb.4.if.end13:
 # GENERATE-NOT:  bb.5.cleanup:
-# GENERATE-DAG:  DBG_VALUE debug-use %rbp, -56, !34, !38
-# GENERATE-DAG:  DBG_VALUE debug-use %rbp, -52, !32, !38
+# GENERATE-DAG:  DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
+# GENERATE-DAG:  DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
 # 
 # Check that the spill location rbp-48 (the variable int0) is not propagated 
 # because int0 is redefined within the same basic block.




More information about the llvm-commits mailing list