* [PATCH] Fix PR66870 ppc64le, ppc64 split stack
@ 2015-07-30 21:10 Lynn A. Boger
2015-07-31 8:11 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Lynn A. Boger @ 2015-07-30 21:10 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 732 bytes --]
The attached patch fixes a problem identified in PR66870 with
split stack on ppc64 and ppc64le. If flag_split_stack is true, but
the function being processed has the no_split_stack attribute, then
the split stack prologue should not be generated.
Bootstrapped on ppc64le-linux and ppc64-linux, passed the
go and libgo testsuites (where split stack is enabled by default).
gcc/ChangeLog
2015-07-30 Lynn Boger <laboger@linux.vnet.ibm.com>
PR66870
* gcc/config/rs6000/rs6000.c: Add check for no_split_stack
function attribute along with flag_split_stack check to
determine when to generate split stack prologue for
ppc64 and ppc64le.
[-- Attachment #2: gccgo-no-split-stack-fix.diff --]
[-- Type: text/x-patch, Size: 2200 bytes --]
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 226401)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -23736,6 +23736,10 @@ rs6000_emit_prologue (void)
int using_static_chain_p = (cfun->static_chain_decl != NULL_TREE
&& df_regs_ever_live_p (STATIC_CHAIN_REGNUM)
&& call_used_regs[STATIC_CHAIN_REGNUM]);
+ int using_split_stack = flag_split_stack &&
+ (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
+ == NULL);
+
/* Offset to top of frame for frame_reg and sp respectively. */
HOST_WIDE_INT frame_off = 0;
HOST_WIDE_INT sp_off = 0;
@@ -24006,7 +24010,7 @@ rs6000_emit_prologue (void)
&& info->cr_save_p
&& REGNO (frame_reg_rtx) != cr_save_regno
&& !(using_static_chain_p && cr_save_regno == 11)
- && !(flag_split_stack && cr_save_regno == 12 && sp_adjust))
+ && !(using_split_stack && cr_save_regno == 12 && sp_adjust))
{
cr_save_rtx = gen_rtx_REG (SImode, cr_save_regno);
START_USE (cr_save_regno);
@@ -24584,7 +24588,7 @@ rs6000_emit_prologue (void)
if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
&& !using_static_chain_p)
save_regno = 11;
- else if (flag_split_stack || REGNO (frame_reg_rtx) == 12)
+ else if (using_split_stack || REGNO (frame_reg_rtx) == 12)
{
save_regno = 11;
if (using_static_chain_p)
@@ -24687,7 +24691,7 @@ rs6000_emit_prologue (void)
emit_insn (gen_frame_store (reg, sp_reg_rtx, RS6000_TOC_SAVE_SLOT));
}
- if (flag_split_stack && split_stack_arg_pointer_used_p ())
+ if (using_split_stack && split_stack_arg_pointer_used_p ())
{
/* Set up the arg pointer (r12) for -fsplit-stack code. If
__morestack was called, it left the arg pointer to the old
@@ -26274,7 +26278,10 @@ rs6000_expand_split_stack_prologue (void)
static rtx
rs6000_internal_arg_pointer (void)
{
- if (flag_split_stack)
+ if (flag_split_stack
+ && (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
+ == NULL))
+
{
if (cfun->machine->split_stack_arg_pointer == NULL_RTX)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix PR66870 ppc64le, ppc64 split stack
2015-07-30 21:10 [PATCH] Fix PR66870 ppc64le, ppc64 split stack Lynn A. Boger
@ 2015-07-31 8:11 ` Alan Modra
2015-07-31 9:31 ` David Edelsohn
0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2015-07-31 8:11 UTC (permalink / raw)
To: Lynn A. Boger, David Edelsohn; +Cc: gcc-patches
On Thu, Jul 30, 2015 at 03:30:12PM -0500, Lynn A. Boger wrote:
> PR66870
> * gcc/config/rs6000/rs6000.c: Add check for no_split_stack
> function attribute along with flag_split_stack check to
> determine when to generate split stack prologue for
> ppc64 and ppc64le.
Looks good to me, except that the changelog entry should mention the
modified functions, for example:
PR target/66870
* gcc/config/rs6000/rs6000.c (rs6000_emit_prologue): Check for
no_split_stack function attribute along with flag_split_stack.
(rs6000_expand_split_stack_prologue): Likewise.
Also, formatting rules for gcc say to not split a line after an
operator.
> + int using_split_stack = flag_split_stack &&
> + (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
> + == NULL);
The "&&" belongs on the next line, with parentheses added so that emacs
and indent will line up the continuation nicely.
int using_split_stack = (flag_split_stack
&& (lookup_attribute ("no_split_stack",
DECL_ATTRIBUTES (cfun->decl))
== NULL));
David, the following is another piece of the PR66870 fixes. This
stops shrink-wrap from moving insns around in the first few blocks of
a function, in a way that is incorrect given that r12 is live.
Bootstrapped and regression tested powerpc64le-linux (and
powerpc64-linux by Lynn).
PR target/66870
* config/rs6000/rs6000.c (machine_function): Add split_stack_argp_used.
(rs6000_emit_prologue): Set it.
(rs6000_set_up_by_prologue): Specify r12 when split_stack_argp_used.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 5d9ff88..dc2e20c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -166,6 +166,7 @@ typedef struct GTY(()) machine_function
rtx sdmode_stack_slot;
/* Alternative internal arg pointer for -fsplit-stack. */
rtx split_stack_arg_pointer;
+ bool split_stack_argp_used;
/* Flag if r2 setup is needed with ELFv2 ABI. */
bool r2_setup_needed;
} machine_function;
@@ -24458,6 +24459,7 @@ rs6000_emit_prologue (void)
__morestack was called, it left the arg pointer to the old
stack in r29. Otherwise, the arg pointer is the top of the
current frame. */
+ cfun->machine->split_stack_argp_used = true;
if (sp_adjust)
{
rtx r12 = gen_rtx_REG (Pmode, 12);
@@ -33711,6 +33713,8 @@ rs6000_set_up_by_prologue (struct hard_reg_set_container *set)
&& TARGET_MINIMAL_TOC
&& get_pool_size () != 0)
add_to_hard_reg_set (&set->set, Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
+ if (cfun->machine->split_stack_argp_used)
+ add_to_hard_reg_set (&set->set, Pmode, 12);
}
\f
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix PR66870 ppc64le, ppc64 split stack
2015-07-31 8:11 ` Alan Modra
@ 2015-07-31 9:31 ` David Edelsohn
2015-08-05 1:22 ` Lynn Boger
0 siblings, 1 reply; 4+ messages in thread
From: David Edelsohn @ 2015-07-31 9:31 UTC (permalink / raw)
To: Alan Modra; +Cc: Lynn A. Boger, gcc-patches
On Fri, Jul 31, 2015 at 12:00 AM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Jul 30, 2015 at 03:30:12PM -0500, Lynn A. Boger wrote:
>> PR66870
>> * gcc/config/rs6000/rs6000.c: Add check for no_split_stack
>> function attribute along with flag_split_stack check to
>> determine when to generate split stack prologue for
>> ppc64 and ppc64le.
>
> Looks good to me, except that the changelog entry should mention the
> modified functions, for example:
>
> PR target/66870
> * gcc/config/rs6000/rs6000.c (rs6000_emit_prologue): Check for
> no_split_stack function attribute along with flag_split_stack.
> (rs6000_expand_split_stack_prologue): Likewise.
>
> Also, formatting rules for gcc say to not split a line after an
> operator.
>
>> + int using_split_stack = flag_split_stack &&
>> + (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
>> + == NULL);
>
> The "&&" belongs on the next line, with parentheses added so that emacs
> and indent will line up the continuation nicely.
>
> int using_split_stack = (flag_split_stack
> && (lookup_attribute ("no_split_stack",
> DECL_ATTRIBUTES (cfun->decl))
> == NULL));
>
>
> David, the following is another piece of the PR66870 fixes. This
> stops shrink-wrap from moving insns around in the first few blocks of
> a function, in a way that is incorrect given that r12 is live.
> Bootstrapped and regression tested powerpc64le-linux (and
> powerpc64-linux by Lynn).
>
> PR target/66870
> * config/rs6000/rs6000.c (machine_function): Add split_stack_argp_used.
> (rs6000_emit_prologue): Set it.
> (rs6000_set_up_by_prologue): Specify r12 when split_stack_argp_used.
Both patches with your suggested changes are okay.
Thanks, David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix PR66870 ppc64le, ppc64 split stack
2015-07-31 9:31 ` David Edelsohn
@ 2015-08-05 1:22 ` Lynn Boger
0 siblings, 0 replies; 4+ messages in thread
From: Lynn Boger @ 2015-08-05 1:22 UTC (permalink / raw)
To: David Edelsohn, Alan Modra; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2416 bytes --]
Updated changelog and attached patch based on Alan's comments.
gcc/ChangeLog
2015-07-30 Lynn Boger <laboger@linux.vnet.ibm.com>
PR66870
* gcc/config/rs6000/rs6000.c (rs6000_emit_prologue): Check for
no_split_stack function attribute along with flag_split_stack.
(rs6000_expand_split_stack_prologue): Likewise.
On 7/31/2015 4:00 AM, David Edelsohn wrote:
> On Fri, Jul 31, 2015 at 12:00 AM, Alan Modra <amodra@gmail.com> wrote:
>> On Thu, Jul 30, 2015 at 03:30:12PM -0500, Lynn A. Boger wrote:
>>> PR66870
>>> * gcc/config/rs6000/rs6000.c: Add check for no_split_stack
>>> function attribute along with flag_split_stack check to
>>> determine when to generate split stack prologue for
>>> ppc64 and ppc64le.
>> Looks good to me, except that the changelog entry should mention the
>> modified functions, for example:
>>
>> PR target/66870
>> * gcc/config/rs6000/rs6000.c (rs6000_emit_prologue): Check for
>> no_split_stack function attribute along with flag_split_stack.
>> (rs6000_expand_split_stack_prologue): Likewise.
>>
>> Also, formatting rules for gcc say to not split a line after an
>> operator.
>>
>>> + int using_split_stack = flag_split_stack &&
>>> + (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
>>> + == NULL);
>> The "&&" belongs on the next line, with parentheses added so that emacs
>> and indent will line up the continuation nicely.
>>
>> int using_split_stack = (flag_split_stack
>> && (lookup_attribute ("no_split_stack",
>> DECL_ATTRIBUTES (cfun->decl))
>> == NULL));
>>
>>
>> David, the following is another piece of the PR66870 fixes. This
>> stops shrink-wrap from moving insns around in the first few blocks of
>> a function, in a way that is incorrect given that r12 is live.
>> Bootstrapped and regression tested powerpc64le-linux (and
>> powerpc64-linux by Lynn).
>>
>> PR target/66870
>> * config/rs6000/rs6000.c (machine_function): Add split_stack_argp_used.
>> (rs6000_emit_prologue): Set it.
>> (rs6000_set_up_by_prologue): Specify r12 when split_stack_argp_used.
> Both patches with your suggested changes are okay.
>
> Thanks, David
>
>
[-- Attachment #2: gccgo-no-split-stack-review.diff --]
[-- Type: text/plain, Size: 2283 bytes --]
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 226606)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -23748,6 +23748,11 @@
int using_static_chain_p = (cfun->static_chain_decl != NULL_TREE
&& df_regs_ever_live_p (STATIC_CHAIN_REGNUM)
&& call_used_regs[STATIC_CHAIN_REGNUM]);
+ int using_split_stack = (flag_split_stack
+ && (lookup_attribute ("no_split_stack",
+ DECL_ATTRIBUTES (cfun->decl))
+ == NULL));
+
/* Offset to top of frame for frame_reg and sp respectively. */
HOST_WIDE_INT frame_off = 0;
HOST_WIDE_INT sp_off = 0;
@@ -24018,7 +24023,7 @@
&& info->cr_save_p
&& REGNO (frame_reg_rtx) != cr_save_regno
&& !(using_static_chain_p && cr_save_regno == 11)
- && !(flag_split_stack && cr_save_regno == 12 && sp_adjust))
+ && !(using_split_stack && cr_save_regno == 12 && sp_adjust))
{
cr_save_rtx = gen_rtx_REG (SImode, cr_save_regno);
START_USE (cr_save_regno);
@@ -24596,7 +24601,7 @@
if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
&& !using_static_chain_p)
save_regno = 11;
- else if (flag_split_stack || REGNO (frame_reg_rtx) == 12)
+ else if (using_split_stack || REGNO (frame_reg_rtx) == 12)
{
save_regno = 11;
if (using_static_chain_p)
@@ -24699,7 +24704,7 @@
emit_insn (gen_frame_store (reg, sp_reg_rtx, RS6000_TOC_SAVE_SLOT));
}
- if (flag_split_stack && split_stack_arg_pointer_used_p ())
+ if (using_split_stack && split_stack_arg_pointer_used_p ())
{
/* Set up the arg pointer (r12) for -fsplit-stack code. If
__morestack was called, it left the arg pointer to the old
@@ -26287,7 +26292,10 @@
static rtx
rs6000_internal_arg_pointer (void)
{
- if (flag_split_stack)
+ if (flag_split_stack
+ && (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl))
+ == NULL))
+
{
if (cfun->machine->split_stack_arg_pointer == NULL_RTX)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-05 1:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-30 21:10 [PATCH] Fix PR66870 ppc64le, ppc64 split stack Lynn A. Boger
2015-07-31 8:11 ` Alan Modra
2015-07-31 9:31 ` David Edelsohn
2015-08-05 1:22 ` Lynn Boger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).