Skip to content

Commit 9bd4c25

Browse files
committed
CHB:abstract when assigning volatile global variables
1 parent 55a5847 commit 9bd4c25

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

CodeHawk/CHB/bchlib/bCHFloc.ml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,22 @@ object (self)
23682368
rhs
23692369
| _ -> rhs in
23702370

2371+
let is_rhs_volatile =
2372+
let rhsvars = Xprt.variables_in_expr rhs in
2373+
List.exists (fun v ->
2374+
if self#f#env#is_global_variable v then
2375+
TR.tfold_default
2376+
(fun gvaddr ->
2377+
if memmap#has_location gvaddr then
2378+
let gloc = memmap#get_location gvaddr in
2379+
gloc#is_volatile
2380+
else
2381+
false)
2382+
false
2383+
(self#f#env#get_global_variable_address v)
2384+
else
2385+
false) rhsvars in
2386+
23712387
if self#f#env#is_global_variable lhs then
23722388
let _ =
23732389
log_diagnostics_result
@@ -2377,6 +2393,15 @@ object (self)
23772393
["lhs: " ^ (p2s lhs#toPretty); "rhs: " ^ (x2s rhs)] in
23782394
[ABSTRACT_VARS [lhs]]
23792395

2396+
else if is_rhs_volatile then
2397+
let _ =
2398+
log_diagnostics_result
2399+
~msg:(p2s self#l#toPretty)
2400+
~tag:("get_assign_cmds_r: abstract volatile assignment")
2401+
__FILE__ __LINE__
2402+
["lhs: " ^ (p2s lhs#toPretty); "rhs: " ^ (x2s rhs)] in
2403+
[ABSTRACT_VARS [lhs]]
2404+
23802405
else
23812406
let rhs =
23822407
(* if rhs is a composite symbolic expression, create a new variable

CodeHawk/CHB/bchlib/bCHGlobalMemoryMap.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ object (self)
157157
| Ok ty -> is_scalar ty
158158
| _ -> false
159159

160+
method is_volatile: bool = BCHBCTypeUtil.is_volatile self#btype
161+
160162
method is_typed: bool = not (btype_equal self#btype t_unknown)
161163

162164
method size: int option = grec.gloc_size

CodeHawk/CHB/bchlib/bCHLibTypes.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4398,6 +4398,7 @@ class type global_location_int =
43984398
method address: doubleword_int
43994399
method btype: btype_t
44004400
method size: int option
4401+
method is_volatile: bool
44014402
method is_readonly: bool
44024403
method is_initialized: bool
44034404
method is_typed: bool

CodeHawk/CHB/bchlib/bCHSystemSettings.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ let _ =
116116
("BL-sig-rv", "enable");
117117
("BXLR-sig-rv", "enable");
118118
("LDR-array", "enable");
119-
("LDR-memop-tc", "enable");
119+
("LDR-memop-tc", "disable");
120120
("LDR-stack-addr", "enable");
121121
("LDR-struct-field", "enable");
122-
("LDRH-memop-tc", "enable");
122+
("LDRH-memop-tc", "disable");
123123
("POP-sig-rv", "enable");
124124
("STR-memop-tc", "enable")
125125
]

CodeHawk/CHB/bchlibarm32/bCHFnARMTypeConstraints.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,8 +1715,8 @@ object (self)
17151715
(regvar_type_introduction "UXTH" rd);
17161716
(regvar_linked_to_exit "UXTH" rd);
17171717

1718-
(let opttc = mk_btype_constraint rdtypevar t_short in
1719-
let rule = "UBFX-def-lhs" in
1718+
(let opttc = mk_btype_constraint rdtypevar t_ushort in
1719+
let rule = "UXTH-def-lhs" in
17201720
(match opttc with
17211721
| Some tc ->
17221722
if fndata#is_typing_rule_enabled iaddr rule then

0 commit comments

Comments
 (0)