From d5e332e8bc07ad2a67cc2878e620c02286b27142 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 22 Sep 2020 17:03:03 +0200 Subject: Fix computation of next temporary in -canonical-idents mode Variables were confused for temporaries, causing the temporaries introduced by this pass to be very big integers. Fixes: #370 --- exportclight/Clightnorm.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'exportclight') diff --git a/exportclight/Clightnorm.ml b/exportclight/Clightnorm.ml index a0001250..a6158b60 100644 --- a/exportclight/Clightnorm.ml +++ b/exportclight/Clightnorm.ml @@ -143,7 +143,18 @@ and norm_lbl_stmt ls = | LSnil -> LSnil | LScons(n, s, ls) -> LScons(n, norm_stmt s, norm_lbl_stmt ls) -let next_var curr (v, _) = if P.lt v curr then curr else P.succ v +(* In "canonical atoms" mode, temporaries are between 2^7 and 2^12 - 1. + Below 2^7 are single-letter identifiers and above 2^12 are all + other identifiers. *) + +let first_temp = P.of_int 128 +let last_temp = P.of_int 4095 + +let next_var curr (v, _) = + if P.lt v curr + || !use_canonical_atoms && (P.lt v first_temp || P.gt v last_temp) + then curr + else P.succ v let next_var_list vars start = List.fold_left next_var start vars -- cgit