瀏覽代碼

[analyzer] set dominator of blocks that ConstPropagation infers to be unreachable

Simon Krajewski 9 年之前
父節點
當前提交
60668b0c3b
共有 2 個文件被更改,包括 14 次插入0 次删除
  1. 1 0
      src/optimization/analyzer.ml
  2. 13 0
      tests/unit/src/unit/issues/Issue4997.hx

+ 1 - 0
src/optimization/analyzer.ml

@@ -478,6 +478,7 @@ module ConstPropagation = DataFlow(struct
 				Type.map_expr commit e
 		in
 		Graph.iter_dom_tree ctx.graph (fun bb ->
+			if not (List.exists (fun edge -> has_flag edge FlagExecutable) bb.bb_incoming) then bb.bb_dominator <- ctx.graph.Graph.g_unreachable;
 			dynarray_map commit bb.bb_el
 		);
 end)

+ 13 - 0
tests/unit/src/unit/issues/Issue4997.hx

@@ -0,0 +1,13 @@
+package unit.issues;
+
+class Issue4997 extends Test {
+	function test() {
+		var b = true;
+		if (b) {
+			return;
+		}
+
+		var a = [];
+		a[0] = true;
+	}
+}