@@ -225,6 +225,28 @@ module GhostVector = struct
225
225
let unfold_vghosts_epred ghosts pre =
226
226
List. map (unfold_ghosts_epred ghosts) pre
227
227
228
+ let unfold_clauses node formals =
229
+ match node with
230
+ | {iname = "assert" ; iargs = [Pred (ep, rp)]} ->
231
+ let ep' = unfold_vghosts_epred formals ep in
232
+ let rp' = unfold_vghosts_rpred formals rp in
233
+ {iname = " assert" ; iargs = [Pred (ep',rp')]}
234
+ | {iname = "assume" ; iargs = [Pred (ep, rp)]} ->
235
+ let ep' = unfold_vghosts_epred formals ep in
236
+ let rp' = unfold_vghosts_rpred formals rp in
237
+ {iname = " assume" ; iargs = [Pred (ep',rp')]}
238
+ | {iname = "cut" ; iargs = [Pred (ep, rp)]} ->
239
+ let ep' = unfold_vghosts_epred formals ep in
240
+ let rp' = unfold_vghosts_rpred formals rp in
241
+ {iname = " cut" ; iargs = [Pred (ep',rp')]}
242
+ | _ -> node
243
+
244
+ let rec unfold_cfg_clauses cfg formals =
245
+ match cfg with
246
+ | h ::t ->
247
+ [unfold_clauses h formals] @ (unfold_cfg_clauses t formals)
248
+ | [] -> []
249
+
228
250
let unfold_vectors formals ret_vars =
229
251
let aux ((v ,ty ) as tv ) =
230
252
let mk_vector = Annot. filter_string_list None [" u16x16" , U16x16 ] in
@@ -261,28 +283,6 @@ module GhostVector = struct
261
283
let fs,ispre,ispost = aux tv in
262
284
fs @ acc1, ispre @ acc2, ispost @ acc3)
263
285
([] ,[] ,[] ) formals
264
-
265
- let unfold_clauses node formals =
266
- match node with
267
- | {iname = "assert" ; iargs = [Pred (ep, rp)]} ->
268
- let ep' = unfold_vghosts_epred formals ep in
269
- let rp' = unfold_vghosts_rpred formals rp in
270
- {iname = " assert" ; iargs = [Pred (ep',rp')]}
271
- | {iname = "assume" ; iargs = [Pred (ep, rp)]} ->
272
- let ep' = unfold_vghosts_epred formals ep in
273
- let rp' = unfold_vghosts_rpred formals rp in
274
- {iname = " assume" ; iargs = [Pred (ep',rp')]}
275
- | {iname = "cut" ; iargs = [Pred (ep, rp)]} ->
276
- let ep' = unfold_vghosts_epred formals ep in
277
- let rp' = unfold_vghosts_rpred formals rp in
278
- {iname = " cut" ; iargs = [Pred (ep',rp')]}
279
- | _ -> node
280
-
281
- let rec unfold_cfg_clauses cfg formals =
282
- match cfg with
283
- | h ::t ->
284
- [unfold_clauses h formals] @ (unfold_cfg_clauses t formals)
285
- | [] -> []
286
286
end
287
287
288
288
module SimplVector = struct
@@ -337,22 +337,6 @@ module SimplVector = struct
337
337
| None -> None
338
338
in
339
339
match n.nkind with
340
- | {iname = "cast" ; iargs = [Lval (Llvar (v',ty')); Atom (Avar (v'', ty''))]} ->
341
- if v == v' then
342
- if is_equiv_type ty' ty'' then
343
- aux (v'',ty'') n
344
- else
345
- Some (v', ty')
346
- else
347
- aux (v, ty) n
348
- | {iname = "cast" ; iargs = [Lval (Llvar (v',ty')); Atom (Avatome (Avar (v'', ty'') :: t))]} ->
349
- let ll = (List. length t) + 1 in
350
- if ll == 1 && v == v' && is_equiv_type ty' ty'' then
351
- aux (v'', ty'') n
352
- else if v == v' && ((int_of_ty ty'') * ll) == (int_of_ty ty') then (* Since we're not able to reconstruct the list, this is no longer invertible *)
353
- Some (v', ty')
354
- else
355
- aux (v, ty) n
356
340
| {iname = "mov" ; iargs = [Lval (Llvar (v',ty')); Atom (Avar (v'', ty''))]} ->
357
341
if v == v' && is_equiv_type ty' ty'' then
358
342
aux (v'',ty'') n
@@ -371,6 +355,22 @@ module SimplVector = struct
371
355
Some (v', ty')
372
356
else
373
357
aux (v, ty) n
358
+ | {iname = "cast" ; iargs = [Lval (Llvar (v',ty')); Atom (Avar (v'', ty''))]} ->
359
+ if v == v' then
360
+ if is_equiv_type ty' ty'' then
361
+ aux (v'',ty'') n
362
+ else
363
+ Some (v', ty')
364
+ else
365
+ aux (v, ty) n
366
+ | {iname = "cast" ; iargs = [Lval (Llvar (v',ty')); Atom (Avatome (Avar (v'', ty'') :: t))]} ->
367
+ let ll = (List. length t) + 1 in
368
+ if ll == 1 && v == v' && is_equiv_type ty' ty'' then
369
+ aux (v'', ty'') n
370
+ else if v == v' && ((int_of_ty ty'') * ll) == (int_of_ty ty') then (* Since we're not able to reconstruct the list, this is no longer invertible *)
371
+ Some (v', ty')
372
+ else
373
+ aux (v, ty) n
374
374
| {iname = "adds" ; iargs = [_; Lval (Llvar (v',ty')); Atom (Avar (_, ty'')); Atom (Avar (_, ty''' ))]} ->
375
375
if v == v' && (is_equiv_type ty' ty'' || is_equiv_type ty' ty''' ) then
376
376
Some (v', ty')
@@ -550,6 +550,7 @@ module SimplVector = struct
550
550
551
551
let rec nop_uinst cfg ret_vars node =
552
552
let nI = getNextI node in
553
+ (* TODO: search for unused lval in Lvatome *)
553
554
match node.nkind with
554
555
| {iname = "cast" ; iargs = [Lval (Llvar tv); _]} ->
555
556
if not (List. exists (is_eq_tyvar tv) ret_vars) && unused_lval tv nI then
0 commit comments