aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend/SimplLocals.v
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-09-17 18:28:55 +0100
committerYann Herklotz <git@yannherklotz.com>2021-09-17 18:28:55 +0100
commita1c401a4eba5fc9fcf42933f70005ecb679a4c1c (patch)
tree26637fca5d1da9b3d049234721d593a60b03a6d3 /cfrontend/SimplLocals.v
parentc49caca4b5f0239b43610fbfe012d6ba0211b364 (diff)
parent1daf96cdca4d828c333cea5c9a314ef861342984 (diff)
downloadcompcert-dev/michalis.tar.gz
compcert-dev/michalis.zip
Merge branch 'master' into dev/michalisdev/michalis
Diffstat (limited to 'cfrontend/SimplLocals.v')
-rw-r--r--cfrontend/SimplLocals.v13
1 files changed, 9 insertions, 4 deletions
diff --git a/cfrontend/SimplLocals.v b/cfrontend/SimplLocals.v
index f54aa60d..0a164e29 100644
--- a/cfrontend/SimplLocals.v
+++ b/cfrontend/SimplLocals.v
@@ -18,7 +18,7 @@ Require FSetAVL.
Require Import Coqlib Ordered Errors.
Require Import AST Linking.
Require Import Ctypes Cop Clight.
-Require Compopts.
+Require Compopts Conventions1.
Open Scope error_monad_scope.
Open Scope string_scope.
@@ -157,15 +157,20 @@ with simpl_lblstmt (cenv: compilenv) (ls: labeled_statements) : res labeled_stat
end.
(** Function parameters that are not lifted to temporaries must be
- stored in the corresponding local variable at function entry. *)
+ stored in the corresponding local variable at function entry.
+ The other function parameters may need to be normalized to their types,
+ to support interoperability with code generated by other C compilers. *)
Fixpoint store_params (cenv: compilenv) (params: list (ident * type))
(s: statement): statement :=
match params with
| nil => s
| (id, ty) :: params' =>
- if VSet.mem id cenv
- then store_params cenv params' s
+ if VSet.mem id cenv then
+ if Conventions1.parameter_needs_normalization (rettype_of_type ty)
+ then Ssequence (Sset id (make_cast (Etempvar id ty) ty))
+ (store_params cenv params' s)
+ else store_params cenv params' s
else Ssequence (Sassign (Evar id ty) (Etempvar id ty))
(store_params cenv params' s)
end.