xref: /llvm-project/llvm/test/DebugInfo/debugify.ll (revision 1c6b0f779f66494cb597884c1a52e377bde4bc54)
1; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
2; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
3
4; RUN: opt -passes=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
8
9; RUN: opt -passes=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"
15
16; RUN: opt -passes=debugify,strip,check-debugify -S -o - < %s 2>&1 | \
17; RUN:   FileCheck %s -check-prefix=CHECK-WARN
18
19; RUN: opt -enable-debugify -passes=strip -S -o - < %s 2>&1 | \
20; RUN:   FileCheck %s -check-prefix=CHECK-WARN
21
22; 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 -passes=debugify,mem2reg,check-debugify < %s | opt -O2 -o /dev/null
27
28;; Perform the same checks again for intrinsic debug info
29; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify -S -o - < %s | FileCheck %s
30; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify -S -o - < %s | FileCheck %s
31
32; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify,debugify -S -o - < %s 2>&1 | \
33; RUN:   FileCheck %s -check-prefix=CHECK-REPEAT
34; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify,debugify -S -o - < %s 2>&1 | \
35; RUN:   FileCheck %s -check-prefix=CHECK-REPEAT
36
37; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify,check-debugify -S -o - < %s | \
38; RUN:   FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
39; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify,check-debugify -S -o - < %s | \
40; RUN:   FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
41; RUN: opt --experimental-debuginfo-iterators=false -enable-debugify -passes=verify -S -o - < %s | \
42; RUN:   FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
43
44; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify,strip,check-debugify -S -o - < %s 2>&1 | \
45; RUN:   FileCheck %s -check-prefix=CHECK-WARN
46
47; RUN: opt --experimental-debuginfo-iterators=false -enable-debugify -passes=strip -S -o - < %s 2>&1 | \
48; RUN:   FileCheck %s -check-prefix=CHECK-WARN
49
50; RUN: opt --experimental-debuginfo-iterators=false -enable-debugify -S -o - < %s 2>&1 | FileCheck %s -check-prefix=PASS
51
52; RUN: opt --experimental-debuginfo-iterators=false -enable-debugify -O1 < %s | opt -O2 -o /dev/null
53; RUN: opt --experimental-debuginfo-iterators=false -passes=debugify,mem2reg,check-debugify < %s | opt -O2 -o /dev/null
54
55; CHECK-LABEL: define void @foo
56define void @foo() {
57; CHECK: ret void, !dbg ![[RET1:.*]]
58  ret void
59}
60
61; CHECK-LABEL: define i32 @bar
62define i32 @bar() {
63; CHECK: call void @foo(), !dbg ![[CALL1:.*]]
64  call void @foo()
65
66; CHECK: add i32 0, 1, !dbg ![[ADD1:.*]]
67  %sum = add i32 0, 1
68
69; CHECK: ret i32 0, !dbg ![[RET2:.*]]
70  ret i32 0
71}
72
73; CHECK-LABEL: define weak_odr zeroext i1 @baz
74define weak_odr zeroext i1 @baz() {
75; CHECK-NOT: !dbg
76  ret i1 false
77}
78
79; CHECK-LABEL: define i32 @boom
80define i32 @boom() {
81; CHECK: [[result:%.*]] = musttail call i32 @bar(), !dbg ![[musttail:.*]]
82  %retval = musttail call i32 @bar()
83; CHECK-NEXT: ret i32 [[result]], !dbg ![[musttailRes:.*]]
84  ret i32 %retval
85}
86
87; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
88; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
89; CHECK-DAG: "Debug Info Version"
90
91; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
92; CHECK-DAG: !DIFile(filename: "<stdin>", directory: "/")
93; CHECK-DAG: distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: {{.*}}, line: 1, type: {{.*}}, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: {{.*}}, retainedNodes: {{.*}})
94; CHECK-DAG: distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: {{.*}}, line: 2, type: {{.*}}, scopeLine: 2, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: {{.*}}, retainedNodes: {{.*}})
95
96; --- DILocations
97; CHECK-DAG: ![[RET1]] = !DILocation(line: 1, column: 1
98; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
99; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
100; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
101; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
102; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
103
104; --- DILocalVariables
105; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
106; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 1, type: ![[TY32]])
107; CHECK-DAG: !DILocalVariable(name: "2", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
108; CHECK-DAG: !DILocalVariable(name: "3", scope: {{.*}}, file: {{.*}}, line: 5, type: ![[TY32]])
109
110; --- Metadata counts
111; CHECK-DAG: ![[NUM_INSTS]] = !{i32 6}
112; CHECK-DAG: ![[NUM_VARS]] = !{i32 3}
113
114; --- Repeat case
115; CHECK-REPEAT: ModuleDebugify: Skipping module with debug info
116
117; --- Failure case
118; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function foo --   ret void
119; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function bar --   call void @foo()
120; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function bar --   {{.*}} add i32 0, 1
121; CHECK-WARN: WARNING: Instruction with empty DebugLoc in function bar --   ret i32 0
122; CHECK-WARN: WARNING: Missing line 1
123; CHECK-WARN: WARNING: Missing line 2
124; CHECK-WARN: WARNING: Missing line 3
125; CHECK-WARN: WARNING: Missing line 4
126; CHECK-WARN: WARNING: Missing variable 1
127; CHECK-WARN: CheckModuleDebugify: PASS
128
129; PASS: CheckModuleDebugify: PASS
130