• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.prof -S | FileCheck %s
2; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.compact.afdo -S | FileCheck %s
3
4; Tests whether the functions in the inline stack are added to the
5; function_entry_count metadata.
6
7declare void @foo()
8
9declare void @bar()
10
11declare !dbg !13 void @bar_dbg()
12
13define void @bar_available() #0 !dbg !14 {
14  ret void
15}
16
17; CHECK: define void @test({{.*}} !prof ![[ENTRY_TEST:[0-9]+]]
18define void @test(void ()*) #0 !dbg !7 {
19  %2 = alloca void ()*
20  store void ()* %0, void ()** %2
21  %3 = load void ()*, void ()** %2
22  ; CHECK: call {{.*}}, !prof ![[PROF:[0-9]+]]
23  call void @foo(), !dbg !18
24  call void %3(), !dbg !19
25  ret void
26}
27
28; CHECK: define void @test_liveness({{.*}} !prof ![[ENTRY_TEST_LIVENESS:[0-9]+]]
29define void @test_liveness() #0 !dbg !12 {
30  call void @foo(), !dbg !20
31  ret void
32}
33
34; GUIDs of foo, bar, foo1, foo2 and foo3 should be included in the metadata to
35; make sure hot inline stacks are imported. The total count of baz is lower
36; than the hot cutoff threshold and its GUID should not be included in the
37; metadata.
38; CHECK: ![[ENTRY_TEST]] = !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905,  i64 -7908226060800700466, i64 -2012135647395072713}
39
40; Check GUIDs for foo, bar and bar_dbg are included in the metadata to
41; make sure the liveness analysis can capture the dependency from test_liveness
42; to bar. bar_available should not be included as it's within the same module.
43; CHECK: ![[ENTRY_TEST_LIVENESS]] = !{!"function_entry_count", i64 1, i64 6699318081062747564, i64 -2012135647395072713, i64 -1522495160813492905}
44
45attributes #0 = {"use-sample-profile"}
46
47!llvm.dbg.cu = !{!0}
48!llvm.module.flags = !{!8, !9}
49!llvm.ident = !{!10}
50
51!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
52!1 = !DIFile(filename: "calls.cc", directory: ".")
53!2 = !{}
54!6 = !DISubroutineType(types: !2)
55!7 = distinct !DISubprogram(name: "test", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
56!8 = !{i32 2, !"Dwarf Version", i32 4}
57!9 = !{i32 1, !"Debug Info Version", i32 3}
58!10 = !{!"clang version 3.5 "}
59!12 = distinct !DISubprogram(name: "test_liveness", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
60!13 = !DISubprogram(name: "bar_dbg", scope: !1, file: !1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
61!14 = distinct !DISubprogram(name: "bar_available", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
62!15 = !DILexicalBlockFile(discriminator: 1, file: !1, scope: !7)
63!17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7)
64!18 = !DILocation(line: 10, scope: !17)
65!19 = !DILocation(line: 11, scope: !17)
66!20 = !DILocation(line: 8, scope: !12)
67