141 lines · plain
1; Make sure profile matching is successful if both profile and IR contain2; ".__uniq." suffix, for text format or extbinary format profile.3; Make sure profile matching is successful if IR contains ".__uniq." suffix4; 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 %s6; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.suffix.afdo -S | FileCheck %s7; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/uniqname.nosuffix.afdo -S | FileCheck %s8 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 113@p = dso_local global ptr null, align 814 15; Check the callsite in inlined function with uniq suffix is annotated with16; 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 void21 22; Function Attrs: uwtable mustprogress23define dso_local void @_Z3foov() #0 !dbg !7 {24entry:25 store ptr @_ZL3hoov.__uniq.334154460836426447066042049082945760258, ptr @p, align 8, !dbg !9, !tbaa !1026 call void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271(), !dbg !1427 call void @_ZL3moov.__uniq.334154460836426447066042049082945760258(), !dbg !1528 ret void, !dbg !1629}30 31; Function Attrs: uwtable mustprogress32define internal void @_ZL3hoov.__uniq.334154460836426447066042049082945760258() #1 !dbg !17 {33entry:34 call void @_Z10hoo_calleev(), !dbg !1835 ret void, !dbg !1936}37 38; Check the indirect call target with uniq suffix is promoted and the inlined39; 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.33415446083642644706604204908294576025842; CHECK: call void @_Z10hoo_calleev(), {{.*}} !prof ![[PROF_ID4:[0-9]+]]43 44; Function Attrs: noinline uwtable mustprogress45define internal void @_ZL3goov.__uniq.334154460836426447066042049082945760258.llvm.4206369970847378271() #2 !dbg !20 {46entry:47 %0 = load ptr, ptr @p, align 8, !dbg !21, !tbaa !1048 call void %0(), !dbg !2249 ret void, !dbg !2350}51 52; Function Attrs: uwtable mustprogress53define internal void @_ZL3moov.__uniq.334154460836426447066042049082945760258() #1 !dbg !24 {54entry:55 call void @_Z10moo_calleev(), !dbg !2556 %0 = load volatile i8, ptr @cond, align 1, !dbg !26, !tbaa !27, !range !2957 %tobool.not = icmp eq i8 %0, 0, !dbg !2658 br i1 %tobool.not, label %if.end, label %if.then, !dbg !2659 60if.then: ; preds = %entry61 call void @_ZL3noov.__uniq.334154460836426447066042049082945760258(), !dbg !3062 br label %if.end, !dbg !3063 64if.end: ; preds = %if.then, %entry65 ret void, !dbg !3166}67 68declare !dbg !32 dso_local void @_Z10hoo_calleev()69 70declare !dbg !33 dso_local void @_Z10moo_calleev()71 72; Function Attrs: uwtable mustprogress73define internal void @_ZL3noov.__uniq.334154460836426447066042049082945760258() #1 !dbg !34 {74entry:75 %0 = load volatile i8, ptr @cond, align 1, !dbg !35, !tbaa !27, !range !2976 %tobool.not = icmp eq i8 %0, 0, !dbg !3577 br i1 %tobool.not, label %if.end, label %if.then, !dbg !3578 79if.then: ; preds = %entry80 call void @_Z10noo_calleev(), !dbg !3681 br label %if.end, !dbg !3682 83if.end: ; preds = %if.then, %entry84 ret void, !dbg !3785}86 87declare !dbg !38 dso_local void @_Z10noo_calleev()88 89attributes #0 = { uwtable mustprogress "use-sample-profile" }90attributes #1 = { uwtable mustprogress "use-sample-profile" "sample-profile-suffix-elision-policy"="selected" }91attributes #2 = { noinline uwtable mustprogress "use-sample-profile" "sample-profile-suffix-elision-policy"="selected" }92 93; CHECK: ![[PROF_ID1]] = !{!"branch_weights", i32 5931}94; CHECK: ![[PROF_ID2]] = !{!"branch_weights", i32 2000}95; CHECK: ![[PROF_ID3]] = !{!"function_entry_count", i64 5861}96; CHECK: ![[PROF_ID4]] = !{!"branch_weights", i32 5000}97 98!llvm.dbg.cu = !{!0}99!llvm.module.flags = !{!3, !4, !5}100!llvm.ident = !{!6}101 102!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)103!1 = !DIFile(filename: "1.cc", directory: "/usr/local/google/home/wmi/workarea/llvm/build/splitprofile")104!2 = !{}105!3 = !{i32 7, !"Dwarf Version", i32 4}106!4 = !{i32 2, !"Debug Info Version", i32 3}107!5 = !{i32 1, !"wchar_size", i32 4}108!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git e42c17446a2e5cbf9eebc752beafadad3fac7f63)"}109!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)110!8 = !DISubroutineType(types: !2)111!9 = !DILocation(line: 29, column: 5, scope: !7)112!10 = !{!11, !11, i64 0}113!11 = !{!"any pointer", !12, i64 0}114!12 = !{!"omnipotent char", !13, i64 0}115!13 = !{!"Simple C++ TBAA"}116!14 = !DILocation(line: 30, column: 3, scope: !7)117!15 = !DILocation(line: 31, column: 3, scope: !7)118!16 = !DILocation(line: 32, column: 3, scope: !7)119!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)120!18 = !DILocation(line: 18, column: 3, scope: !17)121!19 = !DILocation(line: 19, column: 1, scope: !17)122!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)123!21 = !DILocation(line: 25, column: 5, scope: !20)124!22 = !DILocation(line: 25, column: 3, scope: !20)125!23 = !DILocation(line: 26, column: 1, scope: !20)126!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)127!25 = !DILocation(line: 12, column: 3, scope: !24)128!26 = !DILocation(line: 13, column: 7, scope: !24)129!27 = !{!28, !28, i64 0}130!28 = !{!"bool", !12, i64 0}131!29 = !{i8 0, i8 2}132!30 = !DILocation(line: 14, column: 5, scope: !24)133!31 = !DILocation(line: 15, column: 1, scope: !24)134!32 = !DISubprogram(name: "hoo_callee", linkageName: "_Z10hoo_calleev", scope: !1, file: !1, line: 3, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)135!33 = !DISubprogram(name: "moo_callee", linkageName: "_Z10moo_calleev", scope: !1, file: !1, line: 2, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)136!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)137!35 = !DILocation(line: 7, column: 7, scope: !34)138!36 = !DILocation(line: 8, column: 5, scope: !34)139!37 = !DILocation(line: 9, column: 1, scope: !34)140!38 = !DISubprogram(name: "noo_callee", linkageName: "_Z10noo_calleev", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)141