Browse Source

send all types to analyzer for purity inference

see #12224
Simon Krajewski 4 months ago
parent
commit
16afc2b0c1
2 changed files with 7 additions and 7 deletions
  1. 4 4
      src/filters/filters.ml
  2. 3 3
      src/optimization/analyzer.ml

+ 4 - 4
src/filters/filters.ml

@@ -417,7 +417,7 @@ let might_need_cf_unoptimized c cf =
 	| _ ->
 	| _ ->
 		has_class_field_flag cf CfGeneric
 		has_class_field_flag cf CfGeneric
 
 
-let run_safe_filters ectx com (scom : SafeCom.t) new_types_array cv_wrapper_impl rename_locals_config pool =
+let run_safe_filters ectx com (scom : SafeCom.t) all_types_array new_types_array cv_wrapper_impl rename_locals_config pool =
 	let detail_times = Timer.level_from_define scom.defines Define.FilterTimes in
 	let detail_times = Timer.level_from_define scom.defines Define.FilterTimes in
 
 
 	let filters_before_inlining = [
 	let filters_before_inlining = [
@@ -454,7 +454,7 @@ let run_safe_filters ectx com (scom : SafeCom.t) new_types_array cv_wrapper_impl
 	Dump.maybe_generate_dump com AfterInlining;
 	Dump.maybe_generate_dump com AfterInlining;
 
 
 	Common.enter_stage com CAnalyzerStart;
 	Common.enter_stage com CAnalyzerStart;
-	if scom.platform <> Cross then Analyzer.Run.run_on_types scom pool new_types_array;
+	if scom.platform <> Cross then Analyzer.Run.run_on_types scom pool all_types_array new_types_array;
 	Dump.maybe_generate_dump com AfterAnalyzing;
 	Dump.maybe_generate_dump com AfterAnalyzing;
 	Common.enter_stage com CAnalyzerDone;
 	Common.enter_stage com CAnalyzerDone;
 
 
@@ -491,6 +491,7 @@ let run com ectx main before_destruction =
 		not cached
 		not cached
 	) com.types in
 	) com.types in
 	let new_types_array = Array.of_list new_types in
 	let new_types_array = Array.of_list new_types in
+	let all_types_array = Array.of_list com.types in
 
 
 	(* IMPORTANT:
 	(* IMPORTANT:
 	    There may be types in new_types which have already been post-processed, but then had their m_processed flag unset
 	    There may be types in new_types which have already been post-processed, but then had their m_processed flag unset
@@ -506,7 +507,7 @@ let run com ectx main before_destruction =
 	let rename_locals_config = RenameVars.init scom.SafeCom.platform_config com.types in
 	let rename_locals_config = RenameVars.init scom.SafeCom.platform_config com.types in
 	Parallel.run_in_new_pool scom.timer_ctx (fun pool ->
 	Parallel.run_in_new_pool scom.timer_ctx (fun pool ->
 		SafeCom.run_with_scom com scom (fun () ->
 		SafeCom.run_with_scom com scom (fun () ->
-			run_safe_filters ectx com scom new_types_array cv_wrapper_impl rename_locals_config pool
+			run_safe_filters ectx com scom all_types_array new_types_array cv_wrapper_impl rename_locals_config pool
 		)
 		)
 	);
 	);
 	with_timer com.timer_ctx detail_times "callbacks" None (fun () ->
 	with_timer com.timer_ctx detail_times "callbacks" None (fun () ->
@@ -528,5 +529,4 @@ let run com ectx main before_destruction =
 		com.callbacks#run com.error_ext com.callbacks#get_after_save;
 		com.callbacks#run com.error_ext com.callbacks#get_after_save;
 	);
 	);
 	before_destruction();
 	before_destruction();
-	let all_types_array = Array.of_list com.types in
 	destruction com scom ectx detail_times main rename_locals_config com.types all_types_array
 	destruction com scom ectx detail_times main rename_locals_config com.types all_types_array

+ 3 - 3
src/optimization/analyzer.ml

@@ -1184,13 +1184,13 @@ module Run = struct
 		| TTypeDecl _ -> ()
 		| TTypeDecl _ -> ()
 		| TAbstractDecl _ -> ()
 		| TAbstractDecl _ -> ()
 
 
-	let run_on_types scom pool types =
+	let run_on_types scom pool all_types new_types =
 		let config = get_base_config scom in
 		let config = get_base_config scom in
 		with_timer scom.timer_ctx config.detail_times None ["other"] (fun () ->
 		with_timer scom.timer_ctx config.detail_times None ["other"] (fun () ->
 			if config.optimize && config.purity_inference then
 			if config.optimize && config.purity_inference then
-				with_timer scom.timer_ctx config.detail_times None ["optimize";"purity-inference"] (fun () -> Purity.infer types);
+				with_timer scom.timer_ctx config.detail_times None ["optimize";"purity-inference"] (fun () -> Purity.infer all_types);
 			let exc_out = Atomic.make None in
 			let exc_out = Atomic.make None in
-			Parallel.ParallelArray.iter pool (run_on_type scom exc_out pool config) types;
+			Parallel.ParallelArray.iter pool (run_on_type scom exc_out pool config) new_types;
 			check_exc_out exc_out
 			check_exc_out exc_out
 		)
 		)
 end
 end