From 902cbaf7a1968c428fee1b4f27f0948918307971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Pasteur?= Date: Tue, 4 Oct 2011 14:34:36 +0200 Subject: [PATCH] Fixed error with memalloc and const value with when --- compiler/minils/analysis/interference.ml | 33 ++++++++++++++---------- compiler/minils/main/mls_compiler.ml | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/compiler/minils/analysis/interference.ml b/compiler/minils/analysis/interference.ml index 093e4bb..9e4f2ba 100644 --- a/compiler/minils/analysis/interference.ml +++ b/compiler/minils/analysis/interference.ml @@ -36,6 +36,8 @@ module TyEnv = end) module InterfRead = struct + exception Const_extvalue + let rec vars_ck acc = function | Con(_, _, n) -> IvarSet.add (Ivar n) acc | Cbase | Cvar { contents = Cindex _ } -> acc @@ -45,16 +47,18 @@ module InterfRead = struct | Wvar x -> Ivar x | Wfield(w, f) -> Ifield (ivar_of_extvalue w, f) | Wwhen(w, _, _) -> ivar_of_extvalue w - | Wconst _ -> assert false + | Wconst _ -> raise Const_extvalue let ivar_of_pat p = match p with | Evarpat x -> Ivar x | _ -> assert false let ivars_of_extvalues wl = - let tr_one acc w = match w.w_desc with - | Wconst _ -> acc - | _ -> (ivar_of_extvalue w)::acc + let tr_one acc w = + try + (ivar_of_extvalue w)::acc + with + | Const_extvalue -> acc in List.fold_left tr_one [] wl @@ -62,9 +66,10 @@ module InterfRead = struct (* recursive call *) let _, acc = Mls_mapfold.extvalue funs acc w in let acc = - match w.w_desc with - | Wconst _ -> acc - | _ -> IvarSet.add (ivar_of_extvalue w) acc + try + IvarSet.add (ivar_of_extvalue w) acc + with + | Const_extvalue -> acc in w, vars_ck acc w.w_ck @@ -456,14 +461,16 @@ let process_eq ({ eq_lhs = pat; eq_rhs = e } as eq) = (*affinity between inputs and outputs*) List.iter (fun inv -> List.iter (add_affinity_link_from_ivar inv) outvars) invars | Evarpat x, Efby(_, w) -> (* x = _ fby y *) - (match w.w_desc with - | Wconst _ -> () - | _ -> add_affinity_link_from_ivar (InterfRead.ivar_of_extvalue w) (Ivar x) ) + (try + add_affinity_link_from_ivar (InterfRead.ivar_of_extvalue w) (Ivar x) + with + | InterfRead.Const_extvalue -> ()) | Evarpat x, Eextvalue w -> (* Add links between variables with the same value *) - (match w.w_desc with - | Wconst _ -> () - | _ -> add_same_value_link_from_ivar (InterfRead.ivar_of_extvalue w) (Ivar x) ) + (try + add_same_value_link_from_ivar (InterfRead.ivar_of_extvalue w) (Ivar x) + with + | InterfRead.Const_extvalue -> ()) | _ -> () (* do nothing *) (** Add the special init and return equations to the dependency graph diff --git a/compiler/minils/main/mls_compiler.ml b/compiler/minils/main/mls_compiler.ml index ad8bfb8..adca0b3 100644 --- a/compiler/minils/main/mls_compiler.ml +++ b/compiler/minils/main/mls_compiler.ml @@ -53,6 +53,6 @@ let compile_program p = in (* Memory allocation *) - let p = pass "memory allocation" !do_mem_alloc Interference.program p pp in + let p = pass "Memory allocation" !do_mem_alloc Interference.program p pp in p