• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Make sure Import GUID list for ThinLTO properly maintained while update function's entry count for inlining
2
3; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/inline-callee-update.prof -S | FileCheck %s
4
5@y = global i32* ()* null, align 8
6@z = global i32* ()* null, align 8
7
8; CHECK: define i32* @sample_loader_inlinee() {{.*}} !prof ![[ENTRY:[0-9]+]]
9define i32* @sample_loader_inlinee() #0 !dbg !3 {
10bb:
11  %tmp = call i32* @direct_leaf_func(i32* null), !dbg !4
12  %cmp = icmp ne i32* %tmp, null
13  br i1 %cmp, label %then, label %else
14
15then:                                             ; preds = %bb
16  %tmp1 = load i32* ()*, i32* ()** @z, align 8, !dbg !5
17  %tmp2 = call i32* %tmp1(), !dbg !5
18  ret i32* %tmp2
19
20else:                                             ; preds = %bb
21  ret i32* null
22}
23
24; CHECK: define i32* @cgscc_inlinee() {{.*}} !prof ![[ENTRY:[0-9]+]]
25define i32* @cgscc_inlinee() #0 !dbg !6 {
26bb:
27  %tmp = call i32* @direct_leaf_func(i32* null), !dbg !7
28  %cmp = icmp ne i32* %tmp, null
29  br i1 %cmp, label %then, label %else
30
31then:                                             ; preds = %bb
32  %tmp1 = load i32* ()*, i32* ()** @y, align 8, !dbg !8
33  %tmp2 = call i32* %tmp1(), !dbg !8
34  ret i32* %tmp2
35
36else:                                             ; preds = %bb
37  ret i32* null
38}
39
40define i32* @test_sample_loader_inline(void ()* %arg) #0 !dbg !9 {
41bb:
42  %tmp = call i32* @sample_loader_inlinee(), !dbg !10
43  ret i32* %tmp
44}
45
46define i32* @test_cgscc_inline(void ()* %arg) #0 !dbg !11 {
47bb:
48  %tmp = call i32* @cgscc_inlinee(), !dbg !12
49  ret i32* %tmp
50}
51
52declare i32* @direct_leaf_func(i32*)
53
54attributes #0 = {"use-sample-profile"}
55
56!llvm.dbg.cu = !{!0}
57!llvm.module.flags = !{!2}
58
59!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
60!1 = !DIFile(filename: "test.cc", directory: "/")
61!2 = !{i32 2, !"Debug Info Version", i32 3}
62!3 = distinct !DISubprogram(name: "sample_loader_inlinee", scope: !1, file: !1, line: 11, spFlags: DISPFlagDefinition, unit: !0)
63!4 = !DILocation(line: 12, scope: !3)
64!5 = !DILocation(line: 13, scope: !3)
65!6 = distinct !DISubprogram(name: "cgscc_inlinee", scope: !1, file: !1, line: 31, spFlags: DISPFlagDefinition, unit: !0)
66!7 = !DILocation(line: 32, scope: !6)
67!8 = !DILocation(line: 33, scope: !6)
68!9 = distinct !DISubprogram(name: "test_sample_loader_inline", scope: !1, file: !1, line: 3, spFlags: DISPFlagDefinition, unit: !0)
69!10 = !DILocation(line: 4, scope: !9)
70!11 = distinct !DISubprogram(name: "test_cgscc_inline", scope: !1, file: !1, line: 20, spFlags: DISPFlagDefinition, unit: !0)
71!12 = !DILocation(line: 21, scope: !11)
72
73; Make sure the ImportGUID stays with entry count metadata for ThinLTO-PreLink
74; CHECK: ![[ENTRY]] = !{!"function_entry_count", i64 1, i64 -9171813444624716006}
75