| Index: frog/leg/ssa/optimize.dart
|
| diff --git a/frog/leg/ssa/optimize.dart b/frog/leg/ssa/optimize.dart
|
| index ecc6815a488cc133ef7157c18bec858104702108..786cc178750d0ae520bbeb10726e26ac21bc6fc5 100644
|
| --- a/frog/leg/ssa/optimize.dart
|
| +++ b/frog/leg/ssa/optimize.dart
|
| @@ -295,12 +295,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;
|
| }
|
| }
|
|
|