summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2016-02-23 03:39:24 +0000
committerDehao Chen <dehao@google.com>2016-02-23 03:39:24 +0000
commitf84b6300445e726f318ecafd8fec4048a7af1d6e (patch)
treee845b45480f5a34a21b60416beacdbe3cb7d43c3 /llvm/lib/ProfileData
parentc00718fd8e19eb078a9d263c1e59587fbfd6b00a (diff)
downloadbcm5719-llvm-f84b6300445e726f318ecafd8fec4048a7af1d6e.tar.gz
bcm5719-llvm-f84b6300445e726f318ecafd8fec4048a7af1d6e.zip
Add prefix based function layout when profile is available.
Summary: If a function is hot, put it in text.hot section. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17532 llvm-svn: 261607
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r--llvm/lib/ProfileData/ProfileSummary.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/ProfileSummary.cpp b/llvm/lib/ProfileData/ProfileSummary.cpp
index 0e2c43e5e91..a98af2c462c 100644
--- a/llvm/lib/ProfileData/ProfileSummary.cpp
+++ b/llvm/lib/ProfileData/ProfileSummary.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/IR/Attributes.h"
+#include "llvm/IR/Function.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/ProfileData/SampleProf.h"
@@ -75,6 +77,24 @@ void ProfileSummary::computeDetailedSummary() {
}
}
+// Returns true if the function is a hot function.
+bool ProfileSummary::isFunctionHot(const Function *F) {
+ // FIXME: update when summary data is stored in module's metadata.
+ return false;
+}
+
+// Returns true if the function is a cold function.
+bool ProfileSummary::isFunctionUnlikely(const Function *F) {
+ if (F->hasFnAttribute(Attribute::Cold)) {
+ return true;
+ }
+ if (!F->getEntryCount()) {
+ return false;
+ }
+ // FIXME: update when summary data is stored in module's metadata.
+ return (*F->getEntryCount()) == 0;
+}
+
InstrProfSummary::InstrProfSummary(const IndexedInstrProf::Summary &S)
: ProfileSummary(), MaxInternalBlockCount(S.get(
IndexedInstrProf::Summary::MaxInternalBlockCount)),
OpenPOWER on IntegriCloud