History

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.

Thomas Preud'homme committed 13 years ago

Commit 0c40bc81 parent 1528a081 file · +8 −6Browse files

Unified · Split

arm-gen.c+8−6
@@ -985,12 +985,6 @@ static void copy_params(int nb_args, struct plan *plan, int todo) · 984 unmodified lines
985985 int size, align, r, i;
986986 struct param_plan *pplan;
987987
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
994988 /* Several constraints require parameters to be copied in a specific order:
995989 - structures are copied to the stack before being loaded in a reg;
996990 - 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
11561150 #endif
11571151
11581152 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+
11591161 copy_params(nb_args, &plan, todo);
11601162 tcc_free(plan.pplans);
11611163

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t