mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Add hasProfileSummary and has{Sample|Instrumentation}Profile methods
ProfileSummaryInfo already checks whether the module has sample profile in determining profile counts. This will also be useful in inliner to clean up threshold updates. llvm-svn: 303204
This commit is contained in:
parent
95166c2c5b
commit
9567eabb4f
@ -55,6 +55,21 @@ public:
|
|||||||
ProfileSummaryInfo(ProfileSummaryInfo &&Arg)
|
ProfileSummaryInfo(ProfileSummaryInfo &&Arg)
|
||||||
: M(Arg.M), Summary(std::move(Arg.Summary)) {}
|
: M(Arg.M), Summary(std::move(Arg.Summary)) {}
|
||||||
|
|
||||||
|
/// \brief Returns true if profile summary is available.
|
||||||
|
bool hasProfileSummary() { return computeSummary(); }
|
||||||
|
|
||||||
|
/// \brief Returns true if module \c M has sample profile.
|
||||||
|
bool hasSampleProfile() {
|
||||||
|
return hasProfileSummary() &&
|
||||||
|
Summary->getKind() == ProfileSummary::PSK_Sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Returns true if module \c M has instrumentation profile.
|
||||||
|
bool hasInstrumentationProfile() {
|
||||||
|
return hasProfileSummary() &&
|
||||||
|
Summary->getKind() == ProfileSummary::PSK_Instr;
|
||||||
|
}
|
||||||
|
|
||||||
/// Handle the invalidation of this information.
|
/// Handle the invalidation of this information.
|
||||||
///
|
///
|
||||||
/// When used as a result of \c ProfileSummaryAnalysis this method will be
|
/// When used as a result of \c ProfileSummaryAnalysis this method will be
|
||||||
|
@ -75,7 +75,7 @@ ProfileSummaryInfo::getProfileCount(const Instruction *Inst,
|
|||||||
return None;
|
return None;
|
||||||
assert((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
|
assert((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
|
||||||
"We can only get profile count for call/invoke instruction.");
|
"We can only get profile count for call/invoke instruction.");
|
||||||
if (computeSummary() && Summary->getKind() == ProfileSummary::PSK_Sample) {
|
if (hasSampleProfile()) {
|
||||||
// In sample PGO mode, check if there is a profile metadata on the
|
// In sample PGO mode, check if there is a profile metadata on the
|
||||||
// instruction. If it is present, determine hotness solely based on that,
|
// instruction. If it is present, determine hotness solely based on that,
|
||||||
// since the sampled entry count may not be accurate.
|
// since the sampled entry count may not be accurate.
|
||||||
|
@ -102,6 +102,9 @@ TEST_F(ProfileSummaryInfoTest, TestNoProfile) {
|
|||||||
Function *F = M->getFunction("f");
|
Function *F = M->getFunction("f");
|
||||||
|
|
||||||
ProfileSummaryInfo PSI = buildPSI(M.get());
|
ProfileSummaryInfo PSI = buildPSI(M.get());
|
||||||
|
EXPECT_FALSE(PSI.hasProfileSummary());
|
||||||
|
EXPECT_FALSE(PSI.hasSampleProfile());
|
||||||
|
EXPECT_FALSE(PSI.hasInstrumentationProfile());
|
||||||
// In the absence of profiles, is{Hot|Cold}X methods should always return
|
// In the absence of profiles, is{Hot|Cold}X methods should always return
|
||||||
// false.
|
// false.
|
||||||
EXPECT_FALSE(PSI.isHotCount(1000));
|
EXPECT_FALSE(PSI.isHotCount(1000));
|
||||||
@ -130,6 +133,7 @@ TEST_F(ProfileSummaryInfoTest, TestCommon) {
|
|||||||
Function *H = M->getFunction("h");
|
Function *H = M->getFunction("h");
|
||||||
|
|
||||||
ProfileSummaryInfo PSI = buildPSI(M.get());
|
ProfileSummaryInfo PSI = buildPSI(M.get());
|
||||||
|
EXPECT_TRUE(PSI.hasProfileSummary());
|
||||||
EXPECT_TRUE(PSI.isHotCount(400));
|
EXPECT_TRUE(PSI.isHotCount(400));
|
||||||
EXPECT_TRUE(PSI.isColdCount(2));
|
EXPECT_TRUE(PSI.isColdCount(2));
|
||||||
EXPECT_FALSE(PSI.isColdCount(100));
|
EXPECT_FALSE(PSI.isColdCount(100));
|
||||||
@ -144,6 +148,8 @@ TEST_F(ProfileSummaryInfoTest, InstrProf) {
|
|||||||
auto M = makeLLVMModule("InstrProf");
|
auto M = makeLLVMModule("InstrProf");
|
||||||
Function *F = M->getFunction("f");
|
Function *F = M->getFunction("f");
|
||||||
ProfileSummaryInfo PSI = buildPSI(M.get());
|
ProfileSummaryInfo PSI = buildPSI(M.get());
|
||||||
|
EXPECT_TRUE(PSI.hasProfileSummary());
|
||||||
|
EXPECT_TRUE(PSI.hasInstrumentationProfile());
|
||||||
|
|
||||||
BasicBlock &BB0 = F->getEntryBlock();
|
BasicBlock &BB0 = F->getEntryBlock();
|
||||||
BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
|
BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
|
||||||
@ -174,6 +180,8 @@ TEST_F(ProfileSummaryInfoTest, SampleProf) {
|
|||||||
auto M = makeLLVMModule("SampleProfile");
|
auto M = makeLLVMModule("SampleProfile");
|
||||||
Function *F = M->getFunction("f");
|
Function *F = M->getFunction("f");
|
||||||
ProfileSummaryInfo PSI = buildPSI(M.get());
|
ProfileSummaryInfo PSI = buildPSI(M.get());
|
||||||
|
EXPECT_TRUE(PSI.hasProfileSummary());
|
||||||
|
EXPECT_TRUE(PSI.hasSampleProfile());
|
||||||
|
|
||||||
BasicBlock &BB0 = F->getEntryBlock();
|
BasicBlock &BB0 = F->getEntryBlock();
|
||||||
BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
|
BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user