aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-21 18:13:02 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-21 18:13:02 +0000
commit54db30ce18663e6c2991958f3b5d18362e8e93c4 (patch)
tree4aa6442802570767398cc83ba484e97b1309bdc2 /contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp
parent35284c22e9c8348159b7ce032ea45f2cdeb65298 (diff)
parente6d1592492a3a379186bfb02bd0f4eda0669c0d5 (diff)
Merge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.
Notes
Notes: svn path=/projects/clang900-import/; revision=351344
Diffstat (limited to 'contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp')
-rw-r--r--contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index 1d70c75f2e1c..dce19d6d546e 100644
--- a/contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp
+++ b/contrib/llvm/lib/Analysis/ProfileSummaryInfo.cpp
@@ -1,9 +1,8 @@
//===- ProfileSummaryInfo.cpp - Global profile summary information --------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -61,10 +60,9 @@ static cl::opt<int> ProfileSummaryColdCount(
// Find the summary entry for a desired percentile of counts.
static const ProfileSummaryEntry &getEntryForPercentile(SummaryEntryVector &DS,
uint64_t Percentile) {
- auto Compare = [](const ProfileSummaryEntry &Entry, uint64_t Percentile) {
+ auto It = partition_point(DS, [=](const ProfileSummaryEntry &Entry) {
return Entry.Cutoff < Percentile;
- };
- auto It = std::lower_bound(DS.begin(), DS.end(), Percentile, Compare);
+ });
// The required percentile has to be <= one of the percentiles in the
// detailed summary.
if (It == DS.end())
@@ -80,7 +78,14 @@ static const ProfileSummaryEntry &getEntryForPercentile(SummaryEntryVector &DS,
bool ProfileSummaryInfo::computeSummary() {
if (Summary)
return true;
- auto *SummaryMD = M.getProfileSummary();
+ // First try to get context sensitive ProfileSummary.
+ auto *SummaryMD = M.getProfileSummary(/* IsCS */ true);
+ if (SummaryMD) {
+ Summary.reset(ProfileSummary::getFromMD(SummaryMD));
+ return true;
+ }
+ // This will actually return PSK_Instr or PSK_Sample summary.
+ SummaryMD = M.getProfileSummary(/* IsCS */ false);
if (!SummaryMD)
return false;
Summary.reset(ProfileSummary::getFromMD(SummaryMD));
@@ -89,7 +94,8 @@ bool ProfileSummaryInfo::computeSummary() {
Optional<uint64_t>
ProfileSummaryInfo::getProfileCount(const Instruction *Inst,
- BlockFrequencyInfo *BFI) {
+ BlockFrequencyInfo *BFI,
+ bool AllowSynthetic) {
if (!Inst)
return None;
assert((isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) &&
@@ -105,7 +111,7 @@ ProfileSummaryInfo::getProfileCount(const Instruction *Inst,
return None;
}
if (BFI)
- return BFI->getBlockProfileCount(Inst->getParent());
+ return BFI->getBlockProfileCount(Inst->getParent(), AllowSynthetic);
return None;
}