From 946a1f822858e8a3165a375ec56b4793526eb3d5 Mon Sep 17 00:00:00 2001 From: Adrien Guatto Date: Mon, 30 Jan 2012 16:36:53 +0100 Subject: [PATCH] Inline extvalues: do not inline array literals. --- compiler/heptagon/transformations/normalize.ml | 2 +- compiler/minils/transformations/inline_extvalues.ml | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/heptagon/transformations/normalize.ml b/compiler/heptagon/transformations/normalize.ml index 5033bb3..b2f8c5a 100644 --- a/compiler/heptagon/transformations/normalize.ml +++ b/compiler/heptagon/transformations/normalize.ml @@ -118,7 +118,7 @@ type kind = ExtValue | Any let add context expected_kind e = let up = match e.e_desc, expected_kind with (* static arrays should be normalized to simplify code generation *) - | Econst { se_desc = Sarray _ }, ExtValue -> true + | Econst { se_desc = Sarray _ | Sarray_power _ }, ExtValue -> true | (Evar _ | Eapp ({ a_op = Efield | Etuple | Ereinit }, _, _) | Ewhen _ | Econst _) , ExtValue -> false | _ , ExtValue -> true diff --git a/compiler/minils/transformations/inline_extvalues.ml b/compiler/minils/transformations/inline_extvalues.ml index ba6cb6f..1d3ef93 100644 --- a/compiler/minils/transformations/inline_extvalues.ml +++ b/compiler/minils/transformations/inline_extvalues.ml @@ -56,9 +56,14 @@ let gather_extvalues_node nd = | _ -> false in + let inlinable w = match w.w_desc with + | Wconst { se_desc = Sarray _ | Sarray_power _ } -> false + | _ -> true + in + let gather_extvalues_eq _ env eq = let env = match eq.eq_lhs, eq.eq_rhs.e_desc with - | Evarpat x, Eextvalue w when not (is_linear w) -> Env.add x w env + | Evarpat x, Eextvalue w when not (is_linear w) && inlinable w -> Env.add x w env | _ -> env in eq, env