xref: /llvm-project/llvm/test/DebugInfo/X86/multiple-epilogue.ll (revision 6aa94c64a532237674433713a70ec2bda57b4fed)
1; RUN: llc -O1 %s -mtriple=x86_64 -filetype=obj -o %t && llvm-dwarfdump  -debug-line %t | FileCheck -v --check-prefix=LINE-TABLE %s
2
3; based on
4;
5;   1:   int bar();
6;   2:   int baz();
7;   3;
8;   4:   int foo(int a) {
9;   5:     if (a > 20)
10;   6:       return bar();
11;   7:     else
12;   8:       return baz();
13;   9:   }
14;
15; compiled with -g -S -emit-llvm -O1
16
17
18; LINE-TABLE: .debug_line contents:
19; LINE-TABLE: Line table prologue:
20; LINE-TABLE:     total_length: 0x00000069
21; LINE-TABLE:           format: DWARF32
22; LINE-TABLE:          version: 5
23; LINE-TABLE:     address_size: 8
24; LINE-TABLE:  seg_select_size: 0
25; LINE-TABLE:  prologue_length: 0x00000037
26
27; LINE-TABLE:      Address            Line   Column File   ISA Discriminator OpIndex Flags
28; LINE-TABLE-NEXT: ------------------ ------ ------ ------ --- ------------- ------- -------------
29; LINE-TABLE-NEXT: 0x0000000000000000      4      0      0   0             0       0  is_stmt
30; LINE-TABLE-NEXT: 0x0000000000000001      5      9      0   0             0       0  is_stmt prologue_end
31; LINE-TABLE-NEXT: 0x0000000000000004      5      7      0   0             0       0
32; LINE-TABLE-NEXT: 0x0000000000000006      6     12      0   0             0       0  is_stmt
33; LINE-TABLE-NEXT: 0x000000000000000b      9      1      0   0             0       0  is_stmt epilogue_begin
34; LINE-TABLE-NEXT: 0x000000000000000d      8     12      0   0             0       0  is_stmt
35; LINE-TABLE-NEXT: 0x0000000000000012      9      1      0   0             0       0  is_stmt epilogue_begin
36; LINE-TABLE-NEXT: 0x0000000000000014      9      1      0   0             0       0  is_stmt end_sequence
37
38
39
40
41; Function Attrs: mustprogress uwtable
42define dso_local noundef i32 @_Z3fooi(i32 noundef %a) local_unnamed_addr #0 !dbg !8 {
43entry:
44  call void @llvm.dbg.value(metadata i32 %a, metadata !13, metadata !DIExpression()), !dbg !14
45  %cmp = icmp sgt i32 %a, 20, !dbg !15
46  br i1 %cmp, label %if.then, label %if.else, !dbg !17
47
48if.then:                                          ; preds = %entry
49  %call = call noundef i32 @_Z3barv(), !dbg !18
50  br label %return, !dbg !19
51
52if.else:                                          ; preds = %entry
53  %call1 = call noundef i32 @_Z3bazv(), !dbg !20
54  br label %return, !dbg !21
55
56return:                                           ; preds = %if.else, %if.then
57  %retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ], !dbg !22
58  ret i32 %retval.0, !dbg !23
59}
60
61declare !dbg !24 dso_local noundef i32 @_Z3barv() local_unnamed_addr #1
62
63declare !dbg !28 dso_local noundef i32 @_Z3bazv() local_unnamed_addr #1
64
65; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
66declare void @llvm.dbg.value(metadata, metadata, metadata) #2
67
68!llvm.dbg.cu = !{!0}
69!llvm.module.flags = !{!2, !3, !4, !5, !6}
70!llvm.ident = !{!7}
71
72!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
73!1 = !DIFile(filename: "q.cpp", directory: "/", checksumkind: CSK_MD5, checksum: "6b5f6118d466ba2f6510ac0790b09bef")
74!2 = !{i32 7, !"Dwarf Version", i32 5}
75!3 = !{i32 2, !"Debug Info Version", i32 3}
76!4 = !{i32 1, !"wchar_size", i32 4}
77!5 = !{i32 7, !"uwtable", i32 2}
78!6 = !{i32 7, !"frame-pointer", i32 2}
79!7 = !{!"clang version 15.0.0"}
80!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
81!9 = !DISubroutineType(types: !10)
82!10 = !{!11, !11}
83!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
84!12 = !{!13}
85!13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 4, type: !11)
86!14 = !DILocation(line: 0, scope: !8)
87!15 = !DILocation(line: 5, column: 9, scope: !16)
88!16 = distinct !DILexicalBlock(scope: !8, file: !1, line: 5, column: 7)
89!17 = !DILocation(line: 5, column: 7, scope: !8)
90!18 = !DILocation(line: 6, column: 12, scope: !16)
91!19 = !DILocation(line: 6, column: 5, scope: !16)
92!20 = !DILocation(line: 8, column: 12, scope: !16)
93!21 = !DILocation(line: 8, column: 5, scope: !16)
94!22 = !DILocation(line: 0, scope: !16)
95!23 = !DILocation(line: 9, column: 1, scope: !8)
96!24 = !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 1, type: !25, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !27)
97!25 = !DISubroutineType(types: !26)
98!26 = !{!11}
99!27 = !{}
100!28 = !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 2, type: !25, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !27)
101