summaryrefslogtreecommitdiff
path: root/lib/IR/MDBuilder.cpp
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2015-05-13 15:13:45 +0000
committerDiego Novillo <dnovillo@google.com>2015-05-13 15:13:45 +0000
commita3bccceda7ca4d8e8fe8541675b594b4b7ba4148 (patch)
tree4b488412cdbfe7573f1c762447a1f08c38bd94e5 /lib/IR/MDBuilder.cpp
parentdcc57103b82525a35a9e7acc0109d20a83b2b0a0 (diff)
Add function entry count metadata.
Summary: This adds three Function methods to handle function entry counts: setEntryCount() and getEntryCount(). Entry counts are stored under the MD_prof metadata node with the name "function_entry_count". They are unsigned 64 bit values set by profilers (instrumentation and sample profiler changes coming up). Added documentation for new profile metadata and tests. Reviewers: dexonsmith, bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9628 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/MDBuilder.cpp')
-rw-r--r--lib/IR/MDBuilder.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/IR/MDBuilder.cpp b/lib/IR/MDBuilder.cpp
index a9010114044..354592df4c9 100644
--- a/lib/IR/MDBuilder.cpp
+++ b/lib/IR/MDBuilder.cpp
@@ -53,6 +53,16 @@ MDNode *MDBuilder::createBranchWeights(ArrayRef<uint32_t> Weights) {
return MDNode::get(Context, Vals);
}
+MDNode *MDBuilder::createFunctionEntryCount(uint64_t Count) {
+ SmallVector<Metadata *, 2> Vals(2);
+ Vals[0] = createString("function_entry_count");
+
+ Type *Int64Ty = Type::getInt64Ty(Context);
+ Vals[1] = createConstant(ConstantInt::get(Int64Ty, Count));
+
+ return MDNode::get(Context, Vals);
+}
+
MDNode *MDBuilder::createRange(const APInt &Lo, const APInt &Hi) {
assert(Lo.getBitWidth() == Hi.getBitWidth() && "Mismatched bitwidths!");