diff options
author | Alain Frisch <alain@frisch.fr> | 2012-01-18 08:31:11 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2012-01-18 08:31:11 +0000 |
commit | c45bcb892d78f3182acb2805aef7ec6e23cce42a (patch) | |
tree | b92b5d6becb9e67a198bc2e070d748eeef62bc3d /bytecomp/simplif.ml | |
parent | cdbb84ec682704379bac21a633cbd2b9e93b35a8 (diff) | |
parent | 869feeb00704e0640c45ffe6aee6cc13e4077f79 (diff) | |
download | ocaml-unused_declarations.tar.gz |
Synchronize with trunk.unused_declarations
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unused_declarations@12034 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'bytecomp/simplif.ml')
-rw-r--r-- | bytecomp/simplif.ml | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bytecomp/simplif.ml b/bytecomp/simplif.ml index e26524e676..d5f85fc3a8 100644 --- a/bytecomp/simplif.ml +++ b/bytecomp/simplif.ml @@ -260,6 +260,9 @@ let simplify_exits lam = let simplify_lets lam = + (* Disable optimisations for bytecode compilation with -g flag *) + let optimize = !Clflags.native_code || not !Clflags.debug in + (* First pass: count the occurrences of all let-bound identifiers *) let occ = (Hashtbl.create 83: (Ident.t, int ref) Hashtbl.t) in @@ -307,7 +310,7 @@ let simplify_lets lam = count bv l1; List.iter (count bv) ll | Lfunction(kind, params, l) -> count Tbl.empty l - | Llet(str, v, Lvar w, l2) when not !Clflags.debug -> + | Llet(str, v, Lvar w, l2) when optimize -> (* v will be replaced by w in l2, so each occurrence of v in l2 increases w's refcount *) count (bind_var bv v) l2; @@ -361,7 +364,6 @@ let simplify_lets lam = and substitute the bindings of variables used exactly once. *) let subst = Hashtbl.create 83 in - let optimize = !Clflags.native_code || not !Clflags.debug in (* This (small) optimisation is always legal, it may uncover some tail call later on. *) |