summaryrefslogtreecommitdiff
path: root/lib/IR/MDBuilder.cpp
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2018-01-09 19:39:35 +0000
committerEaswaran Raman <eraman@google.com>2018-01-09 19:39:35 +0000
commit283d9781d91cadc8a1e5c02ca6f8a0cf8d1cb040 (patch)
treeec01d073e045f24859b0f2e5a1d933d8762eb147 /lib/IR/MDBuilder.cpp
parent2fd0a70e2df75961328217a8cb68d662c981d10d (diff)
Add a pass to generate synthetic function entry counts.
Summary: This pass synthesizes function entry counts by traversing the callgraph and using the relative block frequencies of the callsites. The intended use of these counts is in inlining to determine hot/cold callsites in the absence of profile information. The pass is split into two files with the code that propagates the counts in a callgraph in a Utils file. I plan to add support for propagation in the thinlto link phase and the propagation code will be shared and hence this split. I did not add support to the old PM since hot callsite determination in inlining is not possible in old PM (although we could use hot callee heuristic with synthetic counts in the old PM it is not worth the effort tuning it) Reviewers: davidxl, silvas Subscribers: mgorny, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D41604 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/MDBuilder.cpp')
-rw-r--r--lib/IR/MDBuilder.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/IR/MDBuilder.cpp b/lib/IR/MDBuilder.cpp
index 6d77a8f2d60..9d467fb9f6d 100644
--- a/lib/IR/MDBuilder.cpp
+++ b/lib/IR/MDBuilder.cpp
@@ -58,10 +58,14 @@ MDNode *MDBuilder::createUnpredictable() {
}
MDNode *MDBuilder::createFunctionEntryCount(
- uint64_t Count, const DenseSet<GlobalValue::GUID> *Imports) {
+ uint64_t Count, bool Synthetic,
+ const DenseSet<GlobalValue::GUID> *Imports) {
Type *Int64Ty = Type::getInt64Ty(Context);
SmallVector<Metadata *, 8> Ops;
- Ops.push_back(createString("function_entry_count"));
+ if (Synthetic)
+ Ops.push_back(createString("synthetic_function_entry_count"));
+ else
+ Ops.push_back(createString("function_entry_count"));
Ops.push_back(createConstant(ConstantInt::get(Int64Ty, Count)));
if (Imports) {
SmallVector<GlobalValue::GUID, 2> OrderID(Imports->begin(), Imports->end());