This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v2] aarch64: Add split-stack initial support
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Jiong Wang <Jiong dot Wang at arm dot com>
- Cc: nd <nd at arm dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 3 Jan 2017 15:13:10 +0000
- Subject: Re: [PATCH v2] aarch64: Add split-stack initial support
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- Nodisclaimer: True
- References: <AM5PR0802MB261081EB50235D83C6462C4483DF0@AM5PR0802MB2610.eurprd08.prod.outlook.com> <85ebdf7a-a361-595d-6167-32c3dbd8f2b2@linaro.org> <8ee569de-c3d2-b37a-6463-ad151803531b@linaro.org> <AM5PR0802MB2610617CF37190BF4F18670383BF0@AM5PR0802MB2610.eurprd08.prod.outlook.com>,<73b35310-87fe-7a11-241d-eacbcd08c6b0@linaro.org>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Adhemerval Zanella wrote:
Sorry for the late reply - but I think it's getting there. A few more comments:
+ /* If function uses stacked arguments save the old stack value so morestack
+ can return it. */
+ reg11 = gen_rtx_REG (Pmode, R11_REGNUM);
+ if (cfun->machine->frame.saved_regs_size
+ || cfun->machine->frame.saved_varargs_size)
+ emit_move_insn (reg11, stack_pointer_rtx);
This doesn't look right - we could have many arguments even without varargs or
saved regs. This would need to check varargs as well as ctrl->args.size (I believe
that is the size of the arguments on the stack). It's fine to omit this optimization
in the first version - we already emit 2-3 extra instructions for the check anyway.
+void
+aarch64_split_stack_space_check (rtx size, rtx label)
{
+ rtx mem, ssvalue, cc, cmp, jump, temp;
+ rtx requested = gen_reg_rtx (Pmode);
+ /* Offset from thread pointer to __private_ss. */
+ int psso = 0x10;
+
+ /* Load __private_ss from TCB. */
+ ssvalue = gen_rtx_REG (Pmode, R9_REGNUM);
ssvalue doesn't need to be a hardcoded register.
+ emit_insn (gen_aarch64_load_tp_hard (ssvalue));
+ mem = gen_rtx_MEM (Pmode, plus_constant (Pmode, ssvalue, psso));
+ emit_move_insn (ssvalue, mem);
+
+ temp = gen_rtx_REG (Pmode, R10_REGNUM);
+
+ /* And compare it with frame pointer plus required stack. */
+ size = force_reg (Pmode, size);
+ emit_move_insn (requested, gen_rtx_MINUS (Pmode, stack_pointer_rtx, size));
+
+ /* Jump to __morestack call if current __private_ss is not suffice. */
+ cc = aarch64_gen_compare_reg (LT, temp, ssvalue);
This uses X10, but where is it set???
+ cmp = gen_rtx_fmt_ee (GEU, VOIDmode, cc, const0_rtx);
+ jump = emit_jump_insn (gen_condjump (cmp, cc, label));
+ JUMP_LABEL (jump) = label;
+}
So neither X10 nor X12 are set before potentially calling __morestack, so I don't
think it will work. Could this be causing the crash you mentioned?
Wilco