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