summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/nodes.cc')
-rw-r--r--compiler/optimizing/nodes.cc42
1 files changed, 21 insertions, 21 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 01eb2d7f86..a6390af1f2 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -117,9 +117,24 @@ void HGraph::BuildDominatorTree() {
// dominators and the reverse post order.
SimplifyCFG();
- // (5) Compute the immediate dominator of each block. We visit
- // the successors of a block only when all its forward branches
- // have been processed.
+ // (5) Compute the dominance information and the reverse post order.
+ ComputeDominanceInformation();
+}
+
+void HGraph::ClearDominanceInformation() {
+ for (HReversePostOrderIterator it(*this); !it.Done(); it.Advance()) {
+ it.Current()->ClearDominanceInformation();
+ }
+ reverse_post_order_.Reset();
+}
+
+void HBasicBlock::ClearDominanceInformation() {
+ dominated_blocks_.Reset();
+ dominator_ = nullptr;
+}
+
+void HGraph::ComputeDominanceInformation() {
+ DCHECK(reverse_post_order_.IsEmpty());
GrowableArray<size_t> visits(arena_, blocks_.Size());
visits.SetSize(blocks_.Size());
reverse_post_order_.Add(entry_block_);
@@ -1035,9 +1050,8 @@ HBasicBlock* HBasicBlock::SplitAfter(HInstruction* cursor) {
bool HBasicBlock::IsSingleGoto() const {
HLoopInformation* loop_info = GetLoopInformation();
- // TODO: Remove the null check b/19084197.
- return GetFirstInstruction() != nullptr
- && GetPhis().IsEmpty()
+ DCHECK(EndsWithControlFlowInstruction());
+ return GetPhis().IsEmpty()
&& GetFirstInstruction() == GetLastInstruction()
&& GetLastInstruction()->IsGoto()
// Back edges generate the suspend check.
@@ -1133,8 +1147,7 @@ void HBasicBlock::DisconnectAndDelete() {
}
predecessors_.Reset();
- // Disconnect the block from its successors and update their dominators
- // and phis.
+ // Disconnect the block from its successors and update their phis.
for (size_t i = 0, e = successors_.Size(); i < e; ++i) {
HBasicBlock* successor = successors_.Get(i);
// Delete this block from the list of predecessors.
@@ -1145,19 +1158,6 @@ void HBasicBlock::DisconnectAndDelete() {
// dominator of `successor` which violates the order DCHECKed at the top.
DCHECK(!successor->predecessors_.IsEmpty());
- // Recompute the successor's dominator.
- HBasicBlock* old_dominator = successor->GetDominator();
- HBasicBlock* new_dominator = successor->predecessors_.Get(0);
- for (size_t j = 1, f = successor->predecessors_.Size(); j < f; ++j) {
- new_dominator = graph_->FindCommonDominator(
- new_dominator, successor->predecessors_.Get(j));
- }
- if (old_dominator != new_dominator) {
- successor->SetDominator(new_dominator);
- old_dominator->RemoveDominatedBlock(successor);
- new_dominator->AddDominatedBlock(successor);
- }
-
// Remove this block's entries in the successor's phis.
if (successor->predecessors_.Size() == 1u) {
// The successor has just one predecessor left. Replace phis with the only