Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hl] add -D hl_w_null_compare #11640

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/generators/genhl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type context = {
cfunctions : fundecl DynArray.t;
cconstants : (constval, (global * int array)) lookup;
optimize : bool;
w_null_compare : bool;
overrides : (string * path, bool) Hashtbl.t;
defined_funs : (int,unit) Hashtbl.t;
is_macro : bool;
Expand Down Expand Up @@ -1546,6 +1547,8 @@ and jump_expr ctx e jcond =
| (HUI8 | HUI16 | HI32 | HI64 | HF32 | HF64 as ti1), HNull (HUI8 | HUI16 | HI32 | HI64 | HF32 | HF64 as ti2)
| HNull (HUI8 | HUI16 | HI32 | HI64 | HF32 | HF64 as ti1), HNull (HUI8 | HUI16 | HI32 | HI64 | HF32 | HF64 as ti2)
->
if ctx.w_null_compare && (is_nullt t1 || is_nullt t2) then
ctx.com.warning WGenerator [] (Printf.sprintf "Null compare: %s %s %s" (tstr t1) (s_binop jop) (tstr t2)) e.epos;
let r1 = eval_expr ctx e1 in
hold ctx r1;
let jnull1 = if is_nullt t1 then jump ctx (fun i -> OJNull (r1, i)) else (fun i -> ()) in
Expand Down Expand Up @@ -4113,6 +4116,7 @@ let create_context com is_macro dump =
com = com;
is_macro = is_macro;
optimize = not (Common.raw_defined com "hl_no_opt");
w_null_compare = Common.raw_defined com "hl_w_null_compare";
dump_out = if dump then Some (IO.output_channel (open_out_bin "dump/hlopt.txt")) else None;
m = method_context 0 HVoid null_capture false;
cints = new_lookup();
Expand Down
Loading