brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.9 KiB · cda66b1 Raw
219 lines · plain
1; REQUIRES: asserts && x86-registered-target2; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-LCS.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl 2>&1 | FileCheck %s3; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-LCS.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl --salvage-stale-profile-max-callsites=6 2>&1 | FileCheck %s -check-prefix=CHECK-MAX-CALLSITES4 5; CHECK: Run stale profile matching for test_indirect_call6; CHECK: Location is matched from 1 to 17; CHECK: Location is matched from 2 to 28; CHECK: Location is matched from 3 to 39; CHECK: Location is matched from 4 to 410; CHECK: Callsite with callee:C is matched from 5 to 211; CHECK: Location is rematched backwards from 3 to 012; CHECK: Location is rematched backwards from 4 to 113; CHECK: Callsite with callee:unknown.indirect.callee is matched from 6 to 314; CHECK:Callsite with callee:B is matched from 7 to 415; CHECK: Location is matched from 8 to 516; CHECK: Callsite with callee:unknown.indirect.callee is matched from 9 to 617; CHECK: Callsite with callee:C is matched from 10 to 718 19; CHECK: Run stale profile matching for test_direct_call20; CHECK: Location is matched from 1 to 121; CHECK: Location is matched from 2 to 222; CHECK: Location is matched from 3 to 323; CHECK: Callsite with callee:C is matched from 4 to 224; CHECK: Location is rematched backwards from 3 to 125; CHECK: Callsite with callee:A is matched from 5 to 426; CHECK: Callsite with callee:B is matched from 6 to 527; CHECK: Location is matched from 7 to 628; CHECK: Callsite with callee:A is matched from 8 to 629 30; CHECK-MAX-CALLSITES: Skip stale profile matching for test_direct_call31; CHECK-MAX-CALLSITES-NOT: Skip stale profile matching for test_indirect_call32 33@c = external global i32, align 434 35; Function Attrs: nounwind uwtable36define dso_local i32 @test_direct_call(i32 noundef %x) #0 !dbg !12 {37entry:38    #dbg_value(i32 %x, !17, !DIExpression(), !18)39  call void @llvm.pseudoprobe(i64 -4364451034228175269, i64 1, i32 0, i64 -1), !dbg !1940  %call = call i32 @A(i32 noundef %x), !dbg !2041  %add = add nsw i32 %x, %call, !dbg !2242    #dbg_value(i32 %add, !17, !DIExpression(), !18)43  %call1 = call i32 @B(i32 noundef %add), !dbg !2344  %add2 = add nsw i32 %add, %call1, !dbg !2545    #dbg_value(i32 %add2, !17, !DIExpression(), !18)46  %call3 = call i32 @C(i32 noundef %add2), !dbg !2647  %add4 = add nsw i32 %add2, %call3, !dbg !2848    #dbg_value(i32 %add4, !17, !DIExpression(), !18)49  %call5 = call i32 @A(i32 noundef %add4), !dbg !2950  %add6 = add nsw i32 %add4, %call5, !dbg !3151    #dbg_value(i32 %add6, !17, !DIExpression(), !18)52  %call7 = call i32 @B(i32 noundef %add6), !dbg !3253  %add8 = add nsw i32 %add6, %call7, !dbg !3454    #dbg_value(i32 %add8, !17, !DIExpression(), !18)55  %call9 = call i32 @B(i32 noundef %add8), !dbg !3556  %add10 = add nsw i32 %add8, %call9, !dbg !3757    #dbg_value(i32 %add10, !17, !DIExpression(), !18)58  %call11 = call i32 @A(i32 noundef %add10), !dbg !3859  %add12 = add nsw i32 %add10, %call11, !dbg !4060    #dbg_value(i32 %add12, !17, !DIExpression(), !18)61  ret i32 %add12, !dbg !4162}63 64; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)65declare void @llvm.dbg.declare(metadata, metadata, metadata) #166 67declare !dbg !42 i32 @A(i32 noundef) #268 69declare !dbg !43 i32 @B(i32 noundef) #270 71declare !dbg !44 i32 @C(i32 noundef) #272 73; Function Attrs: nounwind uwtable74define dso_local i32 @test_indirect_call(i32 noundef %x) #0 !dbg !45 {75entry:76    #dbg_value(i32 %x, !47, !DIExpression(), !50)77  call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 1, i32 0, i64 -1), !dbg !5178  %0 = load i32, ptr @c, align 4, !dbg !51, !tbaa !5379  %tobool = icmp ne i32 %0, 0, !dbg !5180  br i1 %tobool, label %if.then, label %if.else, !dbg !5781 82if.then:                                          ; preds = %entry83  call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 2, i32 0, i64 -1), !dbg !5884    #dbg_value(ptr @A, !48, !DIExpression(), !50)85  br label %if.end, !dbg !5986 87if.else:                                          ; preds = %entry88  call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 3, i32 0, i64 -1), !dbg !6089    #dbg_value(ptr @B, !48, !DIExpression(), !50)90  br label %if.end91 92if.end:                                           ; preds = %if.else, %if.then93  %fp.0 = phi ptr [ @A, %if.then ], [ @B, %if.else ], !dbg !6194    #dbg_value(ptr %fp.0, !48, !DIExpression(), !50)95  call void @llvm.pseudoprobe(i64 -8563147518712133441, i64 4, i32 0, i64 -1), !dbg !6296  %call = call i32 @C(i32 noundef %x), !dbg !6397  %add = add nsw i32 %x, %call, !dbg !6598    #dbg_value(i32 %add, !47, !DIExpression(), !50)99  %call1 = call i32 %fp.0(i32 noundef %add), !dbg !66100  %add2 = add nsw i32 %add, %call1, !dbg !68101    #dbg_value(i32 %add2, !47, !DIExpression(), !50)102  %call3 = call i32 @B(i32 noundef %add2), !dbg !69103  %add4 = add nsw i32 %add2, %call3, !dbg !71104    #dbg_value(i32 %add4, !47, !DIExpression(), !50)105  %call5 = call i32 @C(i32 noundef %add4), !dbg !72106  %add6 = add nsw i32 %add4, %call5, !dbg !74107    #dbg_value(i32 %add6, !47, !DIExpression(), !50)108  %call7 = call i32 %fp.0(i32 noundef %add6), !dbg !75109  %add8 = add nsw i32 %add6, %call7, !dbg !77110    #dbg_value(i32 %add8, !47, !DIExpression(), !50)111  %call9 = call i32 @C(i32 noundef %add8), !dbg !78112  %add10 = add nsw i32 %add8, %call9, !dbg !80113    #dbg_value(i32 %add10, !47, !DIExpression(), !50)114  ret i32 %add10, !dbg !81115}116 117; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)118declare void @llvm.lifetime.start.p0(ptr nocapture) #3119 120; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)121declare void @llvm.lifetime.end.p0(ptr nocapture) #3122 123; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)124declare void @llvm.pseudoprobe(i64, i64, i32, i64) #4125 126attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "use-sample-profile" }127attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn }128attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }129attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }130attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn }131 132!llvm.dbg.cu = !{!0}133!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}134!llvm.ident = !{!9}135!llvm.pseudo_probe_desc = !{!10, !11}136 137!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)138!1 = !DIFile(filename: "test.c", directory: "/home/", checksumkind: CSK_MD5, checksum: "be98aa946f37f0ad8d307c9121efe101")139!2 = !{i32 7, !"Dwarf Version", i32 5}140!3 = !{i32 2, !"Debug Info Version", i32 3}141!4 = !{i32 1, !"wchar_size", i32 4}142!5 = !{i32 8, !"PIC Level", i32 2}143!6 = !{i32 7, !"PIE Level", i32 2}144!7 = !{i32 7, !"uwtable", i32 2}145!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true}146!9 = !{!"clang version 19.0.0"}147!10 = !{i64 -4364451034228175269, i64 1970329131941887, !"test_direct_call"}148!11 = !{i64 -8563147518712133441, i64 1688922477484692, !"test_indirect_call"}149!12 = distinct !DISubprogram(name: "test_direct_call", scope: !1, file: !1, line: 10, type: !13, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)150!13 = !DISubroutineType(types: !14)151!14 = !{!15, !15}152!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)153!16 = !{!17}154!17 = !DILocalVariable(name: "x", arg: 1, scope: !12, file: !1, line: 10, type: !15)155!18 = !DILocation(line: 0, scope: !12)156!19 = !DILocation(line: 11, column: 10, scope: !12)157!20 = !DILocation(line: 11, column: 8, scope: !21)158!21 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646551)159!22 = !DILocation(line: 11, column: 5, scope: !12)160!23 = !DILocation(line: 12, column: 8, scope: !24)161!24 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646559)162!25 = !DILocation(line: 12, column: 5, scope: !12)163!26 = !DILocation(line: 13, column: 8, scope: !27)164!27 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646567)165!28 = !DILocation(line: 13, column: 5, scope: !12)166!29 = !DILocation(line: 14, column: 8, scope: !30)167!30 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646575)168!31 = !DILocation(line: 14, column: 5, scope: !12)169!32 = !DILocation(line: 15, column: 8, scope: !33)170!33 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646583)171!34 = !DILocation(line: 15, column: 5, scope: !12)172!35 = !DILocation(line: 16, column: 8, scope: !36)173!36 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646591)174!37 = !DILocation(line: 16, column: 5, scope: !12)175!38 = !DILocation(line: 17, column: 8, scope: !39)176!39 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 186646599)177!40 = !DILocation(line: 17, column: 5, scope: !12)178!41 = !DILocation(line: 18, column: 3, scope: !12)179!42 = !DISubprogram(name: "A", scope: !1, file: !1, line: 2, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)180!43 = !DISubprogram(name: "B", scope: !1, file: !1, line: 3, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)181!44 = !DISubprogram(name: "C", scope: !1, file: !1, line: 4, type: !13, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)182!45 = distinct !DISubprogram(name: "test_indirect_call", scope: !1, file: !1, line: 21, type: !13, scopeLine: 21, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !46)183!46 = !{!47, !48}184!47 = !DILocalVariable(name: "x", arg: 1, scope: !45, file: !1, line: 21, type: !15)185!48 = !DILocalVariable(name: "fp", scope: !45, file: !1, line: 22, type: !49)186!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)187!50 = !DILocation(line: 0, scope: !45)188!51 = !DILocation(line: 23, column: 6, scope: !52)189!52 = distinct !DILexicalBlock(scope: !45, file: !1, line: 23, column: 6)190!53 = !{!54, !54, i64 0}191!54 = !{!"int", !55, i64 0}192!55 = !{!"omnipotent char", !56, i64 0}193!56 = !{!"Simple C/C++ TBAA"}194!57 = !DILocation(line: 23, column: 6, scope: !45)195!58 = !DILocation(line: 24, column: 8, scope: !52)196!59 = !DILocation(line: 24, column: 5, scope: !52)197!60 = !DILocation(line: 26, column: 8, scope: !52)198!61 = !DILocation(line: 0, scope: !52)199!62 = !DILocation(line: 27, column: 10, scope: !45)200!63 = !DILocation(line: 27, column: 8, scope: !64)201!64 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646575)202!65 = !DILocation(line: 27, column: 5, scope: !45)203!66 = !DILocation(line: 28, column: 8, scope: !67)204!67 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 119537719)205!68 = !DILocation(line: 28, column: 5, scope: !45)206!69 = !DILocation(line: 29, column: 8, scope: !70)207!70 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646591)208!71 = !DILocation(line: 29, column: 5, scope: !45)209!72 = !DILocation(line: 30, column: 8, scope: !73)210!73 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646599)211!74 = !DILocation(line: 30, column: 5, scope: !45)212!75 = !DILocation(line: 31, column: 8, scope: !76)213!76 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 119537743)214!77 = !DILocation(line: 31, column: 5, scope: !45)215!78 = !DILocation(line: 32, column: 8, scope: !79)216!79 = !DILexicalBlockFile(scope: !45, file: !1, discriminator: 186646615)217!80 = !DILocation(line: 32, column: 5, scope: !45)218!81 = !DILocation(line: 33, column: 3, scope: !45)219