summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2017-12-18 20:02:43 +0000
committerTeresa Johnson <tejohnson@google.com>2017-12-18 20:02:43 +0000
commit915897e21b1286d396748cf6bf47cebdae32f41e (patch)
tree90b9dafcaead62eb05d5cf7135137c1fc30c7584 /llvm/lib/IR/Function.cpp
parentec76d9c47f5c5a2c9052e24f46e14c837c2e0af0 (diff)
downloadbcm5719-llvm-915897e21b1286d396748cf6bf47cebdae32f41e.tar.gz
bcm5719-llvm-915897e21b1286d396748cf6bf47cebdae32f41e.zip
[PGO] Fix handling of cold entry count for instrumented PGO
Summary: In r277849, getEntryCount was changed to return None when the entry count was 0, specifically for SamplePGO where it means no samples were recorded. However, for instrumentation PGO a 0 entry count should be returned directly, since it does mean that the function was completely cold. Otherwise we end up treating these functions conservatively in isFunctionEntryCold() and isColdBB(). Instead, for SamplePGO use -1 when there are no samples, and change getEntryCount to return None when the value is -1. Reviewers: danielcdh, davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41307 llvm-svn: 321018
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 1fff912ecf2..7063f6f40a3 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1333,7 +1333,9 @@ Optional<uint64_t> Function::getEntryCount() const {
if (MDS->getString().equals("function_entry_count")) {
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
uint64_t Count = CI->getValue().getZExtValue();
- if (Count == 0)
+ // A value of -1 is used for SamplePGO when there were no samples.
+ // Treat this the same as unknown.
+ if (Count == (uint64_t)-1)
return None;
return Count;
}
OpenPOWER on IntegriCloud