Browse Source

[analyzer] only sweep blocks that we marked (closes #5073)

Simon Krajewski 9 years ago
parent
commit
d888265337
2 changed files with 19 additions and 3 deletions
  1. 4 3
      src/optimization/analyzer.ml
  2. 15 0
      tests/unit/src/unit/issues/Issue5073.hx

+ 4 - 3
src/optimization/analyzer.ml

@@ -851,8 +851,9 @@ module LocalDce = struct
 			| _ ->
 				Type.iter expr e
 		in
-
+		let bb_marked = ref [] in
 		let rec mark bb =
+			bb_marked := bb :: !bb_marked;
 			DynArray.iter expr bb.bb_el;
 			DynArray.iter expr bb.bb_phi;
 			List.iter (fun edge ->
@@ -875,9 +876,9 @@ module LocalDce = struct
 			| _ ->
 				Type.map_expr sweep e
 		in
-		Graph.iter_dom_tree ctx.graph (fun bb ->
+		List.iter (fun bb ->
 			dynarray_map sweep bb.bb_el
-		);
+		) !bb_marked;
 end
 
 module Debug = struct

+ 15 - 0
tests/unit/src/unit/issues/Issue5073.hx

@@ -0,0 +1,15 @@
+package unit.issues;
+
+class Issue5073 extends Test {
+	function test() {
+		function dontRunMe() {
+			var done = false;
+			while (!done) {
+				trace(Math.random() - 1);
+			}
+		}
+		pretendToRun(dontRunMe);
+	}
+
+	static function pretendToRun(f) { }
+}