Skip to content

Commit 1edaaa1

Browse files
committed
CHB:ARM: add more type inference
1 parent f36342c commit 1edaaa1

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

CodeHawk/CHB/bchlib/bCHFloc.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,21 @@ object (self)
14041404
^ " not yet handled"])
14051405
memoff_r)
14061406
basevar_type_r
1407+
else if self#f#env#is_return_value v then
1408+
let callsite_r = self#f#env#get_call_site v in
1409+
TR.tbind
1410+
~msg:(__FILE__ ^ ":" ^ (string_of_int __LINE__))
1411+
(fun callsite ->
1412+
let loc = ctxt_string_to_location self#fa callsite in
1413+
let fndata = functions_data#get_function self#fa in
1414+
if fndata#has_regvar_type_annotation loc#i then
1415+
fndata#get_regvar_type_annotation loc#i
1416+
else
1417+
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
1418+
^ "type of callsite return value " ^ (x2s (XVar v))
1419+
^ " at address " ^ loc#i#to_hex_string
1420+
^ " not yet handled"])
1421+
callsite_r
14071422
else
14081423
let ty = self#env#get_variable_type v in
14091424
match ty with

CodeHawk/CHB/bchlib/bCHVersion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ end
9595

9696

9797
let version = new version_info_t
98-
~version:"0.6.0_20250313"
99-
~date:"2025-03-13"
98+
~version:"0.6.0_20250314"
99+
~date:"2025-03-14"
100100
~licensee: None
101101
~maxfilesize: None
102102
()

CodeHawk/CHB/bchlibarm32/bCHFnARMTypeConstraints.ml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ object (self)
407407
(* no type information gained *)
408408
()
409409

410-
| BranchLink _
410+
| BranchLink _ | BranchLinkExchange _
411411
when floc#has_call_target && floc#get_call_target#is_signature_valid ->
412412
let log_error (msg: string) =
413413
mk_tracelog_spec
@@ -435,18 +435,33 @@ object (self)
435435
(* add constraint for return value *)
436436
(if not (is_void rtype) then
437437
let typevar = mk_reglhs_typevar rvreg faddr iaddr in
438-
let opttc = mk_btype_constraint typevar rtype in
439-
match opttc with
440-
| Some tc ->
441-
begin
442-
log_type_constraint "BL-rv" tc;
443-
store#add_constraint tc
444-
end
438+
match get_regvar_type_annotation () with
439+
| Some t ->
440+
let opttc = mk_btype_constraint typevar t in
441+
(match opttc with
442+
| Some tc ->
443+
begin
444+
log_type_constraint "BL-rv-intro" tc;
445+
store#add_constraint tc
446+
end
447+
| _ ->
448+
begin
449+
log_no_type_constraint "BL-rv-intro" t;
450+
()
451+
end)
445452
| _ ->
446-
begin
447-
log_no_type_constraint "BL-rv" rtype;
448-
()
449-
end);
453+
let opttc = mk_btype_constraint typevar rtype in
454+
match opttc with
455+
| Some tc ->
456+
begin
457+
log_type_constraint "BL-rv" tc;
458+
store#add_constraint tc
459+
end
460+
| _ ->
461+
begin
462+
log_no_type_constraint "BL-rv" rtype;
463+
()
464+
end);
450465

451466
(* add constraints for argument values *)
452467
List.iter (fun (p, x) ->

0 commit comments

Comments
 (0)