Skip to content

Commit 197e73f

Browse files
committed
[Debugify] Do not report line 0 locations as errors
The checking logic should not treat artificial locations as being somehow problematic. Producing these locations can be the desired behavior of some passes. See llvm.org/PR37961. llvm-svn: 335897
1 parent 90d7d5f commit 197e73f

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; RUN: opt -check-debugify < %s -S -o - 2>&1 | FileCheck %s
2+
3+
; CHECK: ERROR: Instruction with empty DebugLoc in function foo -- ret void
4+
define void @foo() !dbg !6 {
5+
ret void
6+
}
7+
8+
; CHECK-NOT: ERROR: Instruction with empty DebugLoc in function bar
9+
define i32 @bar() !dbg !9 {
10+
ret i32 0, !dbg !15
11+
}
12+
13+
declare void @llvm.dbg.value(metadata, metadata, metadata)
14+
15+
!llvm.dbg.cu = !{!0}
16+
!llvm.debugify = !{!3, !4}
17+
!llvm.module.flags = !{!5}
18+
19+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
20+
!1 = !DIFile(filename: "void", directory: "/")
21+
!2 = !{}
22+
!3 = !{i32 6}
23+
!4 = !{i32 1}
24+
!5 = !{i32 2, !"Debug Info Version", i32 3}
25+
!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !2)
26+
!7 = !DISubroutineType(types: !2)
27+
!9 = distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !10)
28+
!10 = !{!11}
29+
!11 = !DILocalVariable(name: "1", scope: !9, file: !1, line: 3, type: !12)
30+
!12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
31+
!15 = !DILocation(line: 0, column: 1, scope: !9)

llvm/tools/opt/Debugify.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,13 @@ bool checkDebugifyMetadata(Module &M,
237237
continue;
238238
}
239239

240-
dbg() << "ERROR: Instruction with empty DebugLoc in function ";
241-
dbg() << F.getName() << " --";
242-
I.print(dbg());
243-
dbg() << "\n";
244-
HasErrors = true;
240+
if (!DL) {
241+
dbg() << "ERROR: Instruction with empty DebugLoc in function ";
242+
dbg() << F.getName() << " --";
243+
I.print(dbg());
244+
dbg() << "\n";
245+
HasErrors = true;
246+
}
245247
}
246248

247249
// Find missing variables and mis-sized debug values.

0 commit comments

Comments
 (0)