blob: 16dd635858116b2a187b3f6441db1b5940fa2bc5 [file] [log] [blame]
Vedant Kumar2cac1082017-12-08 21:57:28 +00001; RUN: opt -debugify -S -o - < %s | FileCheck %s
Vedant Kumarb8c067b2018-02-15 21:14:36 +00002; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
Vedant Kumar2cac1082017-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 Kumarb8c067b2018-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 Kumar2cac1082017-12-08 21:57:28 +00008
9; RUN: opt -debugify -check-debugify -S -o - < %s | \
Vedant Kumarb12dd1f2018-05-15 00:29:27 +000010; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
Vedant Kumarb8c067b2018-02-15 21:14:36 +000011; RUN: opt -passes=debugify,check-debugify -S -o - < %s | \
Vedant Kumarb12dd1f2018-05-15 00:29:27 +000012; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
Vedant Kumarb8c067b2018-02-15 21:14:36 +000013; RUN: opt -enable-debugify -passes=verify -S -o - < %s | \
Vedant Kumarb12dd1f2018-05-15 00:29:27 +000014; RUN: FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
Vedant Kumar2cac1082017-12-08 21:57:28 +000015
Anastasis Grammenosac5db0d2018-05-17 18:19:58 +000016; RUN: opt -debugify -strip -check-debugify -S -o - < %s 2>&1 | \
Vedant Kumar2cac1082017-12-08 21:57:28 +000017; RUN: FileCheck %s -check-prefix=CHECK-FAIL
18
Anastasis Grammenosac5db0d2018-05-17 18:19:58 +000019; RUN: opt -enable-debugify -strip -S -o - < %s 2>&1 | \
Vedant Kumar48c582c2018-01-23 20:43:50 +000020; RUN: FileCheck %s -check-prefix=CHECK-FAIL
21
Anastasis Grammenosac5db0d2018-05-17 18:19:58 +000022; RUN: opt -enable-debugify -S -o - < %s 2>&1 | FileCheck %s -check-prefix=PASS
23
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
Vedant Kumarda3c20c2018-02-15 21:28:38 +000027
Vedant Kumar2cac1082017-12-08 21:57:28 +000028; CHECK-LABEL: define void @foo
29define void @foo() {
30; CHECK: ret void, !dbg ![[RET1:.*]]
31 ret void
32}
33
34; CHECK-LABEL: define i32 @bar
35define i32 @bar() {
36; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
37 call void @foo()
38
39; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
40 %sum = add i32 0, 1
41
42; CHECK: ret i32 0, !dbg ![[RET2:.*]]
43 ret i32 0
44}
45
Vedant Kumar877eaaa2018-02-13 18:15:27 +000046; CHECK-LABEL: define weak_odr zeroext i1 @baz
47define weak_odr zeroext i1 @baz() {
48; CHECK-NOT: !dbg
49 ret i1 false
50}
51
Vedant Kumar23738502018-06-03 22:50:22 +000052; CHECK-LABEL: define i32 @boom
53define 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:.*]]
57 ret i32 %retval
58}
59
Vedant Kumar2cac1082017-12-08 21:57:28 +000060; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
61; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
Vedant Kumar646a7362018-05-24 23:00:23 +000062; CHECK-DAG: "Debug Info Version"
Vedant Kumar2cac1082017-12-08 21:57:28 +000063
64; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: {{.*}})
65; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
Paul Robinsonccefd882018-11-28 21:14:32 +000066; 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: {{.*}})
Vedant Kumar2cac1082017-12-08 21:57:28 +000068
69; --- DILocations
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
Vedant Kumar23738502018-06-03 22:50:22 +000074; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
75; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
Vedant Kumar2cac1082017-12-08 21:57:28 +000076
77; --- DILocalVariables
78; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
79; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
80
81; --- Metadata counts
Vedant Kumar23738502018-06-03 22:50:22 +000082; CHECK-DAG: ![[NUM_INSTS]] = !{i32 6}
Vedant Kumar2cac1082017-12-08 21:57:28 +000083; CHECK-DAG: ![[NUM_VARS]] = !{i32 1}
84
85; --- Repeat case
Vedant Kumarb12dd1f2018-05-15 00:29:27 +000086; CHECK-REPEAT: ModuleDebugify: Skipping module with debug info
Vedant Kumar2cac1082017-12-08 21:57:28 +000087
88; --- Failure case
Vedant Kumarb12dd1f2018-05-15 00:29:27 +000089; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function foo -- ret void
90; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function bar -- call void @foo()
91; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function bar -- {{.*}} add i32 0, 1
92; CHECK-FAIL: ERROR: Instruction with empty DebugLoc in function bar -- ret i32 0
Vedant Kumar2cac1082017-12-08 21:57:28 +000093; CHECK-FAIL: WARNING: Missing line 1
94; CHECK-FAIL: WARNING: Missing line 2
95; CHECK-FAIL: WARNING: Missing line 3
96; CHECK-FAIL: WARNING: Missing line 4
Vedant Kumar92533692018-06-26 18:54:10 +000097; CHECK-FAIL: WARNING: Missing variable 1
Vedant Kumar951e6052018-05-24 23:00:22 +000098; CHECK-FAIL: CheckModuleDebugify: FAIL
Vedant Kumarda3c20c2018-02-15 21:28:38 +000099
Vedant Kumar951e6052018-05-24 23:00:22 +0000100; PASS: CheckModuleDebugify: PASS