blob: 80bbdd164bebd2c09b39e90672cf365d99c76bce [file] [log] [blame]
Vedant Kumar195dfd12017-12-08 21:57:28 +00001; RUN: opt -debugify -S -o - < %s | FileCheck %s
2
3; RUN: opt -debugify -debugify -S -o - < %s 2>&1 | \
4; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
5
6; RUN: opt -debugify -check-debugify -S -o - < %s | \
7; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
8
9; RUN: opt -debugify -strip -check-debugify -S -o - < %s | \
10; RUN: FileCheck %s -check-prefix=CHECK-FAIL
11
Vedant Kumar92f7a622018-01-23 20:43:50 +000012; RUN: opt -enable-debugify -strip -S -o - < %s | \
13; RUN: FileCheck %s -check-prefix=CHECK-FAIL
14
Vedant Kumar195dfd12017-12-08 21:57:28 +000015; CHECK-LABEL: define void @foo
16define void @foo() {
17; CHECK: ret void, !dbg ![[RET1:.*]]
18 ret void
19}
20
21; CHECK-LABEL: define i32 @bar
22define i32 @bar() {
23; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
24 call void @foo()
25
26; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
27 %sum = add i32 0, 1
28
29; CHECK: ret i32 0, !dbg ![[RET2:.*]]
30 ret i32 0
31}
32
Vedant Kumar16276322018-02-13 18:15:27 +000033; CHECK-LABEL: define weak_odr zeroext i1 @baz
34define weak_odr zeroext i1 @baz() {
35; CHECK-NOT: !dbg
36 ret i1 false
37}
38
Vedant Kumar195dfd12017-12-08 21:57:28 +000039; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
40; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
41
42; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: {{.*}})
43; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
44; CHECK-DAG: distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: {{.*}}, line: 1, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: {{.*}}, variables: {{.*}})
45; CHECK-DAG: distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: {{.*}}, line: 2, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: {{.*}}, variables: {{.*}})
46
47; --- DILocations
48; CHECK-DAG: ![[RET1]] = !DILocation(line: 1, column: 1
49; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
50; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
51; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
52
53; --- DILocalVariables
54; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
55; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
56
57; --- Metadata counts
58; CHECK-DAG: ![[NUM_INSTS]] = !{i32 4}
59; CHECK-DAG: ![[NUM_VARS]] = !{i32 1}
60
61; --- Repeat case
62; CHECK-REPEAT: Debugify: Skipping module with debug info
63
64; --- Failure case
65; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- ret void
66; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- call void @foo()
67; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- {{.*}} add i32 0, 1
68; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- ret i32 0
69; CHECK-FAIL: WARNING: Missing line 1
70; CHECK-FAIL: WARNING: Missing line 2
71; CHECK-FAIL: WARNING: Missing line 3
72; CHECK-FAIL: WARNING: Missing line 4
73; CHECK-FAIL: ERROR: Missing variable 1
74; CHECK-FAIL: CheckDebugify: FAIL