This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add a param to decide stack slot sharing at -O0

On Wed, Oct 9, 2013 at 4:11 AM, Richard Biener
<> wrote:
> On Tue, Oct 8, 2013 at 11:04 PM, Easwaran Raman <> wrote:
>> In cfgexpand.c, variables in non-overlapping lexical scopes are
>> assigned same stack locations at -O1 and above. At -O0, this is
>> attempted only if the size of the stack objects is above a threshold
>> (32). The rationale is at -O0, more variables are going to be in the
>> stack and the O(n^2) stack slot sharing algorithm will increase the
>> compilation time. This patch replaces the constant with a param which
>> is set to 32 by default. We ran into a case where the presence of
>> always_inline attribute triggered Wframe-larger-than warnings at -O0
>> but not at -O2 since the different inlined copies share the stack. We
>> are ok with a slight increase in compilation time to get smaller stack
>> frames even at -O0 and this patch would allow us do that easily.
>> Bootstraps on x86_64/linux. Is this ok for trunk?
> Ok with
> +         "min-size-for-stack-sharing",
> +         "Attempt to share stack slots among variables in different
> lexical blocks "
> +         "at O0 only if their sizes exceed this value",
> +         32, 0, 0)
> changed to
>            "The minimum size of variables taking part in stack slot sharing "
>            "when not optimizing"
>            32, 0, 0)
> And with adding documentation for that param in doc/invoke.texi.
> Btw, I'm not sure the sharing algorithm is still quadratic - can you
> investigate on that?

The partition_stack_vars is still quadratic in worst case (all live
ranges overlap), but the expensive part is likely to be the
add_scope_conflicts function.

- Easwaran

> Thanks,
> Richard.
>> Thanks,
>> Easwaran
>> 2013-10-08  Easwaran Raman <>
>>         * params.def (PARAM_MIN_SIZE_FOR_STACK_SHARING): New param...
>>         * cfgexpand.c (defer_stack_allocation): ...use here

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]