Skip to content

Commit 8f5ff52

Browse files
authored
Port upstream's #12715 (disable CSE for atomic loads) (#2079)
1 parent 7f80a7c commit 8f5ff52

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

backend/CSEgen.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,12 @@ method class_of_operation op =
238238
| Icall_ind | Icall_imm _ | Itailcall_ind | Itailcall_imm _
239239
| Iextcall _ | Iprobe _ | Iopaque -> assert false (* treated specially *)
240240
| Istackoffset _ -> Op_other
241-
| Iload { mutability = Mutable } -> Op_load Mutable
242-
| Iload { mutability = Immutable } -> Op_load Immutable
241+
| Iload { mutability; is_atomic } ->
242+
(* #12173: disable CSE for atomic loads. *)
243+
if is_atomic then Op_other
244+
else Op_load (match mutability with
245+
| Mutable -> Mutable
246+
| Immutable -> Immutable)
243247
| Istore(_,_,asg) -> Op_store asg
244248
| Ialloc _ | Ipoll _ -> assert false (* treated specially *)
245249
| Iintop(Icheckbound|Icheckalign _) -> Op_checkbound

ocaml/asmcomp/CSEgen.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ method class_of_operation op =
226226
| Icall_ind | Icall_imm _ | Itailcall_ind | Itailcall_imm _
227227
| Iextcall _ | Iprobe _ | Iopaque -> assert false (* treated specially *)
228228
| Istackoffset _ -> Op_other
229-
| Iload { mutability } -> Op_load mutability
229+
| Iload { mutability; is_atomic } ->
230+
(* #12173: disable CSE for atomic loads. *)
231+
if is_atomic then Op_other
232+
else Op_load mutability
230233
| Istore(_,_,asg) -> Op_store asg
231234
| Ialloc _ | Ipoll _ -> assert false (* treated specially *)
232235
| Iintop(Icheckbound) -> Op_checkbound

0 commit comments

Comments
 (0)