Forráskód Böngészése

[analyzer] use VUsed to mark used locals

Simon Krajewski 5 éve
szülő
commit
757410098e
2 módosított fájl, 4 hozzáadás és 3 törlés
  1. 2 1
      src/core/tType.ml
  2. 2 2
      src/optimization/analyzer.ml

+ 2 - 1
src/core/tType.ml

@@ -378,4 +378,5 @@ type flag_tclass_field =
 
 type flag_tvar =
 	| VCaptured
-	| VFinal
+	| VFinal
+	| VUsed (* used by the analyzer *)

+ 2 - 2
src/optimization/analyzer.ml

@@ -649,14 +649,14 @@ module LocalDce = struct
 
 	let rec apply ctx =
 		let is_used v =
-			Meta.has Meta.Used v.v_meta
+			has_var_flag v VUsed
 		in
 		let keep v =
 			is_used v || ((match v.v_kind with VUser _ | VInlined -> true | _ -> false) && not ctx.config.local_dce) || ExtType.has_reference_semantics v.v_type || has_var_flag v VCaptured || Meta.has Meta.This v.v_meta
 		in
 		let rec use v =
 			if not (is_used v) then begin
-				v.v_meta <- (Meta.Used,[],null_pos) :: v.v_meta;
+				add_var_flag v VUsed;
 				(try expr (get_var_value ctx.graph v) with Not_found -> ());
 				begin match Ssa.get_reaching_def ctx.graph v with
 					| None -> use (get_var_origin ctx.graph v)