diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1999-03-04 09:49:06 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1999-03-04 09:49:06 +0000 |
commit | 2cdc58017cd22cb4c98ca9573e363f2824c763a4 (patch) | |
tree | 4ec60d5f17e419cffcfd6868be97d7dcf74c4ed5 | |
parent | bfeac0e08d86a0f032cb8b857905924e227d2874 (diff) |
Elimination des arguments inutilises lors de l'inlining (Mark Hayden)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2328 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | asmcomp/closure.ml | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/asmcomp/closure.ml b/asmcomp/closure.ml index 9f04df72e..fbdee07b7 100644 --- a/asmcomp/closure.ml +++ b/asmcomp/closure.ml @@ -269,13 +269,23 @@ let is_simple_argument = function | Uconst(Const_pointer _) -> true | _ -> false +let no_effects = function + Uclosure _ -> true + | Uconst(Const_base(Const_string _)) -> true + | u -> is_simple_argument u + let rec bind_params subst params args body = match (params, args) with ([], []) -> substitute subst body | (p1 :: pl, a1 :: al) -> - if is_simple_argument a1 - then bind_params (Tbl.add p1 a1 subst) pl al body - else Ulet(p1, a1, bind_params subst pl al body) + if is_simple_argument a1 then + bind_params (Tbl.add p1 a1 subst) pl al body + else begin + let body' = bind_params subst pl al body in + if occurs_var p1 body then Ulet(p1, a1, body') + else if no_effects a1 then body' + else Usequence(a1, body') + end | (_, _) -> assert false (* Check if a lambda term is ``pure'', |