@@ -187,6 +187,10 @@ let is_simple (lam : Lambda.lambda) =
187
187
match lam with Lvar _ | Lconst _ -> true | _ -> false
188
188
[@@ ocaml.warning " -fragile-match" ]
189
189
190
+ let assert_not_local : Lambda.alloc_mode -> unit = function
191
+ | Alloc_heap -> ()
192
+ | Alloc_local -> Misc. fatal_error " Invalid stack allocation found"
193
+
190
194
let dead_code lam letrec =
191
195
(* Some cases generate code without effects, and bound to nothing. We use this
192
196
function to insert it as [Lsequence] in [effects], for documentation. It
@@ -203,6 +207,7 @@ let rec prepare_letrec (recursive_set : Ident.Set.t)
203
207
(lam : Lambda.lambda ) (letrec : letrec ) =
204
208
match lam with
205
209
| Lfunction funct -> (
210
+ assert_not_local funct.mode;
206
211
match current_let with
207
212
| Some current_let when Ident.Set. mem current_let.ident recursive_set ->
208
213
{ letrec with functions = (current_let.ident, funct) :: letrec.functions }
@@ -221,6 +226,10 @@ let rec prepare_letrec (recursive_set : Ident.Set.t)
221
226
| None -> dead_code lam letrec)
222
227
| Lprim (((Pmakeblock _ | Pmakearray _ | Pduprecord _) as prim), args, dbg)
223
228
when not (List. for_all is_simple args) ->
229
+ (match prim with
230
+ | Pmakeblock (_ , _ , _ , mode ) | Pmakearray (_ , _ , mode ) ->
231
+ assert_not_local mode
232
+ | _ -> () );
224
233
(* If there are some non-trivial expressions as arguments, we first extract
225
234
the arguments (to let-bound variables) before deconstructing. Arguments
226
235
could contain side effects and other blocks declarations. *)
@@ -246,15 +255,16 @@ let rec prepare_letrec (recursive_set : Ident.Set.t)
246
255
defs
247
256
in
248
257
prepare_letrec recursive_set current_let lam letrec
249
- | Lprim (Pmakeblock _, args, _)
250
- | Lprim (Pmakearray ((Paddrarray | Pintarray ), _ , _ ), args , _ ) -> (
258
+ | Lprim (Pmakeblock (_, _, _, mode), args, _)
259
+ | Lprim (Pmakearray ((Paddrarray | Pintarray ), _ , mode ), args , _ ) -> (
260
+ assert_not_local mode;
251
261
match current_let with
252
262
| Some cl -> build_block cl (List. length args) (Normal 0 ) lam letrec
253
- | None ->
254
- dead_code lam letrec
255
- (* We know that [ args] are all "simple" at this point, so no effects *) )
256
- | Lprim (Pmakearray ( Pfloatarray , _, _ ), args, _)
257
- | Lprim (Pmakefloatblock _ , args , _ ) -> (
263
+ | None -> dead_code lam letrec
264
+ (* We know that [args] are all "simple" at this point, so no effects *) )
265
+ | Lprim ( Pmakearray ( Pfloatarray , _, mode), args, _ )
266
+ | Lprim (Pmakefloatblock ( _ , mode ), args , _ ) -> (
267
+ assert_not_local mode;
258
268
match current_let with
259
269
| Some cl -> build_block cl (List. length args) Boxed_float lam letrec
260
270
| None -> dead_code lam letrec)
0 commit comments