summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
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/CodeGen/TargetLoweringObjectFileImpl.cpp
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/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 6756e9df384..4229741cf5a 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -34,6 +34,7 @@
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/MCValue.h"
#include "llvm/ProfileData/InstrProf.h"
+#include "llvm/ProfileData/ProfileCommon.h"
#include "llvm/Support/COFF.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ELF.h"
@@ -244,6 +245,11 @@ static StringRef getSectionPrefixForGlobal(SectionKind Kind) {
return ".data.rel.ro";
}
+static cl::opt<bool> GroupFunctionsByHotness(
+ "group-functions-by-hotness",
+ llvm::cl::desc("Partition hot/cold functions by sections prefix"),
+ cl::init(false));
+
static MCSectionELF *
selectELFSectionForGlobal(MCContext &Ctx, const GlobalValue *GV,
SectionKind Kind, Mangler &Mang,
@@ -296,6 +302,16 @@ selectELFSectionForGlobal(MCContext &Ctx, const GlobalValue *GV,
Name = getSectionPrefixForGlobal(Kind);
}
+ if (GroupFunctionsByHotness) {
+ if (const Function *F = dyn_cast<Function>(GV)) {
+ if (ProfileSummary::isFunctionHot(F)) {
+ Name += getHotSectionPrefix();
+ } else if (ProfileSummary::isFunctionUnlikely(F)) {
+ Name += getUnlikelySectionPrefix();
+ }
+ }
+ }
+
if (EmitUniqueSection && UniqueSectionNames) {
Name.push_back('.');
TM.getNameWithPrefix(Name, GV, Mang, true);
OpenPOWER on IntegriCloud