* 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.
Unified · Split
| @@ -985,12 +985,6 @@ static void copy_params(int nb_args, struct plan *plan, int todo) · 984 unmodified lines | ||
| 985 | 985 | int size, align, r, i; |
| 986 | 986 | struct param_plan *pplan; |
| 987 | 987 | |
| 988 | − /* Put argument on stack (structure are put on stack no matter how they are | |
| 989 | − * passed via register or the stack). */ | |
| 990 | −#ifdef TCC_ARM_EABI | |
| 991 | − if ((pplan = plan->clsplans[STACK_CLASS]) && pplan->end & 7) | |
| 992 | − o(0xE24DD004); /* sub sp, sp, #4 */ | |
| 993 | −#endif | |
| 994 | 988 | /* Several constraints require parameters to be copied in a specific order: |
| 995 | 989 | - structures are copied to the stack before being loaded in a reg; |
| 996 | 990 | - floats loaded to an odd numbered VFP reg are first copied to the |
| @@ -1156,6 +1150,14 @@ void gfunc_call(int nb_args) · 159 unmodified lines | ||
| 1156 | 1150 | #endif |
| 1157 | 1151 | |
| 1158 | 1152 | args_size = assign_regs(nb_args, variadic, &plan, &todo); |
| 1153 | + | |
| 1154 | +#ifdef TCC_ARM_EABI | |
| 1155 | + if (args_size & 7) { /* Stack must be 8 byte aligned at fct call for EABI */ | |
| 1156 | + args_size = (args_size + 7) & ~7; | |
| 1157 | + o(0xE24DD004); /* sub sp, sp, #4 */ | |
| 1158 | + } | |
| 1159 | +#endif | |
| 1160 | + | |
| 1159 | 1161 | copy_params(nb_args, &plan, todo); |
| 1160 | 1162 | tcc_free(plan.pplans); |
| 1161 | 1163 | |