From 2567f3d0fb1f2812f99111ecd67d228ccae42c49 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Wed, 13 May 2015 15:13:45 +0000 Subject: 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 llvm-svn: 237260 --- llvm/lib/IR/MDBuilder.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'llvm/lib/IR/MDBuilder.cpp') diff --git a/llvm/lib/IR/MDBuilder.cpp b/llvm/lib/IR/MDBuilder.cpp index a901011..354592d 100644 --- a/llvm/lib/IR/MDBuilder.cpp +++ b/llvm/lib/IR/MDBuilder.cpp @@ -53,6 +53,16 @@ MDNode *MDBuilder::createBranchWeights(ArrayRef Weights) { return MDNode::get(Context, Vals); } +MDNode *MDBuilder::createFunctionEntryCount(uint64_t Count) { + SmallVector 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!"); -- cgit v1.1