1 ; RUN: opt -debugify -S -o - < %s | FileCheck %s
2 ; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
4 ; RUN: opt -debugify -debugify -S -o - < %s 2>&1 | \
5 ; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
6 ; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
7 ; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
9 ; RUN: opt -debugify -check-debugify -S -o - < %s | \
10 ; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
11 ; RUN: opt -passes=debugify,check-debugify -S -o - < %s | \
12 ; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
13 ; RUN: opt -enable-debugify -passes=verify -S -o - < %s | \
14 ; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
16 ; RUN: opt -debugify -strip -check-debugify -S -o - < %s 2>&1 | \
17 ; RUN: FileCheck %s -check-prefix=CHECK-WARN
19 ; RUN: opt -enable-debugify -strip -S -o - < %s 2>&1 | \
20 ; RUN: FileCheck %s -check-prefix=CHECK-WARN
22 ; RUN: opt -enable-debugify -S -o - < %s 2>&1 | FileCheck %s -check-prefix=PASS
24 ; Verify that debugify can be safely used with piping
25 ; RUN: opt -enable-debugify -O1 < %s | opt -O2 -o /dev/null
26 ; RUN: opt -debugify -mem2reg -check-debugify < %s | opt -O2 -o /dev/null
28 ; CHECK-LABEL: define void @foo
30 ; CHECK: ret void, !dbg ![[RET1:.*]]
34 ; CHECK-LABEL: define i32 @bar
36 ; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
39 ; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
42 ; CHECK: ret i32 0, !dbg ![[RET2:.*]]
46 ; CHECK-LABEL: define weak_odr zeroext i1 @baz
47 define weak_odr zeroext i1 @baz() {
52 ; CHECK-LABEL: define i32 @boom
54 ; CHECK: [[result:%.*]] = musttail call i32 @bar(), !dbg ![[musttail:.*]]
55 %retval = musttail call i32 @bar()
56 ; CHECK-NEXT: ret i32 [[result]], !dbg ![[musttailRes:.*]]
60 ; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
61 ; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
62 ; CHECK-DAG: "Debug Info Version"
64 ; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
65 ; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
66 ; CHECK-DAG: distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: {{.*}}, line: 1, type: {{.*}}, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: {{.*}}, retainedNodes: {{.*}})
67 ; CHECK-DAG: distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: {{.*}}, line: 2, type: {{.*}}, scopeLine: 2, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: {{.*}}, retainedNodes: {{.*}})
70 ; CHECK-DAG: ![[RET1]] = !DILocation(line: 1, column: 1
71 ; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
72 ; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
73 ; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
74 ; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
75 ; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
77 ; --- DILocalVariables
78 ; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
79 ; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 1, type: ![[TY32]])
80 ; CHECK-DAG: !DILocalVariable(name: "2", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
81 ; CHECK-DAG: !DILocalVariable(name: "3", scope: {{.*}}, file: {{.*}}, line: 5, type: ![[TY32]])
84 ; CHECK-DAG: ![[NUM_INSTS]] = !{i32 6}
85 ; CHECK-DAG: ![[NUM_VARS]] = !{i32 3}
88 ; CHECK-REPEAT: ModuleDebugify: Skipping module with debug info
91 ; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function foo -- ret void
92 ; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function bar -- call void @foo()
93 ; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function bar -- {{.*}} add i32 0, 1
94 ; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function bar -- ret i32 0
95 ; CHECK-WARN: WARNING: Missing line 1
96 ; CHECK-WARN: WARNING: Missing line 2
97 ; CHECK-WARN: WARNING: Missing line 3
98 ; CHECK-WARN: WARNING: Missing line 4
99 ; CHECK-WARN: WARNING: Missing variable 1
100 ; CHECK-WARN: CheckModuleDebugify: PASS
102 ; PASS: CheckModuleDebugify: PASS