Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrevert #1131 and fix a Cmm unboxing bug #1284

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions backend/cmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,10 @@ let iter_shallow_tail f = function
f e1;
f e2;
true
| Cregion e ->
f e;
true
| Ctail e ->
f e;
true
| Cexit _ | Cop (Craise _, _, _) ->
true
| Cregion _
| Ctail _
stedolan marked this conversation as resolved.
Show resolved Hide resolved
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down Expand Up @@ -365,12 +361,10 @@ let map_shallow_tail ?kind f = function
| Ctrywith(e1, kind', id, e2, dbg, kind_before) ->
Ctrywith(f e1, kind', id, f e2, dbg,
Option.value kind ~default:kind_before)
| Cregion e ->
Cregion(f e)
| Ctail e ->
Ctail(f e)
| Cexit _ | Cop (Craise _, _, _) as cmm ->
cmm
| Cregion _
| Ctail _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand All @@ -382,6 +376,8 @@ let map_shallow_tail ?kind f = function

let map_tail ?kind f =
let rec loop = function
| Cregion _
| Ctail _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down
3 changes: 2 additions & 1 deletion backend/cmmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ let rec is_unboxed_number_cmm = function
No_unboxing
end
| Cexit _ | Cop (Craise _, _, _) -> No_result
| Csequence (_, a) | Cregion a | Ctail a
| Cregion _ | Ctail _ -> No_unboxing
| Csequence (_, a)
| Clet (_, _, a) | Cphantom_let (_, _, a) | Clet_mut (_, _, _, a) ->
is_unboxed_number_cmm a
| Cconst_int _
Expand Down
16 changes: 6 additions & 10 deletions ocaml/asmcomp/cmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,10 @@ let iter_shallow_tail f = function
f e1;
f e2;
true
| Cregion e ->
f e;
true
| Ctail e ->
f e;
true
| Cexit _ | Cop (Craise _, _, _) ->
true
| Cregion _
| Ctail _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down Expand Up @@ -314,12 +310,10 @@ let map_shallow_tail ?kind f = function
| Ctrywith(e1, id, e2, dbg, kind_before) ->
Ctrywith(f e1, id, f e2, dbg,
Option.value kind ~default:kind_before)
| Cregion e ->
Cregion(f e)
| Ctail e ->
Ctail(f e)
| Cexit _ | Cop (Craise _, _, _) as cmm ->
cmm
| Cregion _
| Ctail _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand All @@ -331,6 +325,8 @@ let map_shallow_tail ?kind f = function

let map_tail ?kind f =
let rec loop = function
| Cregion _
| Ctail _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down
23 changes: 23 additions & 0 deletions ocaml/testsuite/tests/typing-local/regression_cmm_unboxing.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(* TEST *)

(* Regression test for a bad interaction between Cmm unboxing
and regions present after inlining *)

external opaque_local : local_ 'a -> local_ 'a = "%opaque"

let[@inline always] reg k c f =
let _ = opaque_local (local_ ref 42) in
if c then
f ()
else
Int64.add 1L k

let[@inline never] h k c f =
let n = reg k c f in
Int64.add 1L n

let () =
let f () = 2L in
Printf.printf "%Ld %Ld\n"
(h 42L false f)
(h 42L true f)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
44 3