1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2 ; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
3 ; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s --try-experimental-debuginfo-iterators | FileCheck %s
5 ; This test checks that debug info is recognized as able to be extracted along
6 ; with the other instructions, but is not included in the consolidated function.
8 define void @function1() !dbg !6 {
10 %a = alloca i32, align 4, !dbg !17
11 call void @llvm.dbg.value(metadata ptr %a, metadata !9, metadata !DIExpression()), !dbg !17
12 %b = alloca i32, align 4, !dbg !18
13 call void @llvm.dbg.value(metadata ptr %b, metadata !11, metadata !DIExpression()), !dbg !18
14 %c = alloca i32, align 4, !dbg !19
15 call void @llvm.dbg.value(metadata ptr %c, metadata !12, metadata !DIExpression()), !dbg !19
16 store i32 2, ptr %a, align 4, !dbg !20
17 store i32 3, ptr %b, align 4, !dbg !21
18 store i32 4, ptr %c, align 4, !dbg !22
19 %al = load i32, ptr %a, align 4, !dbg !23
20 call void @llvm.dbg.value(metadata i32 %al, metadata !13, metadata !DIExpression()), !dbg !23
21 %bl = load i32, ptr %b, align 4, !dbg !24
22 call void @llvm.dbg.value(metadata i32 %bl, metadata !15, metadata !DIExpression()), !dbg !24
23 %cl = load i32, ptr %c, align 4, !dbg !25
24 call void @llvm.dbg.value(metadata i32 %cl, metadata !16, metadata !DIExpression()), !dbg !25
28 define void @function2() !dbg !27 {
30 %a = alloca i32, align 4, !dbg !35
31 call void @llvm.dbg.value(metadata ptr %a, metadata !29, metadata !DIExpression()), !dbg !35
32 %b = alloca i32, align 4, !dbg !36
33 call void @llvm.dbg.value(metadata ptr %b, metadata !30, metadata !DIExpression()), !dbg !36
34 %c = alloca i32, align 4, !dbg !37
35 call void @llvm.dbg.value(metadata ptr %c, metadata !31, metadata !DIExpression()), !dbg !37
36 store i32 2, ptr %a, align 4, !dbg !38
37 store i32 3, ptr %b, align 4, !dbg !39
38 store i32 4, ptr %c, align 4, !dbg !40
39 %al = load i32, ptr %a, align 4, !dbg !41
40 call void @llvm.dbg.value(metadata i32 %al, metadata !32, metadata !DIExpression()), !dbg !41
41 %bl = load i32, ptr %b, align 4, !dbg !42
42 call void @llvm.dbg.value(metadata i32 %bl, metadata !33, metadata !DIExpression()), !dbg !42
43 %cl = load i32, ptr %c, align 4, !dbg !43
44 call void @llvm.dbg.value(metadata i32 %cl, metadata !34, metadata !DIExpression()), !dbg !43
49 ; Function Attrs: nounwind readnone speculatable willreturn
50 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
52 attributes #0 = { nounwind readnone speculatable willreturn }
55 !llvm.debugify = !{!3, !4}
56 !llvm.module.flags = !{!5}
58 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
59 !1 = !DIFile(filename: "legal-debug.ll", directory: "/")
63 !5 = !{i32 2, !"Debug Info Version", i32 3}
64 !6 = distinct !DISubprogram(name: "function1", linkageName: "function1", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
65 !7 = !DISubroutineType(types: !2)
66 !8 = !{!9, !11, !12, !13, !15, !16}
67 !9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
68 !10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
69 !11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 2, type: !10)
70 !12 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 3, type: !10)
71 !13 = !DILocalVariable(name: "4", scope: !6, file: !1, line: 7, type: !14)
72 !14 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
73 !15 = !DILocalVariable(name: "5", scope: !6, file: !1, line: 8, type: !14)
74 !16 = !DILocalVariable(name: "6", scope: !6, file: !1, line: 9, type: !14)
75 !17 = !DILocation(line: 1, column: 1, scope: !6)
76 !18 = !DILocation(line: 2, column: 1, scope: !6)
77 !19 = !DILocation(line: 3, column: 1, scope: !6)
78 !20 = !DILocation(line: 4, column: 1, scope: !6)
79 !21 = !DILocation(line: 5, column: 1, scope: !6)
80 !22 = !DILocation(line: 6, column: 1, scope: !6)
81 !23 = !DILocation(line: 7, column: 1, scope: !6)
82 !24 = !DILocation(line: 8, column: 1, scope: !6)
83 !25 = !DILocation(line: 9, column: 1, scope: !6)
84 !26 = !DILocation(line: 10, column: 1, scope: !6)
85 !27 = distinct !DISubprogram(name: "function2", linkageName: "function2", scope: null, file: !1, line: 11, type: !7, scopeLine: 11, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !28)
86 !28 = !{!29, !30, !31, !32, !33, !34}
87 !29 = !DILocalVariable(name: "7", scope: !27, file: !1, line: 11, type: !10)
88 !30 = !DILocalVariable(name: "8", scope: !27, file: !1, line: 12, type: !10)
89 !31 = !DILocalVariable(name: "9", scope: !27, file: !1, line: 13, type: !10)
90 !32 = !DILocalVariable(name: "10", scope: !27, file: !1, line: 17, type: !14)
91 !33 = !DILocalVariable(name: "11", scope: !27, file: !1, line: 18, type: !14)
92 !34 = !DILocalVariable(name: "12", scope: !27, file: !1, line: 19, type: !14)
93 !35 = !DILocation(line: 11, column: 1, scope: !27)
94 !36 = !DILocation(line: 12, column: 1, scope: !27)
95 !37 = !DILocation(line: 13, column: 1, scope: !27)
96 !38 = !DILocation(line: 14, column: 1, scope: !27)
97 !39 = !DILocation(line: 15, column: 1, scope: !27)
98 !40 = !DILocation(line: 16, column: 1, scope: !27)
99 !41 = !DILocation(line: 17, column: 1, scope: !27)
100 !42 = !DILocation(line: 18, column: 1, scope: !27)
101 !43 = !DILocation(line: 19, column: 1, scope: !27)
102 !44 = !DILocation(line: 20, column: 1, scope: !27)
103 ; CHECK-LABEL: @function1(
105 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4, !dbg [[DBG17:![0-9]+]]
106 ; CHECK-NEXT: #dbg_value(ptr [[A]], [[META9:![0-9]+]], !DIExpression(), [[DBG17]])
107 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4, !dbg [[DBG18:![0-9]+]]
108 ; CHECK-NEXT: #dbg_value(ptr [[B]], [[META11:![0-9]+]], !DIExpression(), [[DBG18]])
109 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4, !dbg [[DBG19:![0-9]+]]
110 ; CHECK-NEXT: #dbg_value(ptr [[C]], [[META12:![0-9]+]], !DIExpression(), [[DBG19]])
111 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]]), !dbg [[DBG20:![0-9]+]]
112 ; CHECK-NEXT: ret void, !dbg [[DBG21:![0-9]+]]
115 ; CHECK-LABEL: @function2(
117 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4, !dbg [[DBG30:![0-9]+]]
118 ; CHECK-NEXT: #dbg_value(ptr [[A]], [[META24:![0-9]+]], !DIExpression(), [[DBG30]])
119 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4, !dbg [[DBG31:![0-9]+]]
120 ; CHECK-NEXT: #dbg_value(ptr [[B]], [[META25:![0-9]+]], !DIExpression(), [[DBG31]])
121 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4, !dbg [[DBG32:![0-9]+]]
122 ; CHECK-NEXT: #dbg_value(ptr [[C]], [[META26:![0-9]+]], !DIExpression(), [[DBG32]])
123 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]]), !dbg [[DBG33:![0-9]+]]
124 ; CHECK-NEXT: ret void, !dbg [[DBG34:![0-9]+]]
127 ; CHECK-LABEL: define {{.+}} @outlined_ir_func_0(
128 ; CHECK-NEXT: newFuncRoot:
129 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
130 ; CHECK: entry_to_outline:
131 ; CHECK-NEXT: store i32 2, ptr [[TMP0:%.*]], align 4
132 ; CHECK-NEXT: store i32 3, ptr [[TMP1:%.*]], align 4
133 ; CHECK-NEXT: store i32 4, ptr [[TMP2:%.*]], align 4
134 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[TMP0]], align 4
135 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[TMP1]], align 4
136 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[TMP2]], align 4
137 ; CHECK-NEXT: br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]
138 ; CHECK: entry_after_outline.exitStub:
139 ; CHECK-NEXT: ret void