@@ -766,9 +766,7 @@ and get_written e = match E.written_of e with
766766(* Compute rfmap for registers *)
767767(* ******************************)
768768
769- let map_loc_find loc m =
770- try U.LocEnv. find loc m
771- with Not_found -> []
769+ let map_loc_find loc m = U.LocEnv. safe_find [] loc m
772770
773771(* Event set ordered by to (generalised) program order *)
774772
@@ -795,6 +793,13 @@ struct
795793 assert false
796794
797795 end )
796+
797+ let find_last_before set e =
798+ find_last_opt (fun e' -> is_before_strict e' e) set
799+
800+ let find_first_after e set =
801+ find_first_opt (fun e' -> is_before_strict e e') set
802+
798803end
799804
800805let match_reg_events add_eq es csn =
@@ -815,9 +820,7 @@ let match_reg_events add_eq es csn =
815820 (* Add the corresponding store for each load *)
816821 List. fold_left
817822 (fun k load ->
818- let f e = StoreSet. is_before_strict e load in
819- let rf =
820- match StoreSet. find_last_opt f stores with
823+ let rf = match StoreSet. find_last_before stores load with
821824 | Some store -> S. Store store
822825 | None -> S. Init
823826 in
@@ -1691,8 +1694,7 @@ let get_rf_value test read =
16911694 let stores = StoreSet. of_list ws in
16921695 List. fold_left
16931696 (fun k load ->
1694- let f e = StoreSet. is_before_strict load e in
1695- match StoreSet. find_first_opt f stores with
1697+ match StoreSet. find_first_after load stores with
16961698 | None -> k (* No matching store (e.g. final load reserve) *)
16971699 | Some store ->
16981700 if S. atomic_pair_allowed load store then
@@ -1815,12 +1817,12 @@ let get_rf_value test read =
18151817 if C. debug.Debug_herd. mem then begin
18161818 eprintf " Observed locs: {%s}\n " (pp_locations observed_locs)
18171819 end ;
1818- U.LocEnv. fold
1819- (fun loc ws k ->
1820+ U.LocEnv. filter_map
1821+ (fun loc ws ->
18201822 if keep_observed_loc loc observed_locs then
1821- U.LocEnv. add loc ws k
1822- else k )
1823- loc_stores U.LocEnv. empty
1823+ Some ws
1824+ else None )
1825+ loc_stores
18241826 else loc_stores in
18251827
18261828 let possible_finals =
0 commit comments