diff options
author | Dehao Chen <dehao@google.com> | 2016-09-21 16:26:51 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2016-09-21 16:26:51 +0000 |
commit | 160fbc3f9544d8223733fa05f23a64558099ffdf (patch) | |
tree | fbfe691fb049d335a71e32de29a83309be5243e5 /llvm/lib/Transforms | |
parent | a95e8bb7eddc0ace1a63053cd15062421d61e37d (diff) | |
download | bcm5719-llvm-160fbc3f9544d8223733fa05f23a64558099ffdf.tar.gz bcm5719-llvm-160fbc3f9544d8223733fa05f23a64558099ffdf.zip |
Change the basic block weight calculation algorithm to use max instead of voting.
Summary: Now that we have more precise debug info, we should change back to use maximum to get basic block weight.
Reviewers: dnovillo
Subscribers: andreadb, llvm-commits
Differential Revision: https://reviews.llvm.org/D24788
llvm-svn: 282084
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/SampleProfile.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 0594063f0c7..dd918965894 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -513,24 +513,16 @@ SampleProfileLoader::getInstWeight(const Instruction &Inst) const { /// \returns the weight for \p BB. ErrorOr<uint64_t> SampleProfileLoader::getBlockWeight(const BasicBlock *BB) const { - DenseMap<uint64_t, uint64_t> CM; + uint64_t Max = 0; + bool HasWeight = false; for (auto &I : BB->getInstList()) { const ErrorOr<uint64_t> &R = getInstWeight(I); - if (R) - CM[R.get()]++; - } - if (CM.size() == 0) - return std::error_code(); - uint64_t W = 0, C = 0; - for (const auto &C_W : CM) { - if (C_W.second == W) { - C = std::max(C, C_W.first); - } else if (C_W.second > W) { - C = C_W.first; - W = C_W.second; + if (R) { + Max = std::max(Max, R.get()); + HasWeight = true; } } - return C; + return HasWeight ? ErrorOr<uint64_t>(Max) : std::error_code(); } /// \brief Compute and store the weights of every basic block. |