On Tue, Jan 30, 2018 at 06:50:50AM -0600, Aaron Sawdey wrote:
> > Anyway, my preference would be to change that gen_rtx_PLUS into
> >   stack_parm = crtl->args.internal_arg_pointer;
> >   if (!CONST_INT_P (offset_rtx))
> >     stack_parm = gen_rtx_PLUS (Pmode, stack_parm, offset_rtx);
> >   else if (offset_rtx != const0_rtx)
> >     stack_parm = plus_constant (Pmode, stack_parm, INTVAL
> > (offset_rtx));
> >   stack_parm = gen_rtx_MEM (data->promoted_mode, stack_parm);
> > and deal specially with GET_CODE (crtl->args.internal_arg_pointer)
> > in var-tracking.c.
> > rs6000/powerpcspe with -fsplit-stack are the only cases where
> > crtl->args.internal_arg_pointer is not a REG, so just running libgo
> > testsuite on powerpc{,64,64le} should cover it all.
> 
> I'll give this a try today when I get to the office.

On IRC when discussing it with Segher this morning we've come to the
conclusion that it would be best if rs6000 just followed what all other
ports to, i.e. return a pseudo from the target hook, like:

--- gcc/config/rs6000/rs6000.c  2018-01-30 12:30:27.416360076 +0100
+++ gcc/config/rs6000/rs6000.c  2018-01-30 13:59:07.360639803 +0100
@@ -29602,8 +29602,9 @@ rs6000_internal_arg_pointer (void)
          emit_insn_after (pat, get_insns ());
          pop_topmost_sequence ();
        }
-      return plus_constant (Pmode, cfun->machine->split_stack_arg_pointer,
-                           FIRST_PARM_OFFSET (current_function_decl));
+      rtx ret = plus_constant (Pmode, cfun->machine->split_stack_arg_pointer,
+                              FIRST_PARM_OFFSET (current_function_decl));
+      return copy_to_reg (ret);
     }
   return virtual_incoming_args_rtx;
 }

copy_to_reg is what e.g. the generic or pa target hook conditionally uses.

Optionally, check also whether the
          push_topmost_sequence ();
          emit_insn_after (pat, get_insns ());
          pop_topmost_sequence ();
stuff is needed instead of just
        emit_insn (pat);
and whether it needs to be guarded with cfun->machine->split_stack_arg_pointer
== NULL, because the target hook is called exactly once for each function.

        Jakub

Reply via email to