158 lines · plain
1; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list-callee-samples.prof -S | FileCheck %s2 3; Original source code:4 5; file1.c:6;7; int a = 1;8; int bar(int x);9;10; int(*foo())() {11; a++;12; return bar;13; };14 15; __attribute__((noinline)) void func()16; {17; int (*fptr)(int);18; fptr = foo();19; a += (*fptr)(10);20; }21 22; int main() {23; for(int i = 0; i < 1000 * 1000; i++)24; func();25; }26 27; file2.c:28;29; int bar(int x) { return x + 1;}30 31 32 33; GUID for bar is -2012135647395072713, make sure bar is not imported.34; CHECK: ![[#]] = !{!"function_entry_count", i64 1557}35; CHECK-NOT: ![[#]] = !{!"function_entry_count", i64 1557, i64 -2012135647395072713}36 37@a = dso_local global i32 1, align 438 39; Function Attrs: nounwind uwtable40define dso_local ptr @foo() #0 !dbg !11 {41entry:42 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 1, i32 0, i64 -1), !dbg !1443 %0 = load volatile i32, ptr @a, align 4, !dbg !14, !tbaa !1544 %inc = add nsw i32 %0, 1, !dbg !1445 store volatile i32 %inc, ptr @a, align 4, !dbg !14, !tbaa !1546 ret ptr @bar, !dbg !1947}48 49declare dso_local i32 @bar(i32 noundef) #150 51; Function Attrs: noinline nounwind uwtable52define dso_local void @func() #2 !dbg !20 {53entry:54 call void @llvm.pseudoprobe(i64 7289175272376759421, i64 1, i32 0, i64 -1), !dbg !2155 %call = call ptr @foo(), !dbg !2256 %call1 = call i32 %call(i32 noundef 10), !dbg !2457 %0 = load volatile i32, ptr @a, align 4, !dbg !26, !tbaa !1558 %add = add nsw i32 %0, %call1, !dbg !2659 store volatile i32 %add, ptr @a, align 4, !dbg !26, !tbaa !1560 ret void, !dbg !2761}62 63; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)64declare void @llvm.lifetime.start.p0(ptr nocapture) #365 66; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)67declare void @llvm.lifetime.end.p0(ptr nocapture) #368 69; Function Attrs: nounwind uwtable70define dso_local i32 @main() #0 !dbg !28 {71entry:72 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 1, i32 0, i64 -1), !dbg !2973 br label %for.cond, !dbg !3074 75for.cond: ; preds = %for.body, %entry76 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ], !dbg !3177 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 2, i32 0, i64 -1), !dbg !3278 %cmp = icmp slt i32 %i.0, 1000000, !dbg !3479 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !3680 81for.cond.cleanup: ; preds = %for.cond82 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 3, i32 0, i64 -1), !dbg !3783 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 6, i32 0, i64 -1), !dbg !3884 ret i32 0, !dbg !3885 86for.body: ; preds = %for.cond87 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 4, i32 0, i64 -1), !dbg !3988 call void @func(), !dbg !4089 call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 5, i32 0, i64 -1), !dbg !4290 %inc = add nsw i32 %i.0, 1, !dbg !4391 br label %for.cond, !dbg !45, !llvm.loop !4692}93 94; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)95declare void @llvm.pseudoprobe(i64, i64, i32, i64) #496 97attributes #0 = { nounwind uwtable "disable-tail-calls"="true" "frame-pointer"="all" "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" }98attributes #1 = { "disable-tail-calls"="true" "frame-pointer"="all" "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" }99attributes #2 = { noinline nounwind uwtable "disable-tail-calls"="true" "frame-pointer"="all" "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" }100attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }101attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }102 103!llvm.dbg.cu = !{!0}104!llvm.module.flags = !{!2, !3, !4, !5, !6}105!llvm.ident = !{!7}106!llvm.pseudo_probe_desc = !{!8, !9, !10}107 108!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)109!1 = !DIFile(filename: "file.c", directory: "/tmp/")110!2 = !{i32 2, !"Debug Info Version", i32 3}111!3 = !{i32 1, !"wchar_size", i32 4}112!4 = !{i32 7, !"uwtable", i32 2}113!5 = !{i32 7, !"frame-pointer", i32 2}114!6 = !{i32 1, !"EnableSplitLTOUnit", i32 0}115!7 = !{!"clang version 17.0.0"}116!8 = !{i64 6699318081062747564, i64 4294967295, !"foo"}117!9 = !{i64 7289175272376759421, i64 562954248388607, !"func"}118!10 = !{i64 -2624081020897602054, i64 281582081721716, !"main"}119!11 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !12, scopeLine: 6, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)120!12 = !DISubroutineType(types: !13)121!13 = !{}122!14 = !DILocation(line: 7, column: 4, scope: !11)123!15 = !{!16, !16, i64 0}124!16 = !{!"int", !17, i64 0}125!17 = !{!"omnipotent char", !18, i64 0}126!18 = !{!"Simple C/C++ TBAA"}127!19 = !DILocation(line: 8, column: 3, scope: !11)128!20 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 11, type: !12, scopeLine: 12, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)129!21 = !DILocation(line: 14, column: 12, scope: !20)130!22 = !DILocation(line: 14, column: 12, scope: !23)131!23 = !DILexicalBlockFile(scope: !20, file: !1, discriminator: 186646551)132!24 = !DILocation(line: 15, column: 11, scope: !25)133!25 = !DILexicalBlockFile(scope: !20, file: !1, discriminator: 119537695)134!26 = !DILocation(line: 15, column: 7, scope: !20)135!27 = !DILocation(line: 16, column: 1, scope: !20)136!28 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 18, type: !12, scopeLine: 18, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)137!29 = !DILocation(line: 19, column: 11, scope: !28)138!30 = !DILocation(line: 19, column: 7, scope: !28)139!31 = !DILocation(line: 19, scope: !28)140!32 = !DILocation(line: 19, column: 18, scope: !33)141!33 = !DILexicalBlockFile(scope: !28, file: !1, discriminator: 0)142!34 = !DILocation(line: 19, column: 20, scope: !35)143!35 = !DILexicalBlockFile(scope: !28, file: !1, discriminator: 2)144!36 = !DILocation(line: 19, column: 3, scope: !35)145!37 = !DILocation(line: 0, scope: !28)146!38 = !DILocation(line: 21, column: 1, scope: !28)147!39 = !DILocation(line: 20, column: 5, scope: !28)148!40 = !DILocation(line: 20, column: 5, scope: !41)149!41 = !DILexicalBlockFile(scope: !28, file: !1, discriminator: 186646591)150!42 = !DILocation(line: 19, column: 36, scope: !33)151!43 = !DILocation(line: 19, column: 36, scope: !44)152!44 = !DILexicalBlockFile(scope: !28, file: !1, discriminator: 4)153!45 = !DILocation(line: 19, column: 3, scope: !44)154!46 = distinct !{!46, !47, !48, !49}155!47 = !DILocation(line: 19, column: 3, scope: !28)156!48 = !DILocation(line: 20, column: 10, scope: !28)157!49 = !{!"llvm.loop.mustprogress"}158