Index: pkg/compiler/lib/src/cps_ir/gvn.dart |
diff --git a/pkg/compiler/lib/src/cps_ir/gvn.dart b/pkg/compiler/lib/src/cps_ir/gvn.dart |
index 02379d85c1a5e3493d6acda9c84e6beb317f30f5..e8df8391e6a4a4fbaac49e59daab96549cd21601 100644 |
--- a/pkg/compiler/lib/src/cps_ir/gvn.dart |
+++ b/pkg/compiler/lib/src/cps_ir/gvn.dart |
@@ -109,13 +109,22 @@ class GVN extends TrampolineRecursiveVisitor implements Pass { |
return next; |
} |
+ // Update effect numbers due to side effects from a static initializer. |
+ // GetLazyStatic is GVN'ed like a GetStatic, but the effects of the static |
+ // initializer occur before reading the field. |
+ if (prim is GetLazyStatic) { |
+ visit(prim); |
+ } |
+ |
// Compute the GVN vector for this computation. |
List vector = gvnVectorBuilder.make(prim, effectNumbers); |
// Update effect numbers due to side effects. |
// Do this after computing the GVN vector so the primitive's GVN is not |
- // influenced by its own side effects. |
- visit(prim); |
+ // influenced by its own side effects, except in the case of GetLazyStatic. |
+ if (prim is! GetLazyStatic) { |
+ visit(prim); |
+ } |
if (vector == null) { |
// The primitive is not GVN'able. Move on. |