diff options
author | Dehao Chen <dehao@google.com> | 2016-02-22 22:14:14 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2016-02-22 22:14:14 +0000 |
commit | c5f76f73474499012b9559e917ec2368b659618a (patch) | |
tree | 276b18aedfce76a058ea6cfcea03b513337958de /llvm/lib/ProfileData/ProfileSummary.cpp | |
parent | 9b4880e7ecafafcbd8ca749f5985df31340e075f (diff) | |
download | bcm5719-llvm-c5f76f73474499012b9559e917ec2368b659618a.tar.gz bcm5719-llvm-c5f76f73474499012b9559e917ec2368b659618a.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: eraman, mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D17460
llvm-svn: 261582
Diffstat (limited to 'llvm/lib/ProfileData/ProfileSummary.cpp')
-rw-r--r-- | llvm/lib/ProfileData/ProfileSummary.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/ProfileSummary.cpp b/llvm/lib/ProfileData/ProfileSummary.cpp index 0e2c43e5e91..0363fbfe42d 100644 --- a/llvm/lib/ProfileData/ProfileSummary.cpp +++ b/llvm/lib/ProfileData/ProfileSummary.cpp @@ -11,6 +11,9 @@ // //===----------------------------------------------------------------------===// +#include "llvm/IR/Attributes.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/Module.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/ProfileData/ProfileCommon.h" #include "llvm/ProfileData/SampleProf.h" @@ -75,6 +78,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)), |