Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1949)

Unified Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 985913002: Remove more null receiver guards. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 04ac400d3229acfbe04644275d195a19cc9854be..654cebac035bdb3d7fd3f4e3962b78ea206645a6 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -1012,14 +1012,27 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase {
if (current.canThrow() || current.sideEffects.hasSideEffects()) {
return false;
}
- if (current.next == null && current is HGoto) {
- // We do not merge blocks in our SSA graph, so if this block
- // just jumps to a single predecessor, visit this predecessor.
- assert(current.block.successors.length == 1);
- current = current.block.successors[0].first;
- } else {
- current = current.next;
+ HInstruction next = current.next;
+ if (next == null) {
+ // We do not merge blocks in our SSA graph, so if this block just jumps
+ // to a single successor, visit the successor, avoiding back-edges.
+ HBasicBlock successor;
+ if (current is HGoto) {
+ successor = current.block.successors.single;
+ } else if (current is HIf) {
+ // We also leave HIf nodes in place when one branch is dead.
+ HInstruction condition = current.inputs.first;
+ if (condition is HConstant) {
+ bool isTrue = condition.constant.isTrue;
+ successor = isTrue ? current.thenBlock : current.elseBlock;
+ assert(!analyzer.isDeadBlock(successor));
+ }
+ }
+ if (successor != null && successor.id > current.block.id) {
+ next = successor.first;
+ }
}
+ current = next;
} while (current != null);
return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698