diff options
| author | Thomas Preud'homme <robotux@celest.fr> | 2013-11-17 18:26:56 +0800 |
|---|---|---|
| committer | Thomas Preud'homme <robotux@celest.fr> | 2013-11-17 18:26:56 +0800 |
| commit | 0c40bc8982adfba427933260c6571bd29f50a649 (patch) | |
| tree | 25fbb42ccd8d95c4b22afec05f5bf88fb1a833d2 | |
| parent | 1528a085408e7aa16d2009981215fc370842eb87 (diff) | |
| download | tinycc-0c40bc8982adfba427933260c6571bd29f50a649.tar.gz tinycc-0c40bc8982adfba427933260c6571bd29f50a649.tar.bz2 | |
Correctly align and reclaim stack at function call
* Correctly align stack in case of structure split between core
registers and stack
* Correctly reclaim stack space after function call in the case where
the stack needed padding to be aligned at function call.
| -rw-r--r-- | arm-gen.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -985,12 +985,6 @@ static void copy_params(int nb_args, struct plan *plan, int todo) int size, align, r, i; struct param_plan *pplan; - /* Put argument on stack (structure are put on stack no matter how they are - * passed via register or the stack). */ -#ifdef TCC_ARM_EABI - if ((pplan = plan->clsplans[STACK_CLASS]) && pplan->end & 7) - o(0xE24DD004); /* sub sp, sp, #4 */ -#endif /* Several constraints require parameters to be copied in a specific order: - structures are copied to the stack before being loaded in a reg; - floats loaded to an odd numbered VFP reg are first copied to the @@ -1156,6 +1150,14 @@ void gfunc_call(int nb_args) #endif args_size = assign_regs(nb_args, variadic, &plan, &todo); + +#ifdef TCC_ARM_EABI + if (args_size & 7) { /* Stack must be 8 byte aligned at fct call for EABI */ + args_size = (args_size + 7) & ~7; + o(0xE24DD004); /* sub sp, sp, #4 */ + } +#endif + copy_params(nb_args, &plan, todo); tcc_free(plan.pplans); |
