aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@college-de-france.fr>2022-09-03 10:36:49 +0200
committerXavier Leroy <xavier.leroy@college-de-france.fr>2022-09-03 10:38:50 +0200
commit6f26a95f2debe76e1350eea97c2162e5bcd8cfad (patch)
tree3af9f5614c187a72675a80365d04f244fde24c8e
parent9fcb0316df79ee741272340d7db0378872a53c5f (diff)
downloadcompcert-6f26a95f2debe76e1350eea97c2162e5bcd8cfad.tar.gz
compcert-6f26a95f2debe76e1350eea97c2162e5bcd8cfad.zip
Add `iter_literal*` functions with guaranteed iteration order
This makes compilation runs more reproducible.
-rw-r--r--backend/PrintAsmaux.ml12
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml
index 841f4579..df2f72f2 100644
--- a/backend/PrintAsmaux.ml
+++ b/backend/PrintAsmaux.ml
@@ -83,6 +83,18 @@ let literal64_labels = (Hashtbl.create 39 : (int64, int) Hashtbl.t)
let label_literal32 bf = label_constant literal32_labels bf
let label_literal64 n = label_constant literal64_labels n
+(* Sort by label before iteration, to make compilations more reproducible *)
+
+let iter_literal32 f =
+ List.iter (fun (n, lbl) -> f n lbl)
+ (List.fast_sort (fun (n1, lbl1) (n2, lbl2) -> compare lbl1 lbl2)
+ (Hashtbl.fold (fun n lbl accu -> (n, lbl) :: accu) literal32_labels []))
+
+let iter_literal64 f =
+ List.iter (fun (n, lbl) -> f n lbl)
+ (List.fast_sort (fun (n1, lbl1) (n2, lbl2) -> compare lbl1 lbl2)
+ (Hashtbl.fold (fun n lbl accu -> (n, lbl) :: accu) literal64_labels []))
+
let reset_literals () =
Hashtbl.clear literal32_labels;
Hashtbl.clear literal64_labels