[PATCH] D90838: [BranchProbabilityInfo] Remove block handles in eraseBlock()
Yevgeny Rouban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 04:39:19 PST 2020
yrouban created this revision.
yrouban added reviewers: kazu, wmi, efriedma, ebrevnov.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
yrouban requested review of this revision.
//BranchProbabilityInfo::eraseBlock()// is a public method and can be called without deleting the block itself.
I believe this method should remove the correspondent tracking handle from //BranchProbabilityInfo::Handles// along with the probabilities of the block. So I propose to move Handles.erase() call to //eraseBlock()//.
In //setEdgeProbability()// we need to add the block handle only once.
https://reviews.llvm.org/D90838
Files:
llvm/include/llvm/Analysis/BranchProbabilityInfo.h
llvm/lib/Analysis/BranchProbabilityInfo.cpp
Index: llvm/lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -1138,10 +1138,10 @@
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 @@
// 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 public method
// setEdgeProbability().
+ Handles.erase(BasicBlockCallbackVH(BB, this));
for (unsigned I = 0; true; ++I) {
auto MapI = Probs.find(std::make_pair(BB, I));
if (MapI == Probs.end()) {
Index: llvm/include/llvm/Analysis/BranchProbabilityInfo.h
===================================================================
--- llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -213,7 +213,6 @@
void deleted() override {
assert(BPI != nullptr);
BPI->eraseBlock(cast<BasicBlock>(getValPtr()));
- BPI->Handles.erase(*this);
}
public:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90838.303083.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201105/b1a7174a/attachment.bin>
More information about the llvm-commits
mailing list