summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CodeGenPGO.h
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2014-02-05 20:40:15 +0000
committerManman Ren <manman.ren@gmail.com>2014-02-05 20:40:15 +0000
commit94328b6925a1710ccdc18c7053af3ffd39a26d79 (patch)
tree1fdd4f2b38ef7a69b212496708c928681faa83cf /lib/CodeGen/CodeGenPGO.h
parentcf956c43e15b4860922b242785417fcb34afb5af (diff)
PGO: instrumentation based profiling sets function attributes.
We collect a maximal function count among all functions in the pgo data file. For functions that are hot, we set its InlineHint attribute. For functions that are cold, we set its Cold attribute. We currently treat functions with >= 30% of the maximal function count as hot and functions with <= 1% of the maximal function count are treated as cold. These two numbers are from preliminary tuning on SPEC. This commit should not affect non-PGO builds and should boost performance on instrumentation based PGO. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPGO.h')
-rw-r--r--lib/CodeGen/CodeGenPGO.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenPGO.h b/lib/CodeGen/CodeGenPGO.h
index 2d1193bab0..6409a10525 100644
--- a/lib/CodeGen/CodeGenPGO.h
+++ b/lib/CodeGen/CodeGenPGO.h
@@ -33,12 +33,22 @@ private:
llvm::OwningPtr<llvm::MemoryBuffer> DataBuffer;
/// Offsets into DataBuffer for each function's counters
llvm::StringMap<unsigned> DataOffsets;
+ /// Execution counts for each function.
+ llvm::StringMap<uint64_t> FunctionCounts;
+ /// The maximal execution count among all functions.
+ uint64_t MaxFunctionCount;
CodeGenModule &CGM;
public:
PGOProfileData(CodeGenModule &CGM, std::string Path);
/// Fill Counts with the profile data for the given function name. Returns
/// false on success.
bool getFunctionCounts(StringRef MangledName, std::vector<uint64_t> &Counts);
+ /// Return true if a function is hot. If we know nothing about the function,
+ /// return false.
+ bool isHotFunction(StringRef MangledName);
+ /// Return true if a function is cold. If we know nothing about the function,
+ /// return false.
+ bool isColdFunction(StringRef MangledName);
};
/// Per-function PGO state. This class should generally not be used directly,