Skip to content

Commit

Permalink
Squashed 'ocaml/' changes from a7d005a6e5..6c5197b8d9
Browse files Browse the repository at this point in the history
6c5197b8d9 Merge pull request ocaml-flambda#166 from mshinwell/merge-flambda-backend-2023-04-28
0c3dcf956c Fix for ocamldoc
09b9e1cb46 Fix for -zero-alloc-check
71e5e07631 Compilation fixes after merge
bf662571ee Merge flambda-backend changes
a2556fc75f Add `[%exclave]` support (ocaml-flambda#51)
ebe9576b0a Add data race freedom proposal (ocaml-flambda#161)
3f3fc49e0d Merge pull request ocaml-flambda#159 from riaqn/merge-backend
6c635dc542 minor changes after merge
99a0d85320 Merge flambda-backend changes
264246310a Include the modes of values in debugging information (ocaml-flambda#153)
4ecc8a4f17 Remove i386 CI check (ocaml-flambda#155)

git-subtree-dir: ocaml
git-subtree-split: 6c5197b8d9812079036a83fd74ac5ea752735c6e
  • Loading branch information
mshinwell committed Apr 28, 2023
1 parent 4d0fa29 commit 235c9c6
Show file tree
Hide file tree
Showing 63 changed files with 2,066 additions and 263 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ jobs:
use_runtime: d
ocamlrunparam: "v=0,V=1"

- name: i386
config: --enable-stack-allocation=no CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
os: ubuntu-20.04
ocamlparam: ''
boot_config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
boot_cachekey: 32bit

env:
J: "3"

Expand All @@ -36,11 +29,6 @@ jobs:
if: matrix.os == 'macos-latest'
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install parallel

- name: Install GCC 32-bit libraries
if: matrix.name == 'i386'
run: |
sudo apt-get install gcc-multilib gfortran-multilib
- name: Checkout the ocaml-jst repo
uses: actions/checkout@master
with:
Expand All @@ -61,13 +49,6 @@ jobs:
path: 'ocaml-414'
ref: '4.14'

- name: Setup 32-bit C compiler
if: matrix.name == 'i386' && steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ocaml-414/_install/bin
{ echo '#!/bin/sh'; echo 'exec gcc -m32 "$@"'; } > ocaml-414/_install/bin/cc32
chmod +x ocaml-414/_install/bin/cc32
- name: Build OCaml 4.14
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ocaml-414
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/afl_instrument.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ and instrument = function
Ccatch (isrec, cases, instrument body, kind)
| Cexit (ex, args) -> Cexit (ex, List.map instrument args)
| Cregion e -> Cregion (instrument e)
| Ctail e -> Ctail (instrument e)
| Cexclave e -> Cexclave (instrument e)

(* these are base cases and have no logging *)
| Cconst_int _ | Cconst_natint _ | Cconst_float _
Expand Down
14 changes: 7 additions & 7 deletions asmcomp/cmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ type expression =
| Ctrywith of expression * Backend_var.With_provenance.t * expression
* Debuginfo.t * kind_for_unboxing
| Cregion of expression
| Ctail of expression
| Cexclave of expression

type codegen_option =
| Reduce_code_size
Expand Down Expand Up @@ -270,7 +270,7 @@ let iter_shallow_tail f = function
| Cexit _ | Cop (Craise _, _, _) ->
true
| Cregion _
| Ctail _
| Cexclave _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down Expand Up @@ -312,7 +312,7 @@ let map_shallow_tail ?kind f = function
| Cexit _ | Cop (Craise _, _, _) as cmm ->
cmm
| Cregion _
| Ctail _
| Cexclave _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand All @@ -325,7 +325,7 @@ let map_shallow_tail ?kind f = function
let map_tail ?kind f =
let rec loop = function
| Cregion _
| Ctail _
| Cexclave _
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down Expand Up @@ -367,7 +367,7 @@ let iter_shallow f = function
f e1; f e2
| Cregion e ->
f e
| Ctail e ->
| Cexclave e ->
f e
| Cconst_int _
| Cconst_natint _
Expand Down Expand Up @@ -404,8 +404,8 @@ let map_shallow f = function
Ctrywith (f e1, id, f e2, dbg, value_kind)
| Cregion e ->
Cregion (f e)
| Ctail e ->
Ctail (f e)
| Cexclave e ->
Cexclave (f e)
| Cconst_int _
| Cconst_natint _
| Cconst_float _
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/cmm.mli
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ type expression =
| Ctrywith of expression * Backend_var.With_provenance.t * expression
* Debuginfo.t * kind_for_unboxing
| Cregion of expression
| Ctail of expression
| Cexclave of expression

type codegen_option =
| Reduce_code_size
Expand Down
12 changes: 4 additions & 8 deletions asmcomp/cmm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,11 @@ let rec unbox_float dbg =
map_tail ~kind:Any
(function
| Cop (Capply (_, Rc_close_at_apply), _, _) -> raise Exit
| Ctail e -> Ctail (unbox_float dbg e)
| e -> unbox_float dbg e)
e
with
| e -> Cregion e
| exception Exit -> Cop (Cload (Double, Immutable), [cmm], dbg))
| Ctail e -> Ctail (unbox_float dbg e)
| cmm -> Cop(Cload (Double, Immutable), [cmm], dbg)
)

Expand Down Expand Up @@ -1309,13 +1307,11 @@ let rec unbox_int dbg bi =
map_tail ~kind:Any
(function
| Cop (Capply (_, Rc_close_at_apply), _, _) -> raise Exit
| Ctail e -> Ctail (unbox_int dbg bi e)
| e -> unbox_int dbg bi e)
e
with
| e -> Cregion e
| exception Exit -> default cmm)
| Ctail e -> Ctail (unbox_int dbg bi e)
| cmm ->
default cmm
)
Expand Down Expand Up @@ -2018,15 +2014,15 @@ let has_local_allocs e =
let rec loop = function
| Cregion e ->
(* Local allocations within a nested region do not affect this region,
except inside a Ctail block *)
except inside a Cexclave block *)
loop_until_tail e
| Cop (Calloc Alloc_local, _, _)
| Cop ((Cextcall _ | Capply _), _, _) ->
raise Exit
| e ->
iter_shallow loop e
and loop_until_tail = function
| Ctail e -> loop e
| Cexclave e -> loop e
| Cregion _ -> ()
| e -> ignore (iter_shallow_tail loop_until_tail e)
in
Expand All @@ -2036,13 +2032,13 @@ let has_local_allocs e =

let remove_region_tail e =
let rec has_tail = function
| Ctail _
| Cexclave _
| Cop(Capply(_, Rc_close_at_apply), _, _) -> raise Exit
| Cregion _ -> ()
| e -> ignore (iter_shallow_tail has_tail e)
in
let rec remove_tail = function
| Ctail e -> e
| Cexclave e -> e
| Cop(Capply(mach, Rc_close_at_apply), args, dbg) ->
Cop(Capply(mach, Rc_normal), args, dbg)
| Cregion _ as e -> e
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/cmm_invariants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let rec check env (expr : Cmm.expression) =
check env body;
check env handler
| Cregion e -> check env e
| Ctail e -> check env e
| Cexclave e -> check env e

let run ppf (fundecl : Cmm.fundecl) =
let env = Env.init () in
Expand Down
8 changes: 4 additions & 4 deletions asmcomp/cmmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ let rec expr_size env = function
| _ -> assert false)
| Uregion exp ->
expr_size env exp
| Utail exp ->
| Uexclave exp ->
expr_size env exp
| _ -> RHS_nonrec

Expand Down Expand Up @@ -368,7 +368,7 @@ let is_unboxed_number_cmm ~strict cmm =
| _ ->
notify No_unboxing
end
| Cregion e | Ctail e ->
| Cregion e ->
aux e
| l ->
if not (Cmm.iter_shallow_tail aux l) then
Expand Down Expand Up @@ -748,8 +748,8 @@ let rec transl env e =
Cop(Cload (Word_int, Mutable), [Cconst_int (0, dbg)], dbg)
| Uregion e ->
region (transl env e)
| Utail e ->
Ctail (transl env e)
| Uexclave e ->
Cexclave (transl env e)

and transl_catch (kind : Cmm.kind_for_unboxing) env nfail ids body handler dbg =
let ids = List.map (fun (id, kind) -> (id, kind, ref No_result)) ids in
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/printcmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ let rec expr ppf = function
sequence e1 VP.print id sequence e2
| Cregion e ->
fprintf ppf "@[<2>(region@ %a)@]" sequence e
| Ctail e ->
fprintf ppf "@[<2>(tail@ %a)@]" sequence e
| Cexclave e ->
fprintf ppf "@[<2>(exclave@ %a)@]" sequence e

and sequence ppf = function
| Csequence(e1, e2) -> fprintf ppf "%a@ %a" sequence e1 sequence e2
Expand Down
12 changes: 6 additions & 6 deletions asmcomp/selectgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ method is_simple_expr = function
| Ccmpf _ -> List.for_all self#is_simple_expr args
end
| Cassign _ | Cifthenelse _ | Cswitch _ | Ccatch _ | Cexit _
| Ctrywith _ | Cregion _ | Ctail _ -> false
| Ctrywith _ | Cregion _ | Cexclave _ -> false

(* Analyses the effects and coeffects of an expression. This is used across
a whole list of expressions with a view to determining which expressions
Expand Down Expand Up @@ -435,7 +435,7 @@ method effects_of exp =
in
EC.join from_op (EC.join_list_map args self#effects_of)
| Cassign _ | Cswitch _ | Ccatch _ | Cexit _ | Ctrywith _
| Cregion _ | Ctail _ ->
| Cregion _ | Cexclave _ ->
EC.arbitrary

(* Says whether an integer constant is a suitable immediate argument for
Expand Down Expand Up @@ -974,9 +974,9 @@ method emit_expr_aux (env:environment) exp :
assert (List.length unclosed <= List.length old_regions);
Some (rd, unclosed)
end
| Ctail e ->
| Cexclave e ->
begin match env.regions with
| [] -> Misc.fatal_error "Selectgen.emit_expr: Ctail but not in tail of a region"
| [] -> Misc.fatal_error "Selectgen.emit_expr: Cexclave but not in tail of a region"
| cl :: rest ->
self#insert_endregions env [cl];
self#emit_expr_aux { env with regions = rest } e
Expand Down Expand Up @@ -1320,9 +1320,9 @@ method emit_tail (env:environment) exp =
let reg = self#regs_for typ_int in
self#insert env (Iop Ibeginregion) [| |] reg;
self#emit_tail {env with regions = reg::env.regions} e
| Ctail e ->
| Cexclave e ->
begin match env.regions with
| [] -> Misc.fatal_error "Selectgen.emit_tail: Ctail not inside Cregion"
| [] -> Misc.fatal_error "Selectgen.emit_tail: Cexclave not inside Cregion"
| reg :: regions ->
self#insert_endregions env [reg];
self#emit_tail { env with regions } e
Expand Down
2 changes: 2 additions & 0 deletions bytecomp/bytegen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ let rec comp_expr env exp sz cont =
comp_expr env exp sz cont
| Lregion (exp, _) ->
comp_expr env exp sz cont
| Lexclave exp ->
comp_expr env exp sz cont

(* Compile a list of arguments [e1; ...; eN] to a primitive operation.
The values of eN ... e2 are pushed on the stack, e2 at top of stack,
Expand Down
6 changes: 6 additions & 0 deletions driver/main_args.ml
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,9 @@ let mk_afl_inst_ratio f =
\ (advanced, see afl-fuzz docs for AFL_INST_RATIO)"
;;

let mk_alloc_check f =
"-zero-alloc-check", Arg.Unit f, "<ignored>"

let mk__ f =
"-", Arg.String f,
"<file> Treat <file> as a file name (even if it starts with `-')"
Expand Down Expand Up @@ -1201,6 +1204,7 @@ module type Optcomp_options = sig
val _save_ir_after : string -> unit
val _probes : unit -> unit
val _no_probes : unit -> unit
val _alloc_check : unit -> unit
end;;

module type Opttop_options = sig
Expand Down Expand Up @@ -1578,6 +1582,7 @@ struct
mk_dump_into_file F._dump_into_file;
mk_dump_dir F._dump_dir;
mk_dump_pass F._dump_pass;
mk_alloc_check F._alloc_check;

mk_args F._args;
mk_args0 F._args0;
Expand Down Expand Up @@ -2069,6 +2074,7 @@ module Default = struct
let _v () = Compenv.print_version_and_library "native-code compiler"
let _no_probes = clear probes
let _probes = set probes
let _alloc_check () = ()
end

module Odoc_args = struct
Expand Down
1 change: 1 addition & 0 deletions driver/main_args.mli
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ module type Optcomp_options = sig
val _save_ir_after : string -> unit
val _probes : unit -> unit
val _no_probes : unit -> unit
val _alloc_check : unit -> unit
end;;

module type Opttop_options = sig
Expand Down
4 changes: 2 additions & 2 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
;; CR gyorsh: it is not clear what the ":standard" flags are, and they
;; may change depending on the version of dune.
;; Consider hard-coded flags, such as -O3.
(:standard -zero-alloc-check -caml-apply-inline-fast-path)))
(:standard -zero-alloc-check)))
(boot
(flags
(:standard -warn-error +A))))
Expand Down Expand Up @@ -150,7 +150,7 @@
(action
(no-infer
(progn
(chdir yacc (run make -sj8 OCAMLYACC_INCLUDE_PATH=%{ocaml_where}))
(chdir yacc (run make -s OCAMLYACC_INCLUDE_PATH=%{ocaml_where}))
(copy yacc/ocamlyacc ocamlyacc)))))

(install
Expand Down
Loading

0 comments on commit 235c9c6

Please sign in to comment.