Skip to content

Commit cac1f85

Browse files
committed
CHB:ARM:restore def-use-high of R0 for function returns
1 parent 109b1a5 commit cac1f85

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

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_20250420"
99-
~date:"2025-04-20"
98+
~version:"0.6.0_20250502"
99+
~date:"2025-05-02"
100100
~licensee: None
101101
~maxfilesize: None
102102
()

CodeHawk/CHB/bchlibarm32/bCHTranslateARMToCHIF.ml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,9 +2346,24 @@ let translate_arm_instruction
23462346
match rtype with
23472347
| TVoid _ -> []
23482348
| _ ->
2349+
(* Return variables need to be treated somewhat differently
2350+
than other 'initial-value' variables, because in the
2351+
lifting to C code they get assigned to, while other
2352+
'initial-value' variables always have their values
2353+
and thus are by default not included in the use-high
2354+
variables. *)
23492355
let r0_op = arm_register_op AR0 RD in
2350-
let xr0 = r0_op#to_expr floc in
2351-
get_use_high_vars_r [xr0]
2356+
let xr0_r = r0_op#to_expr floc in
2357+
TR.tfold_default
2358+
(fun xr0 ->
2359+
let xxr0 = floc#inv#rewrite_expr xr0 in
2360+
match xxr0 with
2361+
| XVar v when floc#env#is_return_value v ->
2362+
[floc#f#env#mk_arm_register_variable AR0]
2363+
| _ ->
2364+
get_use_high_vars_r ~is_pop:true [xr0_r])
2365+
(get_use_high_vars_r ~is_pop:true [xr0_r])
2366+
xr0_r
23522367
else
23532368
[] in
23542369
let popdefcmds =

0 commit comments

Comments
 (0)