diff options
author | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2023-05-16 11:52:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-16 11:52:31 +0200 |
commit | 8d1af245ef46e40652be4509f03ab600405aef63 (patch) | |
tree | 2e68eb707d3d6e40c1d22153aa62adf4f73e9ef7 | |
parent | cd01cac2e11706cac40462f185345848596f2b40 (diff) | |
download | ocaml-trunk.tar.gz |
Just treat atomic loads like stores.
Fixes: #12216
-rw-r--r-- | Changes | 6 | ||||
-rw-r--r-- | asmcomp/schedgen.ml | 7 | ||||
-rw-r--r-- | asmcomp/schedgen.mli | 5 |
3 files changed, 15 insertions, 3 deletions
@@ -38,6 +38,12 @@ Working version ### Internal/compiler-libs changes: +- #12216, #12248: Prevent reordering of atomic loads during instruction + scheduling. This is for reference, as instruction scheduling is currently + unused in OCaml 5. + (Xavier Leroy, report by Luc Maranget and KC Sivaramakrishnan, + review by Nicolás Ojeda Bär) + ### Build system: ### Bug fixes: diff --git a/asmcomp/schedgen.ml b/asmcomp/schedgen.ml index 2a0c75e5e1..5624281aee 100644 --- a/asmcomp/schedgen.ml +++ b/asmcomp/schedgen.ml @@ -181,12 +181,17 @@ method private instr_in_basic_block instr try_nesting = Can be overridden for some processors to signal specific load or store instructions (e.g. on the I386). *) +(* Stores are not reordered with other stores nor with loads. + Loads can be reordered with other loads, but not with stores. + Atomic loads must not be reordered, so we treat them like stores. *) + method is_store = function Istore(_, _, _) -> true + | Iload {is_atomic = true} -> true | _ -> false method is_load = function - Iload _ -> true + Iload {is_atomic = false} -> true | _ -> false method is_checkbound = function diff --git a/asmcomp/schedgen.mli b/asmcomp/schedgen.mli index bc3f798dad..3f2ea61f36 100644 --- a/asmcomp/schedgen.mli +++ b/asmcomp/schedgen.mli @@ -37,9 +37,10 @@ class virtual scheduler_generic : object method oper_in_basic_block : Mach.operation -> bool (* Says whether the given operation terminates a basic block *) method is_store : Mach.operation -> bool - (* Says whether the given operation is a memory store *) + (* Says whether the given operation is a memory store + or an atomic load. *) method is_load : Mach.operation -> bool - (* Says whether the given operation is a memory load *) + (* Says whether the given operation is a non-atomic memory load *) method is_checkbound : Mach.operation -> bool (* Says whether the given operation is a checkbound *) (* Entry point *) |