xref: /llvm-project/llvm/test/DebugInfo/AArch64/ir-outliner.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2; RUN: opt -passes=verify,iroutliner -ir-outlining-no-cost < %s | \
3; RUN: llc -filetype=obj -mtriple=aarch64-- | llvm-dwarfdump - | FileCheck %s
4
5; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck -check-prefix=IRDEBUG %s
6
7; Ensure that the IR Outliner produces valid DWARF debug information when
8; creating outlined functions.
9
10; CHECK: DW_TAG_compile_unit
11; CHECK-DAG: DW_AT_name ("outline_debug1")
12
13; Check the high address of bar. This is one past the end of bar. It should be
14; the beginning of the outlined function.
15; CHECK:      DW_AT_high_pc ([[ONE_PAST_BAR:0x[a-f0-9]+]])
16; CHECK-NEXT: DW_AT_frame_base  (DW_OP_reg31 WSP)
17; CHECK-NEXT: DW_AT_linkage_name  ("outline_debug2")
18; CHECK-NEXT: DW_AT_name  ("outline_debug2")
19
20; Check the outlined function's DWARF.
21; CHECK-DAG:  DW_TAG_subprogram
22; CHECK-NEXT: DW_AT_low_pc  ([[ONE_PAST_BAR]])
23; CHECK-NEXT: DW_AT_high_pc (0x{{[0-9a-f]+}})
24; CHECK-NEXT: DW_AT_frame_base  (DW_OP_reg31 WSP)
25; CHECK-NEXT: DW_AT_linkage_name ("[[NAME:outlined_ir_func_[0-9]+]]")
26; CHECK-NEXT: DW_AT_name  ("[[NAME]]")
27; CHECK-NEXT: DW_AT_artificial  (true)
28; CHECK-NEXT: DW_AT_external  (true)
29
30define void @outline_debug1() !dbg !6 {
31entry:
32  %a = alloca i32, align 4, !dbg !17
33  call void @llvm.dbg.value(metadata ptr %a, metadata !9, metadata !DIExpression()), !dbg !17
34  %b = alloca i32, align 4, !dbg !18
35  call void @llvm.dbg.value(metadata ptr %b, metadata !11, metadata !DIExpression()), !dbg !18
36  %c = alloca i32, align 4, !dbg !19
37  call void @llvm.dbg.value(metadata ptr %c, metadata !12, metadata !DIExpression()), !dbg !19
38  store i32 2, ptr %a, align 4, !dbg !20
39  store i32 3, ptr %b, align 4, !dbg !21
40  store i32 4, ptr %c, align 4, !dbg !22
41  %al = load i32, ptr %a, align 4, !dbg !23
42  call void @llvm.dbg.value(metadata i32 %al, metadata !13, metadata !DIExpression()), !dbg !23
43  %bl = load i32, ptr %b, align 4, !dbg !24
44  call void @llvm.dbg.value(metadata i32 %bl, metadata !15, metadata !DIExpression()), !dbg !24
45  %cl = load i32, ptr %c, align 4, !dbg !25
46  call void @llvm.dbg.value(metadata i32 %cl, metadata !16, metadata !DIExpression()), !dbg !25
47  ret void, !dbg !26
48}
49
50define void @outline_debug2() !dbg !27 {
51entry:
52  %a = alloca i32, align 4, !dbg !35
53  call void @llvm.dbg.value(metadata ptr %a, metadata !29, metadata !DIExpression()), !dbg !35
54  %b = alloca i32, align 4, !dbg !36
55  call void @llvm.dbg.value(metadata ptr %b, metadata !30, metadata !DIExpression()), !dbg !36
56  %c = alloca i32, align 4, !dbg !37
57  call void @llvm.dbg.value(metadata ptr %c, metadata !31, metadata !DIExpression()), !dbg !37
58  store i32 2, ptr %a, align 4, !dbg !38
59  store i32 3, ptr %b, align 4, !dbg !39
60  store i32 4, ptr %c, align 4, !dbg !40
61  %al = load i32, ptr %a, align 4, !dbg !41
62  call void @llvm.dbg.value(metadata i32 %al, metadata !32, metadata !DIExpression()), !dbg !41
63  %bl = load i32, ptr %b, align 4, !dbg !42
64  call void @llvm.dbg.value(metadata i32 %bl, metadata !33, metadata !DIExpression()), !dbg !42
65  %cl = load i32, ptr %c, align 4, !dbg !43
66  call void @llvm.dbg.value(metadata i32 %cl, metadata !34, metadata !DIExpression()), !dbg !43
67  ret void, !dbg !44
68}
69
70; Function Attrs: nounwind readnone speculatable willreturn
71declare void @llvm.dbg.value(metadata, metadata, metadata) #0
72
73attributes #0 = { nounwind readnone speculatable willreturn }
74
75!llvm.dbg.cu = !{!0}
76!llvm.debugify = !{!3, !4}
77!llvm.module.flags = !{!5}
78
79!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
80!1 = !DIFile(filename: "llvm/test/DebugInfo/ir-outliner.ll", directory: "/")
81!2 = !{}
82!3 = !{i32 20}
83!4 = !{i32 12}
84!5 = !{i32 2, !"Debug Info Version", i32 3}
85!6 = distinct !DISubprogram(name: "outline_debug1", linkageName: "outline_debug1", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
86!7 = !DISubroutineType(types: !2)
87!8 = !{!9, !11, !12, !13, !15, !16}
88!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
89!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
90!11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 2, type: !10)
91!12 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 3, type: !10)
92!13 = !DILocalVariable(name: "4", scope: !6, file: !1, line: 7, type: !14)
93!14 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
94!15 = !DILocalVariable(name: "5", scope: !6, file: !1, line: 8, type: !14)
95!16 = !DILocalVariable(name: "6", scope: !6, file: !1, line: 9, type: !14)
96!17 = !DILocation(line: 1, column: 1, scope: !6)
97!18 = !DILocation(line: 2, column: 1, scope: !6)
98!19 = !DILocation(line: 3, column: 1, scope: !6)
99!20 = !DILocation(line: 4, column: 1, scope: !6)
100!21 = !DILocation(line: 5, column: 1, scope: !6)
101!22 = !DILocation(line: 6, column: 1, scope: !6)
102!23 = !DILocation(line: 7, column: 1, scope: !6)
103!24 = !DILocation(line: 8, column: 1, scope: !6)
104!25 = !DILocation(line: 9, column: 1, scope: !6)
105!26 = !DILocation(line: 10, column: 1, scope: !6)
106!27 = distinct !DISubprogram(name: "outline_debug2", linkageName: "outline_debug2", scope: null, file: !1, line: 11, type: !7, scopeLine: 11, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !28)
107!28 = !{!29, !30, !31, !32, !33, !34}
108!29 = !DILocalVariable(name: "7", scope: !27, file: !1, line: 11, type: !10)
109!30 = !DILocalVariable(name: "8", scope: !27, file: !1, line: 12, type: !10)
110!31 = !DILocalVariable(name: "9", scope: !27, file: !1, line: 13, type: !10)
111!32 = !DILocalVariable(name: "10", scope: !27, file: !1, line: 17, type: !14)
112!33 = !DILocalVariable(name: "11", scope: !27, file: !1, line: 18, type: !14)
113!34 = !DILocalVariable(name: "12", scope: !27, file: !1, line: 19, type: !14)
114!35 = !DILocation(line: 11, column: 1, scope: !27)
115!36 = !DILocation(line: 12, column: 1, scope: !27)
116!37 = !DILocation(line: 13, column: 1, scope: !27)
117!38 = !DILocation(line: 14, column: 1, scope: !27)
118!39 = !DILocation(line: 15, column: 1, scope: !27)
119!40 = !DILocation(line: 16, column: 1, scope: !27)
120!41 = !DILocation(line: 17, column: 1, scope: !27)
121!42 = !DILocation(line: 18, column: 1, scope: !27)
122!43 = !DILocation(line: 19, column: 1, scope: !27)
123!44 = !DILocation(line: 20, column: 1, scope: !27)
124
125; IRDEBUG-LABEL: @outline_debug1(
126; IRDEBUG-NEXT:  entry:
127; IRDEBUG-NEXT:    [[A:%.*]] = alloca i32, align 4, !dbg [[DBG17:![0-9]+]]
128; IRDEBUG-NEXT:      #dbg_value(ptr [[A]], [[META9:![0-9]+]], !DIExpression(), [[DBG17]])
129; IRDEBUG-NEXT:    [[B:%.*]] = alloca i32, align 4, !dbg [[DBG18:![0-9]+]]
130; IRDEBUG-NEXT:      #dbg_value(ptr [[B]], [[META11:![0-9]+]], !DIExpression(), [[DBG18]])
131; IRDEBUG-NEXT:    [[C:%.*]] = alloca i32, align 4, !dbg [[DBG19:![0-9]+]]
132; IRDEBUG-NEXT:      #dbg_value(ptr [[C]], [[META12:![0-9]+]], !DIExpression(), [[DBG19]])
133; IRDEBUG-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]]), !dbg [[DBG20:![0-9]+]]
134; IRDEBUG-NEXT:    ret void, !dbg [[DBG21:![0-9]+]]
135;
136;
137; IRDEBUG-LABEL: @outline_debug2(
138; IRDEBUG-NEXT:  entry:
139; IRDEBUG-NEXT:    [[A:%.*]] = alloca i32, align 4, !dbg [[DBG30:![0-9]+]]
140; IRDEBUG-NEXT:      #dbg_value(ptr [[A]], [[META24:![0-9]+]], !DIExpression(), [[DBG30]])
141; IRDEBUG-NEXT:    [[B:%.*]] = alloca i32, align 4, !dbg [[DBG31:![0-9]+]]
142; IRDEBUG-NEXT:      #dbg_value(ptr [[B]], [[META25:![0-9]+]], !DIExpression(), [[DBG31]])
143; IRDEBUG-NEXT:    [[C:%.*]] = alloca i32, align 4, !dbg [[DBG32:![0-9]+]]
144; IRDEBUG-NEXT:      #dbg_value(ptr [[C]], [[META26:![0-9]+]], !DIExpression(), [[DBG32]])
145; IRDEBUG-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]]), !dbg [[DBG33:![0-9]+]]
146; IRDEBUG-NEXT:    ret void, !dbg [[DBG34:![0-9]+]]
147;
148;
149; IRDEBUG-LABEL: define {{.+}} @outlined_ir_func_0(
150; IRDEBUG-NEXT:  newFuncRoot:
151; IRDEBUG-NEXT:    br label [[ENTRY_TO_OUTLINE:%.*]]
152; IRDEBUG:       entry_to_outline:
153; IRDEBUG-NEXT:    store i32 2, ptr [[TMP0:%.*]], align 4
154; IRDEBUG-NEXT:    store i32 3, ptr [[TMP1:%.*]], align 4
155; IRDEBUG-NEXT:    store i32 4, ptr [[TMP2:%.*]], align 4
156; IRDEBUG-NEXT:    [[AL:%.*]] = load i32, ptr [[TMP0]], align 4
157; IRDEBUG-NEXT:    [[BL:%.*]] = load i32, ptr [[TMP1]], align 4
158; IRDEBUG-NEXT:    [[CL:%.*]] = load i32, ptr [[TMP2]], align 4
159; IRDEBUG-NEXT:    br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]
160; IRDEBUG:       entry_after_outline.exitStub:
161; IRDEBUG-NEXT:    ret void
162;
163