@@ -69698,13 +69698,13 @@ val string_of_primitive : Lam.primitive -> string
6969869698val kind_of_lambda_block : Lam_stats.boxed_nullable -> Lam.t list -> Lam_stats.kind
6969969699
6970069700val field_flatten_get :
69701- Lam.t -> Ident.t -> int -> Lam_stats.ident_tbl -> Lam.t
69701+ (unit -> Lam.t) -> Ident.t -> int -> Lam_stats.ident_tbl -> Lam.t
6970269702
6970369703
6970469704
6970569705
6970669706
69707- val alias : Lam_stats.meta ->
69707+ val alias_ident_or_global : Lam_stats.meta ->
6970869708 Ident.t -> Ident.t -> Lam_stats.kind -> Lambda.let_kind -> unit
6970969709
6971069710
@@ -69922,7 +69922,7 @@ let refine_let
6992269922 | None , _, _ ->
6992369923 Lam.let_ Strict param arg l
6992469924
69925- let alias (meta : Lam_stats.meta) (k:Ident.t) (v:Ident.t)
69925+ let alias_ident_or_global (meta : Lam_stats.meta) (k:Ident.t) (v:Ident.t)
6992669926 (v_kind : Lam_stats.kind) (let_kind : Lambda.let_kind) =
6992769927 (** treat rec as Strict, k is assigned to v
6992869928 {[ let k = v ]}
@@ -70002,13 +70002,13 @@ let field_flatten_get
7000270002 ~args:[Lam.prim ~primitive:(Pgetglobal g) ~args:[] Location.none] Location.none
7000370003 | Some (ImmutableBlock (arr, _)) ->
7000470004 begin match arr.(i) with
70005- | NA -> lam
70005+ | NA -> lam ()
7000670006 | SimpleForm l -> l
7000770007 end
7000870008 | Some (Constant (Const_block (_,_,ls))) ->
7000970009 Lam.const (List.nth ls i)
7001070010 | Some _
70011- | None -> lam
70011+ | None -> lam ()
7001270012
7001370013
7001470014(* TODO: check that if label belongs to a different
@@ -93705,12 +93705,12 @@ let collect_helper (meta : Lam_stats.meta) (lam : Lam.t) =
9370593705
9370693706 | Lprim {primitive = Pgetglobal v; args = []; _}
9370793707 ->
93708- Lam_util.alias meta ident v (Module v) kind;
93708+ Lam_util.alias_ident_or_global meta ident v (Module v) kind;
9370993709 | Lvar v
9371093710 ->
9371193711 (
9371293712 (* if Ident.global v then *)
93713- Lam_util.alias meta ident v NA kind
93713+ Lam_util.alias_ident_or_global meta ident v NA kind
9371493714 (* enven for not subsitution, it still propogate some properties *)
9371593715 (* else () *)
9371693716 )
@@ -95438,6 +95438,8 @@ val simplify_alias :
9543895438 Lam.t ->
9543995439 Lam.t
9544095440
95441+
95442+
9544195443end = struct
9544295444#1 "lam_pass_remove_alias.ml"
9544395445(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -95481,7 +95483,11 @@ let simplify_alias
9548195483 | Lvar v ->
9548295484 begin match (Ident_hashtbl.find_opt meta.alias_tbl v) with
9548395485 | None -> lam
95484- | Some v -> Lam.var v
95486+ | Some v ->
95487+ if Ident.persistent v then
95488+ Lam.prim ~primitive:(Pgetglobal v) ~args:[] Location.none
95489+ else
95490+ Lam.var v
9548595491 (* This is wrong
9548695492 currently alias table has info
9548795493 include -> Array
@@ -95501,21 +95507,26 @@ let simplify_alias
9550195507 since global module access is not the same as local module
9550295508 TODO:
9550395509 since we aliased k, so it's safe to remove it?
95510+ no, we should not shake away code just by [Ident_set.mem k meta.export_idents ]
95511+ in that case, we should provide strong guarantee that all [k] will be substitued
9550495512 *)
9550595513 let v = simpl l in
95506- if Ident_set.mem k meta.export_idents
95507- then
95508- Lam.let_ kind k g v
95514+ Lam.let_ kind k g v
9550995515 (* in this case it is preserved, but will still be simplified
9551095516 for the inner expression
9551195517 *)
95512- else v
95518+
9551395519 | Lprim {primitive = (Pfield (i,_) as primitive); args = [arg]; loc} ->
9551495520 (* ATTENTION:
9551595521 Main use case, we should detect inline all immutable block .. *)
95516- begin match (* simpl*) arg with
95517- | Lvar v ->
95518- Lam_util.field_flatten_get lam
95522+ begin match simpl arg with
95523+ | Lprim {primitive = Pgetglobal g; args= []} ->
95524+ Lam.prim
95525+ ~primitive:(Pfield(i,Lambda.Fld_na))
95526+ ~args:[Lam.prim ~primitive:(Pgetglobal g) ~args:[] Location.none]
95527+ loc
95528+ | Lvar v as l->
95529+ Lam_util.field_flatten_get (fun _ -> Lam.prim ~primitive ~args:[l] loc )
9551995530 v i meta.ident_tbl
9552095531 | _ ->
9552195532 Lam.prim ~primitive ~args:[simpl arg] loc
@@ -95739,6 +95750,8 @@ let simplify_alias
9573995750 in
9574095751 simpl lam
9574195752
95753+
95754+
9574295755end
9574395756module Ext_option : sig
9574495757#1 "ext_option.mli"
0 commit comments