xref: /llvm-project/llvm/test/Transforms/SampleProfile/uniqname.ll (revision 0271ae65a66367d802fa6866599d11e35f68450f)
1; Make sure profile matching is successful if both profile and IR contain
2; ".__uniq." suffix, for text format or extbinary format profile.
3; Make sure profile matching is successful if IR contains ".__uniq." suffix
4; but profile doesn't contain the suffix, for extbinary format profile.
5; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.suffix.prof -S | FileCheck %s
6; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.suffix.afdo -S | FileCheck %s
7; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.nosuffix.afdo -S | FileCheck %s
8
9target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
10target triple = "x86_64-unknown-linux-gnu"
11
12@cond = dso_local global i8 0, align 1
13@p = dso_local global ptr null, align 8
14
15; Check the callsite in inlined function with uniq suffix is annotated with
16; profile correctly.
17; CHECK-LABEL: @_Z3foov(
18; CHECK: call void @_Z10moo_calleev(), {{.*}} !prof ![[PROF_ID1:[0-9]+]]
19; CHECK: call void @_Z10noo_calleev(), {{.*}} !prof ![[PROF_ID2:[0-9]+]]
20; CHECK: ret void
21
22; Function Attrs: uwtable mustprogress
23define dso_local void @_Z3foov() #0 !dbg !7 {
24entry:
25  store ptr @_ZL3hoov.__uniq.334154460836426447066042049082945760258, ptr @p, align 8, !dbg !9, !tbaa !10
26  call void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271(), !dbg !14
27  call void @_ZL3moov.__uniq.334154460836426447066042049082945760258(), !dbg !15
28  ret void, !dbg !16
29}
30
31; Function Attrs: uwtable mustprogress
32define internal void @_ZL3hoov.__uniq.334154460836426447066042049082945760258() #1 !dbg !17 {
33entry:
34  call void @_Z10hoo_calleev(), !dbg !18
35  ret void, !dbg !19
36}
37
38; Check the indirect call target with uniq suffix is promoted and the inlined
39; body is annotated with profile.
40; CHECK: define internal void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271{{.*}} !prof ![[PROF_ID3:[0-9]+]]
41; CHECK: icmp eq ptr {{.*}} @_ZL3hoov.__uniq.334154460836426447066042049082945760258
42; CHECK: call void @_Z10hoo_calleev(), {{.*}} !prof ![[PROF_ID4:[0-9]+]]
43
44; Function Attrs: noinline uwtable mustprogress
45define internal void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271() #2 !dbg !20 {
46entry:
47  %0 = load ptr, ptr @p, align 8, !dbg !21, !tbaa !10
48  call void %0(), !dbg !22
49  ret void, !dbg !23
50}
51
52; Function Attrs: uwtable mustprogress
53define internal void @_ZL3moov.__uniq.334154460836426447066042049082945760258() #1 !dbg !24 {
54entry:
55  call void @_Z10moo_calleev(), !dbg !25
56  %0 = load volatile i8, ptr @cond, align 1, !dbg !26, !tbaa !27, !range !29
57  %tobool.not = icmp eq i8 %0, 0, !dbg !26
58  br i1 %tobool.not, label %if.end, label %if.then, !dbg !26
59
60if.then:                                          ; preds = %entry
61  call void @_ZL3noov.__uniq.334154460836426447066042049082945760258(), !dbg !30
62  br label %if.end, !dbg !30
63
64if.end:                                           ; preds = %if.then, %entry
65  ret void, !dbg !31
66}
67
68declare !dbg !32 dso_local void @_Z10hoo_calleev() #3
69
70declare !dbg !33 dso_local void @_Z10moo_calleev() #3
71
72; Function Attrs: uwtable mustprogress
73define internal void @_ZL3noov.__uniq.334154460836426447066042049082945760258() #1 !dbg !34 {
74entry:
75  %0 = load volatile i8, ptr @cond, align 1, !dbg !35, !tbaa !27, !range !29
76  %tobool.not = icmp eq i8 %0, 0, !dbg !35
77  br i1 %tobool.not, label %if.end, label %if.then, !dbg !35
78
79if.then:                                          ; preds = %entry
80  call void @_Z10noo_calleev(), !dbg !36
81  br label %if.end, !dbg !36
82
83if.end:                                           ; preds = %if.then, %entry
84  ret void, !dbg !37
85}
86
87declare !dbg !38 dso_local void @_Z10noo_calleev() #3
88
89attributes #0 = { uwtable mustprogress "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-sample-profile" "use-soft-float"="false" }
90attributes #1 = { uwtable mustprogress "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "sample-profile-suffix-elision-policy"="selected" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-sample-profile" "use-soft-float"="false" }
91attributes #2 = { noinline uwtable mustprogress "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "sample-profile-suffix-elision-policy"="selected" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-sample-profile" "use-soft-float"="false" }
92attributes #3 = { "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
93
94; CHECK: ![[PROF_ID1]] = !{!"branch_weights", i32 5931}
95; CHECK: ![[PROF_ID2]] = !{!"branch_weights", i32 2000}
96; CHECK: ![[PROF_ID3]] = !{!"function_entry_count", i64 5861}
97; CHECK: ![[PROF_ID4]] = !{!"branch_weights", i32 5000}
98
99!llvm.dbg.cu = !{!0}
100!llvm.module.flags = !{!3, !4, !5}
101!llvm.ident = !{!6}
102
103!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git e42c17446a2e5cbf9eebc752beafadad3fac7f63)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
104!1 = !DIFile(filename: "1.cc", directory: "/usr/local/google/home/wmi/workarea/llvm/build/splitprofile")
105!2 = !{}
106!3 = !{i32 7, !"Dwarf Version", i32 4}
107!4 = !{i32 2, !"Debug Info Version", i32 3}
108!5 = !{i32 1, !"wchar_size", i32 4}
109!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git e42c17446a2e5cbf9eebc752beafadad3fac7f63)"}
110!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 28, type: !8, scopeLine: 28, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
111!8 = !DISubroutineType(types: !2)
112!9 = !DILocation(line: 29, column: 5, scope: !7)
113!10 = !{!11, !11, i64 0}
114!11 = !{!"any pointer", !12, i64 0}
115!12 = !{!"omnipotent char", !13, i64 0}
116!13 = !{!"Simple C++ TBAA"}
117!14 = !DILocation(line: 30, column: 3, scope: !7)
118!15 = !DILocation(line: 31, column: 3, scope: !7)
119!16 = !DILocation(line: 32, column: 3, scope: !7)
120!17 = distinct !DISubprogram(name: "hoo", linkageName: "_ZL3hoov.__uniq.334154460836426447066042049082945760258", scope: !1, file: !1, line: 17, type: !8, scopeLine: 17, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
121!18 = !DILocation(line: 18, column: 3, scope: !17)
122!19 = !DILocation(line: 19, column: 1, scope: !17)
123!20 = distinct !DISubprogram(name: "goo", linkageName: "_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271", scope: !1, file: !1, line: 24, type: !8, scopeLine: 24, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
124!21 = !DILocation(line: 25, column: 5, scope: !20)
125!22 = !DILocation(line: 25, column: 3, scope: !20)
126!23 = !DILocation(line: 26, column: 1, scope: !20)
127!24 = distinct !DISubprogram(name: "moo", linkageName: "_ZL3moov.__uniq.334154460836426447066042049082945760258", scope: !1, file: !1, line: 11, type: !8, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
128!25 = !DILocation(line: 12, column: 3, scope: !24)
129!26 = !DILocation(line: 13, column: 7, scope: !24)
130!27 = !{!28, !28, i64 0}
131!28 = !{!"bool", !12, i64 0}
132!29 = !{i8 0, i8 2}
133!30 = !DILocation(line: 14, column: 5, scope: !24)
134!31 = !DILocation(line: 15, column: 1, scope: !24)
135!32 = !DISubprogram(name: "hoo_callee", linkageName: "_Z10hoo_calleev", scope: !1, file: !1, line: 3, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
136!33 = !DISubprogram(name: "moo_callee", linkageName: "_Z10moo_calleev", scope: !1, file: !1, line: 2, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
137!34 = distinct !DISubprogram(name: "noo", linkageName: "_ZL3noov.__uniq.334154460836426447066042049082945760258", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
138!35 = !DILocation(line: 7, column: 7, scope: !34)
139!36 = !DILocation(line: 8, column: 5, scope: !34)
140!37 = !DILocation(line: 9, column: 1, scope: !34)
141!38 = !DISubprogram(name: "noo_callee", linkageName: "_Z10noo_calleev", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
142