[llvm] e38c8e7 - [BranchProbabilityInfo] Remove block handles in eraseBlock()
Yevgeny Rouban via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 22:14:35 PST 2020
Author: Yevgeny Rouban
Date: 2020-11-06T13:13:58+07:00
New Revision: e38c8e7590a0a82be24f3bcc5b87736498f2cb07
URL: https://github.com/llvm/llvm-project/commit/e38c8e7590a0a82be24f3bcc5b87736498f2cb07
DIFF: https://github.com/llvm/llvm-project/commit/e38c8e7590a0a82be24f3bcc5b87736498f2cb07.diff
LOG: [BranchProbabilityInfo] Remove block handles in eraseBlock()
BranchProbabilityInfo::eraseBlock() is a public method and
can be called without deleting the block itself.
This method is made remove the correspondent tracking handle
from BranchProbabilityInfo::Handles along with
the probabilities of the block. Handles.erase() call is moved
to eraseBlock().
In setEdgeProbability() we need to add the block handle only once.
Reviewed By: kazu
Differential Revision: https://reviews.llvm.org/D90838
Added:
Modified:
llvm/include/llvm/Analysis/BranchProbabilityInfo.h
llvm/lib/Analysis/BranchProbabilityInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
index b878eca7616b..78fe4adb5ebc 100644
--- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -213,7 +213,6 @@ class BranchProbabilityInfo {
void deleted() override {
assert(BPI != nullptr);
BPI->eraseBlock(cast<BasicBlock>(getValPtr()));
- BPI->Handles.erase(*this);
}
public:
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index 2b533b5c5ec0..ad8817d1b1a6 100644
--- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -1138,10 +1138,10 @@ void BranchProbabilityInfo::setEdgeProbability(
if (Probs.size() == 0)
return; // Nothing to set.
+ Handles.insert(BasicBlockCallbackVH(Src, this));
uint64_t TotalNumerator = 0;
for (unsigned SuccIdx = 0; SuccIdx < Probs.size(); ++SuccIdx) {
this->Probs[std::make_pair(Src, SuccIdx)] = Probs[SuccIdx];
- Handles.insert(BasicBlockCallbackVH(Src, this));
LLVM_DEBUG(dbgs() << "set edge " << Src->getName() << " -> " << SuccIdx
<< " successor probability to " << Probs[SuccIdx]
<< "\n");
@@ -1177,6 +1177,7 @@ void BranchProbabilityInfo::eraseBlock(const BasicBlock *BB) {
// a pair (BB, N) if there is no data for (BB, N-1) because the data is always
// set for all successors from 0 to M at once by the method
// setEdgeProbability().
+ Handles.erase(BasicBlockCallbackVH(BB, this));
for (unsigned I = 0;; ++I) {
auto MapI = Probs.find(std::make_pair(BB, I));
if (MapI == Probs.end()) {
More information about the llvm-commits
mailing list