[llvm] r309628 - [codeview] Ignore DBG_VALUEs when choosing a BB start source loc

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 14:03:08 PDT 2017


Author: rnk
Date: Mon Jul 31 14:03:08 2017
New Revision: 309628

URL: http://llvm.org/viewvc/llvm-project?rev=309628&view=rev
Log:
[codeview] Ignore DBG_VALUEs when choosing a BB start source loc

When the first instruction of a basic block has no location (consider a
LEA materializing the address of an alloca for a call), we want to start
the line table for the block with the first valid source location in the
block.  We need to ignore DBG_VALUE instructions during this scan to get
decent line tables.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/test/DebugInfo/COFF/lines-bb-start.ll
    llvm/trunk/test/DebugInfo/COFF/local-variables.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=309628&r1=309627&r2=309628&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Mon Jul 31 14:03:08 2017
@@ -2157,6 +2157,8 @@ void CodeViewDebug::beginInstruction(con
   DebugLoc DL = MI->getDebugLoc();
   if (!DL && MI->getParent() != PrevInstBB) {
     for (const auto &NextMI : *MI->getParent()) {
+      if (NextMI.isDebugValue())
+        continue;
       DL = NextMI.getDebugLoc();
       if (DL)
         break;

Modified: llvm/trunk/test/DebugInfo/COFF/lines-bb-start.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/lines-bb-start.ll?rev=309628&r1=309627&r2=309628&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/lines-bb-start.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/lines-bb-start.ll Mon Jul 31 14:03:08 2017
@@ -7,6 +7,8 @@ target triple = "i386-pc-windows-msvc19.
 @str_const = internal unnamed_addr constant [4 x i8] c"str\00", align 1
 
 declare i32 @puts(i8*)
+declare void @use_i32(i32*)
+declare void @llvm.dbg.value(metadata, metadata, metadata) nounwind readnone
 
 ; We had a line info quality issue where the LEA for the string constant had no
 ; location info, so the .cv_loc directive appeared after it. Now we have logic
@@ -66,6 +68,33 @@ return:
 ; CHECK-NEXT:    movl    %[[reg]], (%esp)
 ; CHECK-NEXT:    calll   _puts
 
+define void @lea_dbg_value(i1 %cond) !dbg !30 {
+entry:
+  %value = alloca i32
+  store i32 42, i32* %value
+  br i1 %cond, label %if.then, label %if.end, !dbg !31
+
+if.then:                                          ; preds = %entry
+  br label %return, !dbg !32
+
+if.end:                                           ; preds = %entry
+  call void @llvm.dbg.value(metadata i32* %value, metadata !35, metadata !13), !dbg !34
+  call void @use_i32(i32* %value), !dbg !33
+  br label %return, !dbg !34
+
+return:                                           ; preds = %if.end, %if.then
+  ret void, !dbg !34
+}
+
+; CHECK-LABEL: _lea_dbg_value:
+; CHECK:         .cv_loc {{.*}} # t.c:4:5
+; CHECK:         jmp     LBB{{.*}}
+; CHECK: LBB2_{{.*}}:                                 # %if.end
+; CHECK-NEXT:    .cv_loc {{.*}} # t.c:5:3
+; CHECK:         leal 4(%esp), %[[reg:[^ ]*]]
+; CHECK:         movl    %[[reg]], (%esp)
+; CHECK:         calll   _use_i32
+
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!3, !4, !5, !6}
 !llvm.ident = !{!7}
@@ -78,11 +107,11 @@ return:
 !5 = !{i32 2, !"Debug Info Version", i32 3}
 !6 = !{i32 1, !"wchar_size", i32 2}
 !7 = !{!"clang version 5.0.0 "}
-!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!8 = distinct !DISubprogram(name: "lea_str_loc", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
 !9 = !DISubroutineType(types: !10)
 !10 = !{null, !11}
 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!13 = !DIExpression()
+!13 = !DIExpression(DW_OP_deref)
 !14 = !DILocation(line: 2, column: 12, scope: !8)
 !15 = !DILocation(line: 3, column: 7, scope: !16)
 !16 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
@@ -90,8 +119,14 @@ return:
 !18 = !DILocation(line: 4, column: 5, scope: !16)
 !19 = !DILocation(line: 5, column: 3, scope: !8)
 !20 = !DILocation(line: 6, column: 1, scope: !8)
-!21 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!21 = distinct !DISubprogram(name: "instr_no_loc", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
 !22 = !DILocation(line: 3, column: 7, scope: !21)
 !23 = !DILocation(line: 4, column: 5, scope: !21)
 !24 = !DILocation(line: 5, column: 3, scope: !21)
 !25 = !DILocation(line: 6, column: 1, scope: !21)
+!30 = distinct !DISubprogram(name: "lea_dbg_value", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!31 = !DILocation(line: 3, column: 7, scope: !30)
+!32 = !DILocation(line: 4, column: 5, scope: !30)
+!33 = !DILocation(line: 5, column: 3, scope: !30)
+!34 = !DILocation(line: 6, column: 1, scope: !30)
+!35 = !DILocalVariable(name: "v", scope: !30, file: !1, line: 3, type: !11)

Modified: llvm/trunk/test/DebugInfo/COFF/local-variables.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/local-variables.ll?rev=309628&r1=309627&r2=309628&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/local-variables.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/local-variables.ll Mon Jul 31 14:03:08 2017
@@ -60,8 +60,8 @@
 ; ASM:         leaq    36(%rsp), %rcx
 ; ASM: [[else_end:\.Ltmp.*]]:
 ; ASM: .LBB0_3:                                # %if.end
-; ASM:         callq   capture
 ; ASM:         .cv_loc 0 1 17 1                # t.cpp:17:1
+; ASM:         callq   capture
 ; ASM:         nop
 ; ASM:         addq    $56, %rsp
 ; ASM:         retq




More information about the llvm-commits mailing list