[PATCH] D80819: [DebugInfo][DAG] Don't reuse debug location on COPY if width changes.

Tobias Bosch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 12:00:44 PDT 2020


tbosch updated this revision to Diff 267317.
tbosch added a comment.

Do the width check at the right time

As suggested by vsk


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80819

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/DebugInfo/X86/dbg-value-funcarg3.ll


Index: llvm/test/DebugInfo/X86/dbg-value-funcarg3.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/dbg-value-funcarg3.ll
@@ -0,0 +1,58 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -start-after=codegenprepare -stop-before=finalize-isel -o - %s | FileCheck %s
+
+; Input to this test looked like this and was compiled using: clang -g -O1 -mllvm -stop-after=codegenprepare -S
+;
+;    int fn1(long t1) {
+;      return t;
+;    }
+;
+
+; Catch metadata references for involved variables.
+;
+; CHECK-DAG: ![[T1:.*]] = !DILocalVariable(name: "t1"
+
+
+define dso_local i32 @fn1(i64 %t1) local_unnamed_addr #0 !dbg !7 {
+; We expect that the same width COPY reuses the debug location,
+; but the width narrowing COPY does not.
+; 
+; CHECK-LABEL: name:            fn1
+; CHECK: DBG_VALUE $rdi, $noreg, ![[T1]], !DIExpression(),
+; CHECK-NEXT: %0:gr64 = COPY $rdi
+; CHECK-NEXT: DBG_VALUE %0, $noreg, ![[T1]], !DIExpression(),
+; CHECK-NEXT: %1:gr32 = COPY %0.sub_32bit
+; CHECK-NEXT: COPY
+; CHECK-NEXT: RET
+entry:
+  call void @llvm.dbg.value(metadata i64 %t1, metadata !13, metadata !DIExpression()), !dbg !14
+  %0 = trunc i64 %t1 to i32, !dbg !15
+  ret i32 %0, !dbg !16
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #0 = { norecurse nounwind readnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (git at github.com:tbosch/llvm-project.git 0b11aed869bf09ba60
+d7ed17334cf0b76e6a5922)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "test.cc", directory: "")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 11.0.0 (git at github.com:tbosch/llvm-project.git 0b11aed869bf09ba60d7ed17334cf0b76e6a5922)"}
+!7 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
+!8 = !DISubroutineType(types: !9)
+!9 = !{!10, !11}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
+!12 = !{!13}
+!13 = !DILocalVariable(name: "t1", arg: 1, scope: !7, file: !1, line: 1, type: !11)
+!14 = !DILocation(line: 0, scope: !7)
+!15 = !DILocation(line: 2, column: 10, scope: !7)
+!16 = !DILocation(line: 2, column: 3, scope: !7)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -623,7 +623,9 @@
         // Otherwise this is another use or second copy use.
         CopyUseMI = nullptr; break;
       }
-      if (CopyUseMI) {
+      if (CopyUseMI &&
+          TRI.getRegSizeInBits(LDI->second, MRI) ==
+              TRI.getRegSizeInBits(CopyUseMI->getOperand(0).getReg(), MRI)) {
         // Use MI's debug location, which describes where Variable was
         // declared, rather than whatever is attached to CopyUseMI.
         MachineInstr *NewMI =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80819.267317.patch
Type: text/x-patch
Size: 3498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200529/ee7e8628/attachment-0001.bin>


More information about the llvm-commits mailing list