1ee35784aSWei Mi; Make sure profile matching is successful if both profile and IR contain 2ee35784aSWei Mi; ".__uniq." suffix, for text format or extbinary format profile. 3ee35784aSWei Mi; Make sure profile matching is successful if IR contains ".__uniq." suffix 4ee35784aSWei Mi; but profile doesn't contain the suffix, for extbinary format profile. 5ee35784aSWei Mi; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.suffix.prof -S | FileCheck %s 6ee35784aSWei Mi; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.suffix.afdo -S | FileCheck %s 7ee35784aSWei Mi; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.nosuffix.afdo -S | FileCheck %s 8ee35784aSWei Mi 9ee35784aSWei Mitarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 10ee35784aSWei Mitarget triple = "x86_64-unknown-linux-gnu" 11ee35784aSWei Mi 12ee35784aSWei Mi@cond = dso_local global i8 0, align 1 13*0271ae65SFangrui Song@p = dso_local global ptr null, align 8 14ee35784aSWei Mi 15ee35784aSWei Mi; Check the callsite in inlined function with uniq suffix is annotated with 16ee35784aSWei Mi; profile correctly. 17ee35784aSWei Mi; CHECK-LABEL: @_Z3foov( 18ee35784aSWei Mi; CHECK: call void @_Z10moo_calleev(), {{.*}} !prof ![[PROF_ID1:[0-9]+]] 19ee35784aSWei Mi; CHECK: call void @_Z10noo_calleev(), {{.*}} !prof ![[PROF_ID2:[0-9]+]] 20ee35784aSWei Mi; CHECK: ret void 21ee35784aSWei Mi 22ee35784aSWei Mi; Function Attrs: uwtable mustprogress 23ee35784aSWei Midefine dso_local void @_Z3foov() #0 !dbg !7 { 24ee35784aSWei Mientry: 25*0271ae65SFangrui Song store ptr @_ZL3hoov.__uniq.334154460836426447066042049082945760258, ptr @p, align 8, !dbg !9, !tbaa !10 26ee35784aSWei Mi call void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271(), !dbg !14 27ee35784aSWei Mi call void @_ZL3moov.__uniq.334154460836426447066042049082945760258(), !dbg !15 28ee35784aSWei Mi ret void, !dbg !16 29ee35784aSWei Mi} 30ee35784aSWei Mi 31ee35784aSWei Mi; Function Attrs: uwtable mustprogress 32ee35784aSWei Midefine internal void @_ZL3hoov.__uniq.334154460836426447066042049082945760258() #1 !dbg !17 { 33ee35784aSWei Mientry: 34ee35784aSWei Mi call void @_Z10hoo_calleev(), !dbg !18 35ee35784aSWei Mi ret void, !dbg !19 36ee35784aSWei Mi} 37ee35784aSWei Mi 38ee35784aSWei Mi; Check the indirect call target with uniq suffix is promoted and the inlined 39ee35784aSWei Mi; body is annotated with profile. 40ee35784aSWei Mi; CHECK: define internal void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271{{.*}} !prof ![[PROF_ID3:[0-9]+]] 41*0271ae65SFangrui Song; CHECK: icmp eq ptr {{.*}} @_ZL3hoov.__uniq.334154460836426447066042049082945760258 42ee35784aSWei Mi; CHECK: call void @_Z10hoo_calleev(), {{.*}} !prof ![[PROF_ID4:[0-9]+]] 43ee35784aSWei Mi 44ee35784aSWei Mi; Function Attrs: noinline uwtable mustprogress 45ee35784aSWei Midefine internal void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271() #2 !dbg !20 { 46ee35784aSWei Mientry: 47*0271ae65SFangrui Song %0 = load ptr, ptr @p, align 8, !dbg !21, !tbaa !10 48ee35784aSWei Mi call void %0(), !dbg !22 49ee35784aSWei Mi ret void, !dbg !23 50ee35784aSWei Mi} 51ee35784aSWei Mi 52ee35784aSWei Mi; Function Attrs: uwtable mustprogress 53ee35784aSWei Midefine internal void @_ZL3moov.__uniq.334154460836426447066042049082945760258() #1 !dbg !24 { 54ee35784aSWei Mientry: 55ee35784aSWei Mi call void @_Z10moo_calleev(), !dbg !25 56*0271ae65SFangrui Song %0 = load volatile i8, ptr @cond, align 1, !dbg !26, !tbaa !27, !range !29 57ee35784aSWei Mi %tobool.not = icmp eq i8 %0, 0, !dbg !26 58ee35784aSWei Mi br i1 %tobool.not, label %if.end, label %if.then, !dbg !26 59ee35784aSWei Mi 60ee35784aSWei Miif.then: ; preds = %entry 61ee35784aSWei Mi call void @_ZL3noov.__uniq.334154460836426447066042049082945760258(), !dbg !30 62ee35784aSWei Mi br label %if.end, !dbg !30 63ee35784aSWei Mi 64ee35784aSWei Miif.end: ; preds = %if.then, %entry 65ee35784aSWei Mi ret void, !dbg !31 66ee35784aSWei Mi} 67ee35784aSWei Mi 68ee35784aSWei Mideclare !dbg !32 dso_local void @_Z10hoo_calleev() #3 69ee35784aSWei Mi 70ee35784aSWei Mideclare !dbg !33 dso_local void @_Z10moo_calleev() #3 71ee35784aSWei Mi 72ee35784aSWei Mi; Function Attrs: uwtable mustprogress 73ee35784aSWei Midefine internal void @_ZL3noov.__uniq.334154460836426447066042049082945760258() #1 !dbg !34 { 74ee35784aSWei Mientry: 75*0271ae65SFangrui Song %0 = load volatile i8, ptr @cond, align 1, !dbg !35, !tbaa !27, !range !29 76ee35784aSWei Mi %tobool.not = icmp eq i8 %0, 0, !dbg !35 77ee35784aSWei Mi br i1 %tobool.not, label %if.end, label %if.then, !dbg !35 78ee35784aSWei Mi 79ee35784aSWei Miif.then: ; preds = %entry 80ee35784aSWei Mi call void @_Z10noo_calleev(), !dbg !36 81ee35784aSWei Mi br label %if.end, !dbg !36 82ee35784aSWei Mi 83ee35784aSWei Miif.end: ; preds = %if.then, %entry 84ee35784aSWei Mi ret void, !dbg !37 85ee35784aSWei Mi} 86ee35784aSWei Mi 87ee35784aSWei Mideclare !dbg !38 dso_local void @_Z10noo_calleev() #3 88ee35784aSWei Mi 894ab3041aSserge-sans-pailleattributes #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" } 904ab3041aSserge-sans-pailleattributes #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" } 914ab3041aSserge-sans-pailleattributes #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" } 924ab3041aSserge-sans-pailleattributes #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" } 93ee35784aSWei Mi 94ee35784aSWei Mi; CHECK: ![[PROF_ID1]] = !{!"branch_weights", i32 5931} 95ee35784aSWei Mi; CHECK: ![[PROF_ID2]] = !{!"branch_weights", i32 2000} 96ee35784aSWei Mi; CHECK: ![[PROF_ID3]] = !{!"function_entry_count", i64 5861} 97ee35784aSWei Mi; CHECK: ![[PROF_ID4]] = !{!"branch_weights", i32 5000} 98ee35784aSWei Mi 99ee35784aSWei Mi!llvm.dbg.cu = !{!0} 100ee35784aSWei Mi!llvm.module.flags = !{!3, !4, !5} 101ee35784aSWei Mi!llvm.ident = !{!6} 102ee35784aSWei Mi 103ee35784aSWei Mi!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) 104ee35784aSWei Mi!1 = !DIFile(filename: "1.cc", directory: "/usr/local/google/home/wmi/workarea/llvm/build/splitprofile") 105ee35784aSWei Mi!2 = !{} 106ee35784aSWei Mi!3 = !{i32 7, !"Dwarf Version", i32 4} 107ee35784aSWei Mi!4 = !{i32 2, !"Debug Info Version", i32 3} 108ee35784aSWei Mi!5 = !{i32 1, !"wchar_size", i32 4} 109ee35784aSWei Mi!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git e42c17446a2e5cbf9eebc752beafadad3fac7f63)"} 110ee35784aSWei Mi!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) 111ee35784aSWei Mi!8 = !DISubroutineType(types: !2) 112ee35784aSWei Mi!9 = !DILocation(line: 29, column: 5, scope: !7) 113ee35784aSWei Mi!10 = !{!11, !11, i64 0} 114ee35784aSWei Mi!11 = !{!"any pointer", !12, i64 0} 115ee35784aSWei Mi!12 = !{!"omnipotent char", !13, i64 0} 116ee35784aSWei Mi!13 = !{!"Simple C++ TBAA"} 117ee35784aSWei Mi!14 = !DILocation(line: 30, column: 3, scope: !7) 118ee35784aSWei Mi!15 = !DILocation(line: 31, column: 3, scope: !7) 119ee35784aSWei Mi!16 = !DILocation(line: 32, column: 3, scope: !7) 120ee35784aSWei Mi!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) 121ee35784aSWei Mi!18 = !DILocation(line: 18, column: 3, scope: !17) 122ee35784aSWei Mi!19 = !DILocation(line: 19, column: 1, scope: !17) 123ee35784aSWei Mi!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) 124ee35784aSWei Mi!21 = !DILocation(line: 25, column: 5, scope: !20) 125ee35784aSWei Mi!22 = !DILocation(line: 25, column: 3, scope: !20) 126ee35784aSWei Mi!23 = !DILocation(line: 26, column: 1, scope: !20) 127ee35784aSWei Mi!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) 128ee35784aSWei Mi!25 = !DILocation(line: 12, column: 3, scope: !24) 129ee35784aSWei Mi!26 = !DILocation(line: 13, column: 7, scope: !24) 130ee35784aSWei Mi!27 = !{!28, !28, i64 0} 131ee35784aSWei Mi!28 = !{!"bool", !12, i64 0} 132ee35784aSWei Mi!29 = !{i8 0, i8 2} 133ee35784aSWei Mi!30 = !DILocation(line: 14, column: 5, scope: !24) 134ee35784aSWei Mi!31 = !DILocation(line: 15, column: 1, scope: !24) 135ee35784aSWei Mi!32 = !DISubprogram(name: "hoo_callee", linkageName: "_Z10hoo_calleev", scope: !1, file: !1, line: 3, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) 136ee35784aSWei Mi!33 = !DISubprogram(name: "moo_callee", linkageName: "_Z10moo_calleev", scope: !1, file: !1, line: 2, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) 137ee35784aSWei Mi!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) 138ee35784aSWei Mi!35 = !DILocation(line: 7, column: 7, scope: !34) 139ee35784aSWei Mi!36 = !DILocation(line: 8, column: 5, scope: !34) 140ee35784aSWei Mi!37 = !DILocation(line: 9, column: 1, scope: !34) 141ee35784aSWei Mi!38 = !DISubprogram(name: "noo_callee", linkageName: "_Z10noo_calleev", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) 142