[PATCH] D72938: Fix an assertion failure in DwarfExpression's subregister composition

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 13:19:43 PST 2020


aprantl updated this revision to Diff 239418.
aprantl marked an inline comment as done.
aprantl added a comment.

Address review feedback.

Bjorn made an excellent point about operations that need access to more bits, such as DW_OP_shr. I will address that in a follow-up soon!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72938/new/

https://reviews.llvm.org/D72938

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
  llvm/test/DebugInfo/MIR/ARM/subregister-full-piece.mir


Index: llvm/test/DebugInfo/MIR/ARM/subregister-full-piece.mir
===================================================================
--- llvm/test/DebugInfo/MIR/ARM/subregister-full-piece.mir
+++ llvm/test/DebugInfo/MIR/ARM/subregister-full-piece.mir
@@ -11,30 +11,38 @@
 #                                     Q8 = {D16, D17}
 # CHECK-NEXT:                   DW_OP_bregx D16+208, DW_OP_piece 0x8)
 # CHECK-NOT: DW_TAG
-# CHECK:   DW_AT_name	("p1")
+# CHECK:   DW_AT_name	("q8")
+# CHECK: DW_TAG_variable
+# CHECK-NOT: DW_TAG
+# CHECK:   DW_AT_location
+#                                     Q9 = {D18, D19}
+# CHECK-NEXT:                   DW_OP_bregx D18+0, DW_OP_piece 0x7)
+# CHECK-NOT: DW_TAG
+# CHECK:   DW_AT_name	("q9")
 
-# CHECK-NOT: DW_AT_location
-# CHECK: DW_TAG
 --- |
   target triple = "thumbv7s-apple-ios"
-  define hidden void @f() !dbg !118 {
+  define hidden void @f() !dbg !5 {
   for.body:
-  ret void, !dbg !260
+  ret void, !dbg !20
   }
   !llvm.module.flags = !{!1, !2}
-  !llvm.dbg.cu = !{!6}
+  !llvm.dbg.cu = !{!3}
   !1 = !{i32 7, !"Dwarf Version", i32 4}
   !2 = !{i32 2, !"Debug Info Version", i32 3}
-  !6 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !50, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
-  !50 = !DIFile(filename: "t.cpp", directory: "/")
-  !118 = distinct !DISubprogram(name: "f",scope: !50, file: !50, line: 1, type: !120, scopeLine: 1, unit: !6)
-  !120 = !DISubroutineType(types: !{})
-  !134 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "uint8x8x2_t", file: !50, line: 113, size: 128, flags: DIFlagTypePassByValue, elements: !{})
-  !139 = !DILocalVariable(name: "p1", scope: !118, file: !50, line: 1, type: !134)
-  !260 = !DILocation(line: 0, scope: !118)
+  !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !4, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+  !4 = !DIFile(filename: "t.cpp", directory: "/")
+  !5 = distinct !DISubprogram(name: "f",scope: !4, file: !4, line: 1, type: !6, scopeLine: 1, unit: !3)
+  !6 = !DISubroutineType(types: !{})
+  !7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "uint8x8x2_t", file: !4, line: 113, size: 128, flags: DIFlagTypePassByValue, elements: !{})
+  !8 = !DILocalVariable(name: "q8", scope: !5, file: !4, line: 1, type: !7)
+  !9 = !DILocalVariable(name: "q9", scope: !5, file: !4, line: 1, type: !7)
+  !10 = !DILocalVariable(name: "q10", scope: !5, file: !4, line: 1, type: !7)
+  !20 = !DILocation(line: 0, scope: !5)
 name:            f
 body:             |
   bb.2.for.body:
-    t2Bcc %bb.2.for.body, 0, killed $cpsr, debug-location !260
-    DBG_VALUE $q8, 0, !139, !DIExpression(DW_OP_plus_uconst, 208, DW_OP_LLVM_fragment, 0, 64), debug-location !260
+    t2Bcc %bb.2.for.body, 0, killed $cpsr, debug-location !20
+    DBG_VALUE $q8, 0, !8, !DIExpression(DW_OP_plus_uconst, 208, DW_OP_LLVM_fragment, 0, 64), debug-location !20
+    DBG_VALUE $q9, 0, !9, !DIExpression(DW_OP_LLVM_fragment, 0, 56), debug-location !20
     tB %bb.2.for.body, 14, $noreg
Index: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -110,7 +110,7 @@
     unsigned SubRegSize;
     const char *Comment;
 
-    /// Create a full register, not extra DW_OP_piece operators necessary.
+    /// Create a full register, no extra DW_OP_piece operators necessary.
     static Register createRegister(int RegNo, const char *Comment) {
       return {RegNo, 0, Comment};
     }
Index: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -149,8 +149,8 @@
     if (Reg < 0)
       continue;
 
-    // Intersection between the bits we already emitted and the bits
-    // covered by this subregister.
+    // Used to build the intersection between the bits we already
+    // emitted and the bits covered by this subregister.
     SmallBitVector CurSubReg(RegSize, false);
     CurSubReg.set(Offset, Offset + Size);
 
@@ -161,7 +161,7 @@
       if (Offset > CurPos)
         DwarfRegs.push_back(Register::createSubRegister(
             -1, Offset - CurPos, "no DWARF register encoding"));
-      if (Offset == 0 && Size == MaxSize)
+      if (Offset == 0 && Size >= MaxSize)
         DwarfRegs.push_back(Register::createRegister(Reg, "sub-register"));
       else
         DwarfRegs.push_back(Register::createSubRegister(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72938.239418.patch
Type: text/x-patch
Size: 4640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200121/975b9908/attachment.bin>


More information about the llvm-commits mailing list