blob: 9747c88def87f1b5411daaa580c1627dad67bc51 [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 Kumar17d8bba2018-02-15 21:28:38 +000022; RUN: opt -enable-debugify -S -o - < %s | FileCheck %s -check-prefix=PASS
23
Vedant Kumar195dfd12017-12-08 21:57:28 +000024; CHECK-LABEL: define void @foo
25define void @foo() {
26; CHECK: ret void, !dbg ![[RET1:.*]]
27 ret void
28}
29
30; CHECK-LABEL: define i32 @bar
31define i32 @bar() {
32; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
33 call void @foo()
34
35; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
36 %sum = add i32 0, 1
37
38; CHECK: ret i32 0, !dbg ![[RET2:.*]]
39 ret i32 0
40}
41
Vedant Kumar16276322018-02-13 18:15:27 +000042; CHECK-LABEL: define weak_odr zeroext i1 @baz
43define weak_odr zeroext i1 @baz() {
44; CHECK-NOT: !dbg
45 ret i1 false
46}
47
Vedant Kumar195dfd12017-12-08 21:57:28 +000048; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
49; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
50
51; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: {{.*}})
52; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
53; CHECK-DAG: distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: {{.*}}, line: 1, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: {{.*}}, variables: {{.*}})
54; CHECK-DAG: distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: {{.*}}, line: 2, type: {{.*}}, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: {{.*}}, variables: {{.*}})
55
56; --- DILocations
57; CHECK-DAG: ![[RET1]] = !DILocation(line: 1, column: 1
58; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
59; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
60; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
61
62; --- DILocalVariables
63; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
64; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
65
66; --- Metadata counts
67; CHECK-DAG: ![[NUM_INSTS]] = !{i32 4}
68; CHECK-DAG: ![[NUM_VARS]] = !{i32 1}
69
70; --- Repeat case
71; CHECK-REPEAT: Debugify: Skipping module with debug info
72
73; --- Failure case
74; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- ret void
75; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- call void @foo()
76; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- {{.*}} add i32 0, 1
77; CHECK-FAIL: ERROR: Instruction with empty DebugLoc -- ret i32 0
78; CHECK-FAIL: WARNING: Missing line 1
79; CHECK-FAIL: WARNING: Missing line 2
80; CHECK-FAIL: WARNING: Missing line 3
81; CHECK-FAIL: WARNING: Missing line 4
82; CHECK-FAIL: ERROR: Missing variable 1
83; CHECK-FAIL: CheckDebugify: FAIL
Vedant Kumar17d8bba2018-02-15 21:28:38 +000084
85; PASS: CheckDebugify: PASS