Skip to content

Commit d5e332e

Browse files
committed
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
1 parent ab0d947 commit d5e332e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

exportclight/Clightnorm.ml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,18 @@ and norm_lbl_stmt ls =
143143
| LSnil -> LSnil
144144
| LScons(n, s, ls) -> LScons(n, norm_stmt s, norm_lbl_stmt ls)
145145

146-
let next_var curr (v, _) = if P.lt v curr then curr else P.succ v
146+
(* In "canonical atoms" mode, temporaries are between 2^7 and 2^12 - 1.
147+
Below 2^7 are single-letter identifiers and above 2^12 are all
148+
other identifiers. *)
149+
150+
let first_temp = P.of_int 128
151+
let last_temp = P.of_int 4095
152+
153+
let next_var curr (v, _) =
154+
if P.lt v curr
155+
|| !use_canonical_atoms && (P.lt v first_temp || P.gt v last_temp)
156+
then curr
157+
else P.succ v
147158

148159
let next_var_list vars start = List.fold_left next_var start vars
149160

0 commit comments

Comments
 (0)