Skip to content

Commit

Permalink
[analyzer] allow inlining unsafe casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Jun 18, 2015
1 parent e86c9c1 commit f386f74
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ module ConstPropagation = struct
with Not_found ->
-1

let can_be_inlined com v0 e = type_iseq v0.v_type e.etype && match e.eexpr with
let rec can_be_inlined com v0 e = type_iseq v0.v_type e.etype && match e.eexpr with
| TConst ct ->
begin match ct with
| TThis | TSuper -> false
Expand All @@ -1065,6 +1065,9 @@ module ConstPropagation = struct
Ssa.get_var_usage_count v0 <= 1
| TField(_,FEnum _) ->
Ssa.get_var_usage_count v0 <= 1
| TCast(e1,None) ->
(* We can inline an unsafe cast if the variable is only used once. *)
can_be_inlined com v0 {e1 with etype = e.etype} && Ssa.get_var_usage_count v0 <= 1
| _ ->
false

Expand Down

0 comments on commit f386f74

Please sign in to comment.