xref: /llvm-project/llvm/test/DebugInfo/COFF/pgo.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc < %s -filetype=obj | llvm-readobj --codeview - | FileCheck %s
2
3; CHECK: Compile3Sym {
4; CHECK:   Flags [ (0x40000)
5; CHECK:     PGO (0x40000)
6
7; CHECK: DisplayName: foo
8; CHECK: Kind: S_FRAMEPROC (0x1012)
9; CHECK:   ProfileGuidedOptimization (0x40000)
10; CHECK:   ValidProfileCounts (0x80000)
11
12; CHECK: DisplayName: foo2
13; CHECK: Kind: S_FRAMEPROC (0x1012)
14; CHECK:   ProfileGuidedOptimization (0x40000)
15; CHECK:   ValidProfileCounts (0x80000)
16
17; CHECK: DisplayName: bar
18; CHECK: Kind: S_FRAMEPROC (0x1012)
19; CHECK:   ProfileGuidedOptimization (0x40000)
20; CHECK:   ValidProfileCounts (0x80000)
21
22; CHECK: DisplayName: main
23; CHECK: Kind: S_FRAMEPROC (0x1012)
24; CHECK-NOT:   ProfileGuidedOptimization (0x40000)
25; CHECK-NOT:   ValidProfileCounts (0x80000)
26
27source_filename = "pgo.cpp"
28target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
29target triple = "x86_64-pc-windows-msvc19.28.29912"
30
31define dso_local i32 @"?foo@@YAHH@Z"(i32 %b) local_unnamed_addr #1 !dbg !43 !prof !49 {
32entry:
33  call void @llvm.dbg.value(metadata i32 %b, metadata !48, metadata !DIExpression()), !dbg !50
34  %mul = mul nsw i32 %b, 10, !dbg !51
35  ret i32 %mul, !dbg !51
36}
37
38define dso_local i32 @"?foo2@@YAHH@Z"(i32 %a) local_unnamed_addr #1 !dbg !52 !prof !55 {
39entry:
40  call void @llvm.dbg.value(metadata i32 %a, metadata !54, metadata !DIExpression()), !dbg !56
41  %mul = mul nsw i32 %a, 5, !dbg !57
42  ret i32 %mul, !dbg !57
43}
44
45define dso_local i32 @"?bar@@YAHH@Z"(i32 %num) local_unnamed_addr #1 !dbg !58 !prof !55 {
46entry:
47  call void @llvm.dbg.value(metadata i32 undef, metadata !60, metadata !DIExpression()), !dbg !61
48  %call = tail call i32 @"?foo@@YAHH@Z"(i32 1) #1, !dbg !62
49  %call1 = tail call i32 @"?foo2@@YAHH@Z"(i32 2) #1, !dbg !62
50  %mul = mul nsw i32 %call1, %call, !dbg !62
51  %call2 = tail call i32 @"?foo2@@YAHH@Z"(i32 3) #1, !dbg !62
52  %mul3 = mul nsw i32 %mul, %call2, !dbg !62
53  ret i32 %mul3, !dbg !62
54}
55
56define dso_local i32 @main(i32 %argc, ptr nocapture readnone %argv) local_unnamed_addr #1 !dbg !63 !annotation !72 {
57entry:
58  call void @llvm.dbg.value(metadata ptr %argv, metadata !70, metadata !DIExpression()), !dbg !73
59  call void @llvm.dbg.value(metadata i32 %argc, metadata !71, metadata !DIExpression()), !dbg !73
60  %cmp = icmp eq i32 %argc, 2, !dbg !74
61  br i1 %cmp, label %return, label %if.end, !dbg !74
62
63if.end:                                           ; preds = %entry
64  %cmp1 = icmp slt i32 %argc, 5, !dbg !75
65  br i1 %cmp1, label %if.then2, label %if.else, !dbg !75
66
67if.then2:                                         ; preds = %if.end
68  %call = tail call i32 @"?bar@@YAHH@Z"(i32 undef) #1, !dbg !76
69  br label %return, !dbg !76
70
71if.else:                                          ; preds = %if.end
72  %call3 = tail call i32 @"?foo@@YAHH@Z"(i32 %argc) #1, !dbg !79
73  br label %return, !dbg !79
74
75return:                                           ; preds = %entry, %if.else, %if.then2
76  %retval.0 = phi i32 [ %call, %if.then2 ], [ %call3, %if.else ], [ 0, %entry ], !dbg !73
77  ret i32 %retval.0, !dbg !81
78}
79
80declare void @llvm.dbg.value(metadata, metadata, metadata) #3
81
82attributes #1 = { optsize }
83
84!llvm.dbg.cu = !{!0}
85!llvm.module.flags = !{!5, !6, !7, !8, !9, !38}
86
87!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
88!1 = !DIFile(filename: "pgo.cpp", directory: "")
89!2 = !{}
90!5 = !{i32 2, !"CodeView", i32 1}
91!6 = !{i32 2, !"Debug Info Version", i32 3}
92!7 = !{i32 1, !"wchar_size", i32 2}
93!8 = !{i32 7, !"PIC Level", i32 2}
94!9 = !{i32 1, !"ProfileSummary", !10}
95!10 = !{!11, !12, !13, !14, !15, !16, !17, !18, !19, !20}
96!11 = !{!"ProfileFormat", !"InstrProf"}
97!12 = !{!"TotalCount", i64 2}
98!13 = !{!"MaxCount", i64 1}
99!14 = !{!"MaxInternalCount", i64 1}
100!15 = !{!"MaxFunctionCount", i64 1}
101!16 = !{!"NumCounts", i64 5}
102!17 = !{!"NumFunctions", i64 4}
103!18 = !{!"IsPartialProfile", i64 0}
104!19 = !{!"PartialProfileRatio", double 0.000000e+00}
105!20 = !{!"DetailedSummary", !21}
106!21 = !{!22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37}
107!22 = !{i32 10000, i64 0, i32 0}
108!23 = !{i32 100000, i64 0, i32 0}
109!24 = !{i32 200000, i64 0, i32 0}
110!25 = !{i32 300000, i64 0, i32 0}
111!26 = !{i32 400000, i64 0, i32 0}
112!27 = !{i32 500000, i64 1, i32 2}
113!28 = !{i32 600000, i64 1, i32 2}
114!29 = !{i32 700000, i64 1, i32 2}
115!30 = !{i32 800000, i64 1, i32 2}
116!31 = !{i32 900000, i64 1, i32 2}
117!32 = !{i32 950000, i64 1, i32 2}
118!33 = !{i32 990000, i64 1, i32 2}
119!34 = !{i32 999000, i64 1, i32 2}
120!35 = !{i32 999900, i64 1, i32 2}
121!36 = !{i32 999990, i64 1, i32 2}
122!37 = !{i32 999999, i64 1, i32 2}
123!38 = !{i32 5, !"CG Profile", !39}
124!39 = !{!40, !41}
125!40 = !{ptr @"?bar@@YAHH@Z", ptr @"?foo@@YAHH@Z", i64 0}
126!41 = !{ptr @"?bar@@YAHH@Z", ptr @"?foo2@@YAHH@Z", i64 0}
127!43 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHH@Z", scope: !1, file: !1, line: 2, type: !44, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !47)
128!44 = !DISubroutineType(types: !45)
129!45 = !{!46, !46}
130!46 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
131!47 = !{!48}
132!48 = !DILocalVariable(name: "b", arg: 1, scope: !43, file: !1, line: 2, type: !46)
133!49 = !{!"function_entry_count", i64 1}
134!50 = !DILocation(line: 0, scope: !43)
135!51 = !DILocation(line: 3, scope: !43)
136!52 = distinct !DISubprogram(name: "foo2", linkageName: "?foo2@@YAHH@Z", scope: !1, file: !1, line: 5, type: !44, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !53)
137!53 = !{!54}
138!54 = !DILocalVariable(name: "a", arg: 1, scope: !52, file: !1, line: 5, type: !46)
139!55 = !{!"function_entry_count", i64 0}
140!56 = !DILocation(line: 0, scope: !52)
141!57 = !DILocation(line: 6, scope: !52)
142!58 = distinct !DISubprogram(name: "bar", linkageName: "?bar@@YAHH@Z", scope: !1, file: !1, line: 8, type: !44, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !59)
143!59 = !{!60}
144!60 = !DILocalVariable(name: "num", arg: 1, scope: !58, file: !1, line: 8, type: !46)
145!61 = !DILocation(line: 0, scope: !58)
146!62 = !DILocation(line: 9, scope: !58)
147!63 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 11, type: !64, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !69)
148!64 = !DISubroutineType(types: !65)
149!65 = !{!46, !46, !66}
150!66 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !67, size: 64)
151!67 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !68, size: 64)
152!68 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
153!69 = !{!70, !71}
154!70 = !DILocalVariable(name: "argv", arg: 2, scope: !63, file: !1, line: 11, type: !66)
155!71 = !DILocalVariable(name: "argc", arg: 1, scope: !63, file: !1, line: 11, type: !46)
156!72 = !{!"instr_prof_hash_mismatch"}
157!73 = !DILocation(line: 0, scope: !63)
158!74 = !DILocation(line: 13, scope: !63)
159!75 = !DILocation(line: 16, scope: !63)
160!76 = !DILocation(line: 17, scope: !77)
161!77 = distinct !DILexicalBlock(scope: !78, file: !1, line: 16)
162!78 = distinct !DILexicalBlock(scope: !63, file: !1, line: 16)
163!79 = !DILocation(line: 19, scope: !80)
164!80 = distinct !DILexicalBlock(scope: !78, file: !1, line: 18)
165!81 = !DILocation(line: 21, scope: !63)
166