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

Zero alloc: propagate assume on partial applications #2543

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions ocaml/lambda/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,9 @@ and transl_apply ~scopes
Lsend(k, lmet, lobj, largs @ args, pos, mode, loc, result_layout)
| Lapply ({ ap_region_close = (Rc_normal | Rc_nontail) } as ap),
(Rc_normal | Rc_nontail) ->
let loc =
map_scopes (update_assume_zero_alloc ~assume_zero_alloc) loc
in
Lapply
{ap with ap_args = ap.ap_args @ args; ap_loc = loc;
ap_region_close = pos; ap_mode = mode; ap_result_layout = result_layout }
Expand Down
20 changes: 0 additions & 20 deletions tests/backend/checkmach/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,3 @@
(alias runtest)
(action (copy test_all_opt.ml test_all_opt3.ml)))

;; Tests whose outputs differ depending on stack_allocation configuration flag.
;; This condition is not expressible in "enable_if" clause
;; because dune does not support %{config:stack_allocation} yet.
;; This test cannot be promoted automatically.

(rule
(enabled_if (= %{context_name} "main"))
(targets test_assume_stub.output)
(deps
test_assume_stub.heap_allocation.output
test_assume_stub.stack_allocation.output)
(action
(with-accepted-exit-codes 0
(bash
"if %{bin:ocamlopt.opt} -config | grep -q \"stack_allocation: true\" ;
then
cp test_assume_stub.stack_allocation.output test_assume_stub.output
else
cp test_assume_stub.heap_allocation.output test_assume_stub.output
fi"))))
2 changes: 1 addition & 1 deletion tests/backend/checkmach/test_assume_fail.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ let[@zero_alloc strict] test68 x =
So far, we haven't seen the need for it in a real example.
*)

(* CR gyorsh: the check passes on g0 and fails on g1-g3 below, even though the
(* CR gyorsh: the check passes on g0,g2,g3 and fails on g1 below, even though the
generated code is exactly the same in all four cases. The difference is because
"assume" is not propagated on partial applications. There is no misplaced
attribute warning. This is the same behavior as for "@inlined" annotations.
Expand Down
12 changes: 0 additions & 12 deletions tests/backend/checkmach/test_assume_fail.output
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,3 @@ Error: Annotation check for zero_alloc failed on function Test_assume_fail.g1 (c

File "test_assume_fail.ml", line 109, characters 10-41:
Error: called function may allocate (direct tailcall camlTest_assume_fail.f_HIDE_STAMP)

File "test_assume_fail.ml", line 112, characters 5-15:
Error: Annotation check for zero_alloc failed on function Test_assume_fail.g2 (camlTest_assume_fail.g2_HIDE_STAMP)

File "test_assume_fail.ml", line 113, characters 10-41:
Error: called function may allocate (direct tailcall camlTest_assume_fail.f_HIDE_STAMP)

File "test_assume_fail.ml", line 116, characters 5-15:
Error: Annotation check for zero_alloc failed on function Test_assume_fail.g3 (camlTest_assume_fail.g3_HIDE_STAMP)

File "test_assume_fail.ml", line 117, characters 10-63:
Error: called function may allocate (direct tailcall camlTest_assume_fail.f_HIDE_STAMP)
11 changes: 0 additions & 11 deletions tests/backend/checkmach/test_assume_stub.heap_allocation.output

This file was deleted.

Loading