diff options
| author | Dehao Chen <dehao@google.com> | 2017-02-28 18:09:44 +0000 |
|---|---|---|
| committer | Dehao Chen <dehao@google.com> | 2017-02-28 18:09:44 +0000 |
| commit | a60cdd38812d2f2cc32a2446b24bca607a1f6341 (patch) | |
| tree | 491cf2321050cee91fb50fff4a65f58a900374fe /llvm/docs | |
| parent | 2fdabb055d4179fc4e71d8708ab0a352b842fbba (diff) | |
| download | bcm5719-llvm-a60cdd38812d2f2cc32a2446b24bca607a1f6341.tar.gz bcm5719-llvm-a60cdd38812d2f2cc32a2446b24bca607a1f6341.zip | |
Add function importing info from samplepgo profile to the module summary.
Summary: For SamplePGO, the profile may contain cross-module inline stacks. As we need to make sure the profile annotation happens when all the hot inline stacks are expanded, we need to pass this info to the module importer so that it can import proper functions if necessary. This patch implemented this feature by emitting cross-module targets as part of function entry metadata. In the module-summary phase, the metadata is used to build call edges that points to functions need to be imported.
Reviewers: mehdi_amini, tejohnson
Reviewed By: tejohnson
Subscribers: davidxl, llvm-commits
Differential Revision: https://reviews.llvm.org/D30053
llvm-svn: 296498
Diffstat (limited to 'llvm/docs')
| -rw-r--r-- | llvm/docs/BranchWeightMetadata.rst | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/docs/BranchWeightMetadata.rst b/llvm/docs/BranchWeightMetadata.rst index 9e61d232d74..b941d0d1505 100644 --- a/llvm/docs/BranchWeightMetadata.rst +++ b/llvm/docs/BranchWeightMetadata.rst @@ -123,11 +123,11 @@ To allow comparing different functions during inter-procedural analysis and optimization, ``MD_prof`` nodes can also be assigned to a function definition. The first operand is a string indicating the name of the associated counter. -Currently, one counter is supported: "function_entry_count". This is a 64-bit -counter that indicates the number of times that this function was invoked (in -the case of instrumentation-based profiles). In the case of sampling-based -profiles, this counter is an approximation of how many times the function was -invoked. +Currently, one counter is supported: "function_entry_count". The second operand +is a 64-bit counter that indicates the number of times that this function was +invoked (in the case of instrumentation-based profiles). In the case of +sampling-based profiles, this operand is an approximation of how many times +the function was invoked. For example, in the code below, the instrumentation for function foo() indicates that it was called 2,590 times at runtime. @@ -138,3 +138,13 @@ indicates that it was called 2,590 times at runtime. ret i32 0 } !1 = !{!"function_entry_count", i64 2590} + +If "function_entry_count" has more than 2 operands, the later operands are +the GUID of the functions that needs to be imported by ThinLTO. This is only +set by sampling based profile. It is needed because the sampling based profile +was collected on a binary that had already imported and inlined these functions, +and we need to ensure the IR matches in the ThinLTO backends for profile +annotation. The reason why we cannot annotate this on the callsite is that it +can only goes down 1 level in the call chain. For the cases where +foo_in_a_cc()->bar_in_b_cc()->baz_in_c_cc(), we will need to go down 2 levels +in the call chain to import both bar_in_b_cc and baz_in_c_cc. |

