| 1 |
; RUN: opt < %s -passes=sample-profile -sample-profile-icp-max-prom=4 -sample-profile-file=%S/Inputs/norepeated-icp-3.prof -S | FileCheck %s |
| 2 |
|
| 3 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 4 |
target triple = "x86_64-unknown-linux-gnu" |
| 5 |
|
| 6 |
@.str = private unnamed_addr constant [5 x i8] c"hoo\0A\00", align 1 |
| 7 |
@p = dso_local global ptr null, align 8 |
| 8 |
@str = private unnamed_addr constant [4 x i8] c"hoo\00", align 1 |
| 9 |
|
| 10 |
; Function Attrs: nofree nounwind |
| 11 |
declare dso_local noundef i32 @printf(ptr nocapture noundef readonly, ...) #1 |
| 12 |
|
| 13 |
; Function Attrs: uwtable mustprogress |
| 14 |
define dso_local void @_Z3goov() #0 !dbg !11 { |
| 15 |
entry: |
| 16 |
%0 = load ptr, ptr @p, align 8, !dbg !12, !tbaa !13 |
| 17 |
call void %0(), !dbg !17, !prof !22 |
| 18 |
ret void, !dbg !18 |
| 19 |
} |
| 20 |
|
| 21 |
; After the indirect call in _Z3goov is inlined into _Z3foov, it will be |
| 22 |
; annotated with new inline instance profile. The existing value profile |
| 23 |
; associated with the indirect call should be dropped except those values |
| 24 |
; wth NOMORE_ICP_MAGICNUM magic number indicating promoted targets. |
| 25 |
; CHECK-LABEL: @_Z3foov( |
| 26 |
; CHECK: call void %0(), {{.*}} !prof ![[PROF_ID:[0-9]+]] |
| 27 |
; CHECK-NEXT: ret void |
| 28 |
|
| 29 |
; Function Attrs: uwtable mustprogress |
| 30 |
define dso_local void @_Z3foov() #0 !dbg !19 { |
| 31 |
entry: |
| 32 |
call void @_Z3goov(), !dbg !20 |
| 33 |
ret void, !dbg !21 |
| 34 |
} |
| 35 |
|
| 36 |
; Function Attrs: nofree nounwind |
| 37 |
declare noundef i32 @puts(ptr nocapture noundef readonly) #1 |
| 38 |
|
| 39 |
attributes #0 = { uwtable mustprogress "use-sample-profile" } |
| 40 |
attributes #1 = { nofree nounwind } |
| 41 |
|
| 42 |
!llvm.dbg.cu = !{!0} |
| 43 |
!llvm.module.flags = !{!3, !4, !5} |
| 44 |
!llvm.ident = !{!6} |
| 45 |
|
| 46 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None) |
| 47 |
!1 = !DIFile(filename: "1.cc", directory: "") |
| 48 |
!2 = !{} |
| 49 |
!3 = !{i32 7, !"Dwarf Version", i32 4} |
| 50 |
!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 51 |
!5 = !{i32 1, !"wchar_size", i32 4} |
| 52 |
!6 = !{!""} |
| 53 |
!8 = !DISubroutineType(types: !2) |
| 54 |
!11 = distinct !DISubprogram(name: "goo", linkageName: "_Z3goov", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) |
| 55 |
!12 = !DILocation(line: 7, column: 5, scope: !11) |
| 56 |
!13 = !{!14, !14, i64 0} |
| 57 |
!14 = !{!"any pointer", !15, i64 0} |
| 58 |
!15 = !{!"omnipotent char", !16, i64 0} |
| 59 |
!16 = !{!"Simple C++ TBAA"} |
| 60 |
!17 = !DILocation(line: 7, column: 3, scope: !11) |
| 61 |
!18 = !DILocation(line: 8, column: 1, scope: !11) |
| 62 |
!19 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 10, type: !8, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) |
| 63 |
!20 = !DILocation(line: 11, column: 3, scope: !19) |
| 64 |
!21 = !DILocation(line: 12, column: 3, scope: !19) |
| 65 |
; The original value 125292384912345234234 and its count 8000 should |
| 66 |
; be dropped when the indirect call is annotated with new profile. |
| 67 |
; The original value -7383239051784516332 and its count -1 should be kept |
| 68 |
; because -1 is NOMORE_ICP_MAGICNUM. |
| 69 |
; CHECK: ![[PROF_ID]] = !{!"VP", i32 0, i64 5860, i64 -7383239051784516332, i64 -1, i64 -7701940972712279918, i64 5860} |
| 70 |
!22 = !{!"VP", i32 0, i64 8000, i64 -7383239051784516332, i64 -1, i64 125292384912345234234, i64 8000} |