summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorChijun Sima <simachijun@gmail.com>2018-08-03 06:51:35 +0000
committerChijun Sima <simachijun@gmail.com>2018-08-03 06:51:35 +0000
commitc72ff1011d62cfc6ee3c8f96eacacf654a3308d4 (patch)
tree3950150eb047feb795b18953f906dbaa8e778a1d /llvm/lib/IR
parente902b7d0b0f87489b52953ea83b92bf66039f452 (diff)
downloadbcm5719-llvm-c72ff1011d62cfc6ee3c8f96eacacf654a3308d4.tar.gz
bcm5719-llvm-c72ff1011d62cfc6ee3c8f96eacacf654a3308d4.zip
[Dominators] Refine the logic of recalculate() in the DomTreeUpdater
Summary: This patch refines the logic of `recalculate()` in the `DomTreeUpdater` in the following two aspects: 1. Previously, `recalculate()` tests whether there are pending updates/BBs awaiting deletion and then do recalculation under Lazy UpdateStrategy; and do recalculation immediately under Eager UpdateStrategy. (The former behavior is inherited from the `DeferredDominance` class). This is an inconsistency between two strategies and there is no obvious reason to do this. So the behavior is changed to always recalculate available trees when calling `recalculate()`. 2. Fix the issue of when DTU under Lazy UpdateStrategy holds nothing but with BBs awaiting deletion, after calling `recalculate()`, BBs awaiting deletion aren't flushed. An additional unittest is added to cover this case. Reviewers: kuhar, dmgreen, brzycki, grosser, davide Reviewed By: kuhar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50173 llvm-svn: 338822
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DomTreeUpdater.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/llvm/lib/IR/DomTreeUpdater.cpp b/llvm/lib/IR/DomTreeUpdater.cpp
index f035a86edda..b72c1b77c2c 100644
--- a/llvm/lib/IR/DomTreeUpdater.cpp
+++ b/llvm/lib/IR/DomTreeUpdater.cpp
@@ -152,39 +152,34 @@ bool DomTreeUpdater::forceFlushDeletedBB() {
return true;
}
-bool DomTreeUpdater::recalculate(Function &F) {
- if (!DT && !PDT)
- return false;
+void DomTreeUpdater::recalculate(Function &F) {
if (Strategy == UpdateStrategy::Eager) {
if (DT)
DT->recalculate(F);
if (PDT)
PDT->recalculate(F);
- return true;
+ return;
}
+ // There is little performance gain if we pend the recalculation under
+ // Lazy UpdateStrategy so we recalculate available trees immediately.
+
// Prevent forceFlushDeletedBB() from erasing DomTree or PostDomTree nodes.
IsRecalculatingDomTree = IsRecalculatingPostDomTree = true;
// Because all trees are going to be up-to-date after recalculation,
// flush awaiting deleted BasicBlocks.
- if (forceFlushDeletedBB() || hasPendingUpdates()) {
- if (DT)
- DT->recalculate(F);
- if (PDT)
- PDT->recalculate(F);
-
- // Resume forceFlushDeletedBB() to erase DomTree or PostDomTree nodes.
- IsRecalculatingDomTree = IsRecalculatingPostDomTree = false;
- PendDTUpdateIndex = PendPDTUpdateIndex = PendUpdates.size();
- dropOutOfDateUpdates();
- return true;
- }
+ forceFlushDeletedBB();
+ if (DT)
+ DT->recalculate(F);
+ if (PDT)
+ PDT->recalculate(F);
// Resume forceFlushDeletedBB() to erase DomTree or PostDomTree nodes.
IsRecalculatingDomTree = IsRecalculatingPostDomTree = false;
- return false;
+ PendDTUpdateIndex = PendPDTUpdateIndex = PendUpdates.size();
+ dropOutOfDateUpdates();
}
bool DomTreeUpdater::hasPendingUpdates() const {
OpenPOWER on IntegriCloud