File tree Expand file tree Collapse file tree 1 file changed +31
-4
lines changed Expand file tree Collapse file tree 1 file changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -299,12 +299,39 @@ let the_case_of info x =
299
299
| Pc (Tuple (j , _ , _ )) -> CTag j
300
300
| _ -> Unknown
301
301
302
+ type cond_of =
303
+ | Zero
304
+ | Non_zero
305
+ | Unknown
306
+
307
+ let the_cond_of info x =
308
+ get_approx
309
+ info
310
+ (fun x ->
311
+ match info.info_defs.(Var. idx x) with
312
+ | Expr (Constant (Int 0l | Float 0. )) -> Zero
313
+ | Expr
314
+ (Constant
315
+ (Int _ | Float _ | Tuple _ | String _ | IString _ | Float_array _ | Int64 _))
316
+ ->
317
+ Non_zero
318
+ | Expr (Block (_ , _ , _ )) -> Non_zero
319
+ | Expr (Field _ | Closure _ | Prim _ | Apply _ ) -> Unknown
320
+ | Param | Phi _ -> Unknown )
321
+ Unknown
322
+ (fun u v ->
323
+ match u, v with
324
+ | Zero , Zero -> Zero
325
+ | Non_zero , Non_zero -> Non_zero
326
+ | _ -> Unknown )
327
+ x
328
+
302
329
let eval_branch info = function
303
330
| Cond (x , ftrue , ffalse ) as b -> (
304
- match the_int info ( Pv x) with
305
- | Some 0l -> Branch ffalse
306
- | Some _ -> Branch ftrue
307
- | _ -> b)
331
+ match the_cond_of info x with
332
+ | Zero -> Branch ffalse
333
+ | Non_zero -> Branch ftrue
334
+ | Unknown -> b)
308
335
| Switch (x , const , tags ) as b -> (
309
336
(* [the_case_of info (Pv x)] might be meaningless when we're inside a dead code.
310
337
The proper fix would be to remove the deadcode entirely.
You can’t perform that action at this time.
0 commit comments