aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip <pipcet@gmail.com>2015-04-29 21:32:14 +0000
committerPhilip <pipcet@gmail.com>2015-04-29 21:48:30 +0000
commit4126056fbe62dfc7897b0b2c52abf9fdfbfbffda (patch)
tree0121797b5491be90aa454de13a95213b7e3c962d
parent44c330d647c3e1a17e7169f5aa5abb322166fdae (diff)
downloadtinycc-4126056fbe62dfc7897b0b2c52abf9fdfbfbffda.tar.gz
tinycc-4126056fbe62dfc7897b0b2c52abf9fdfbfbffda.tar.bz2
fix vstack leak
I think this code only affects the ARM EABI target, and only when returning small structures that might be unaligned. However, it was both leaking vstack entries and failing to achieve what I think is its purpose, to ensure the sret argument would be aligned properly. Both issues fixed.
-rw-r--r--tccgen.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tccgen.c b/tccgen.c
index 8c1165f..e054b4b 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4916,12 +4916,13 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
size = type_size(&func_vt,&align);
if ((vtop->r != (VT_LOCAL | VT_LVAL) || (vtop->c.i & (ret_align-1)))
&& (align & (ret_align-1))) {
- loc = (loc - size) & -align;
+ loc = (loc - size) & -ret_align;
addr = loc;
type = func_vt;
vset(&type, VT_LOCAL | VT_LVAL, addr);
vswap();
vstore();
+ vpop();
vset(&ret_type, VT_LOCAL | VT_LVAL, addr);
}
vtop->type = ret_type;