@@ -193,6 +193,15 @@ object (self)
193193 let getopt_stackaddress_r (x_r : xpr_t traceresult ): int option =
194194 TR. tfold_default getopt_stackaddress None x_r in
195195
196+ let getopt_stacklocation_type (x : xpr_t ): btype_t option =
197+ match getopt_stackaddress x with
198+ | Some offset when fndata#has_stackvar_type_annotation offset ->
199+ TR. to_option (fndata#get_stackvar_type_annotation offset)
200+ | _ -> None in
201+
202+ let getopt_stacklocation_type_r (x_r : xpr_t traceresult ): btype_t option =
203+ TR. tfold_default getopt_stacklocation_type None x_r in
204+
196205 let getopt_global_address (x : xpr_t ): doubleword_int option =
197206 match (rewrite_expr x) with
198207 | XConst (IntConst num ) ->
@@ -818,26 +827,30 @@ object (self)
818827 (regvar_type_introduction " LDR" rt);
819828
820829 (* loaded type may be known *)
821- (let xmem_r = memop#to_expr floc in
822- let xrmem_r =
823- TR. tmap (fun x -> simplify_xpr (floc#inv#rewrite_expr x)) xmem_r in
824- let xtype_r = TR. tbind floc#get_xpr_type xrmem_r in
825- let rule = " LDR-memop-tc" in
826- TR. titer
827- ~ok: (fun t ->
828- let opttc = mk_btype_constraint rttypevar t in
829- (match opttc with
830- | Some tc ->
831- if fndata#is_typing_rule_enabled iaddr rule then
832- begin
833- log_type_constraint __LINE__ rule tc;
834- store#add_constraint faddr iaddr rule tc
835- end
836- else
837- log_type_constraint_rule_disabled __LINE__ rule tc
838- | _ -> () ))
839- ~error: (fun e -> log_error_result __FILE__ __LINE__ e)
840- xtype_r);
830+ (match getopt_stacklocation_type_r (memop#to_address floc) with
831+ (* skip if stacklocation type has been declared in userdata *)
832+ | Some _ -> ()
833+ | _ ->
834+ (let xmem_r = memop#to_expr floc in
835+ let xrmem_r =
836+ TR. tmap (fun x -> simplify_xpr (floc#inv#rewrite_expr x)) xmem_r in
837+ let xtype_r = TR. tbind floc#get_xpr_type xrmem_r in
838+ let rule = " LDR-memop-tc" in
839+ TR. titer
840+ ~ok: (fun t ->
841+ let opttc = mk_btype_constraint rttypevar t in
842+ (match opttc with
843+ | Some tc ->
844+ if fndata#is_typing_rule_enabled iaddr rule then
845+ begin
846+ log_type_constraint __LINE__ rule tc;
847+ store#add_constraint faddr iaddr rule tc
848+ end
849+ else
850+ log_type_constraint_rule_disabled __LINE__ rule tc
851+ | _ -> () ))
852+ ~error: (fun e -> log_error_result __FILE__ __LINE__ e)
853+ xtype_r));
841854
842855 (* LDR rt, [rn, rm] : X_rndef.load <: X_rt *)
843856 (let xrdef = get_variable_rdefs_r (rn#to_variable floc) in
0 commit comments