aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/StructReturn.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-07-14 22:41:24 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-07-14 22:41:24 +0200
commit4c146156a36d48209a6206f61f80dc5d4c48ce93 (patch)
treedc8e3b1c7daf41cdf965c9e3e6119dcb5d6a41e5 /cparser/StructReturn.ml
parentd03d47c6e4ce9324d6d59ae36cb8db78b013be54 (diff)
parentf995a671ceb28c2a83e5e5574c3cdb46fd5e0f57 (diff)
downloadcompcert-4c146156a36d48209a6206f61f80dc5d4c48ce93.tar.gz
compcert-4c146156a36d48209a6206f61f80dc5d4c48ce93.zip
Merge branch 'master' into asmexpand
Diffstat (limited to 'cparser/StructReturn.ml')
-rw-r--r--cparser/StructReturn.ml14
1 files changed, 10 insertions, 4 deletions
diff --git a/cparser/StructReturn.ml b/cparser/StructReturn.ml
index 660f1d9b..5e5602f3 100644
--- a/cparser/StructReturn.ml
+++ b/cparser/StructReturn.ml
@@ -299,10 +299,15 @@ let rec transf_expr env ctx e =
transf_call env ctx None fn args e.etyp
(* Function calls returning a composite by reference: add first argument.
- ctx = Effects: lv = f(...) -> f(&lv, ...) [copy optimization]
+ ctx = Effects: lv = f(...) -> f(&newtemp, ...), lv = newtemp
f(...) -> f(&newtemp, ...)
ctx = Val: lv = f(...) -> f(&newtemp, ...), lv = newtemp
f(...) -> f(&newtemp, ...), newtemp
+
+ We used to do a copy optimization:
+ ctx = Effects: lv = f(...) -> f(&lv, ...)
+ but it is not correct in case of overlap (see test/regression/struct12.c)
+
Function calls returning a composite by value:
ctx = Effects: lv = f(...) -> newtemp = f(...), lv = newtemp
f(...) -> f(...)
@@ -332,13 +337,14 @@ and transf_call env ctx opt_lhs fn args ty =
| Effects, None ->
let tmp = new_temp ~name:"_res" ty in
{edesc = ECall(fn', eaddrof tmp :: args'); etyp = TVoid []}
- | Effects, Some lhs ->
- {edesc = ECall(fn', eaddrof lhs :: args'); etyp = TVoid []}
+ (* Copy optimization, turned off as explained above *)
+ (* | Effects, Some lhs ->
+ {edesc = ECall(fn', eaddrof lhs :: args'); etyp = TVoid []} *)
| Val, None ->
let tmp = new_temp ~name:"_res" ty in
ecomma {edesc = ECall(fn', eaddrof tmp :: args'); etyp = TVoid []}
tmp
- | Val, Some lhs ->
+ | _, Some lhs ->
let tmp = new_temp ~name:"_res" ty in
ecomma {edesc = ECall(fn', eaddrof tmp :: args'); etyp = TVoid []}
(eassign lhs tmp)