Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 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 | |
| 7 | declare void @foo() |
| 8 | |
| 9 | define void @foo_available() !dbg !11 { |
| 10 | ret void |
| 11 | } |
| 12 | |
| 13 | ; CHECK: define void @test({{.*}} !prof ![[ENTRY_TEST:[0-9]+]] |
| 14 | define void @test(void ()*) !dbg !7 { |
| 15 | %2 = alloca void ()* |
| 16 | store void ()* %0, void ()** %2 |
| 17 | %3 = load void ()*, void ()** %2 |
| 18 | ; CHECK: call {{.*}}, !prof ![[PROF:[0-9]+]] |
| 19 | call void @foo(), !dbg !18 |
| 20 | call void %3(), !dbg !19 |
| 21 | ret void |
| 22 | } |
| 23 | |
| 24 | ; CHECK: define void @test_liveness({{.*}} !prof ![[ENTRY_TEST_LIVENESS:[0-9]+]] |
| 25 | define void @test_liveness() !dbg !12 { |
| 26 | call void @foo(), !dbg !20 |
| 27 | ret void |
| 28 | } |
| 29 | |
| 30 | ; GUIDs of foo, bar, foo1, foo2 and foo3 should be included in the metadata to |
| 31 | ; make sure hot inline stacks are imported. The total count of baz is lower |
| 32 | ; than the hot cutoff threshold and its GUID should not be included in the |
| 33 | ; metadata. |
| 34 | ; CHECK: ![[ENTRY_TEST]] = !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905, i64 -7908226060800700466, i64 -2012135647395072713} |
| 35 | |
| 36 | ; Check GUIDs for both foo and foo_available are included in the metadata to |
| 37 | ; make sure the liveness analysis can capture the dependency from test_liveness |
| 38 | ; to foo_available. |
| 39 | ; CHECK: ![[ENTRY_TEST_LIVENESS]] = !{!"function_entry_count", i64 1, i64 4005816710939881937, i64 6699318081062747564} |
| 40 | |
| 41 | !llvm.dbg.cu = !{!0} |
| 42 | !llvm.module.flags = !{!8, !9} |
| 43 | !llvm.ident = !{!10} |
| 44 | |
| 45 | !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) |
| 46 | !1 = !DIFile(filename: "calls.cc", directory: ".") |
| 47 | !2 = !{} |
| 48 | !6 = !DISubroutineType(types: !2) |
| 49 | !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) |
| 50 | !8 = !{i32 2, !"Dwarf Version", i32 4} |
| 51 | !9 = !{i32 1, !"Debug Info Version", i32 3} |
| 52 | !10 = !{!"clang version 3.5 "} |
| 53 | !11 = distinct !DISubprogram(name: "foo_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) |
| 54 | !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) |
| 55 | !15 = !DILexicalBlockFile(discriminator: 1, file: !1, scope: !7) |
| 56 | !17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7) |
| 57 | !18 = !DILocation(line: 10, scope: !17) |
| 58 | !19 = !DILocation(line: 11, scope: !17) |
| 59 | !20 = !DILocation(line: 8, scope: !12) |