| Index: frog/leg/ssa/optimize.dart
|
| diff --git a/frog/leg/ssa/optimize.dart b/frog/leg/ssa/optimize.dart
|
| index 1f1a029aeaf8bff9407fa4bc6569399abff3be31..d5eb74144383cab067ffb6d3962bf12fa8d955e0 100644
|
| --- a/frog/leg/ssa/optimize.dart
|
| +++ b/frog/leg/ssa/optimize.dart
|
| @@ -296,12 +296,19 @@ class SsaDeadPhiEliminator {
|
| }
|
|
|
| // Remove phis that are not live.
|
| - for (final block in graph.blocks) {
|
| + // Traverse in reverse order to remove phis with no uses before the
|
| + // phis that they might use.
|
| + // TODO(lrn): Handle cyclic usages.
|
| + List<HBasicBlock> blocks = graph.blocks;
|
| + for (int i = blocks.length - 1; i >= 0; i--) {
|
| + HBasicBlock block = blocks[i];
|
| HPhi current = block.phis.first;
|
| HPhi next = null;
|
| while (current != null) {
|
| next = current.next;
|
| - if (!livePhis.contains(current)) block.removePhi(current);
|
| + if (!livePhis.contains(current)) {
|
| + current.block.removePhi(current);
|
| + }
|
| current = next;
|
| }
|
| }
|
|
|