This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Enhance support for -Wstack-usage/-Wvla-larger-than/-Walloca-larger-than
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 19 Oct 2017 13:07:10 +0200
- Subject: Re: [patch] Enhance support for -Wstack-usage/-Wvla-larger-than/-Walloca-larger-than
- Authentication-results: sourceware.org; auth=none
- References: <29004893.lAlsAOZA3D@polaris> <CAFiYyc3otvAyDK2T=3EJ4nFrV8hC-fB2Zps1ajkhPaSbX6wbmw@mail.gmail.com> <2419282.B7VBLFYQk7@polaris>
On Thu, Oct 19, 2017 at 12:28 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Looks ok. I wonder if you want to explicitely document that max_size < size
>> doesn't have any effect on actual code generation and is not checked for.
>
> Documentation amended to that effect:
>
> -- Built-in Function: void *__builtin_alloca_with_align_and_max
> (size_t size, size_t alignment, size_t max_size)
> Similar to `__builtin_alloca_with_align' but takes an extra
> argument specifying an upper bound for SIZE in case its value
> cannot be computed at compile time, for use by `-fstack-usage',
> `-Wstack-usage' and `-Walloca-larger-than' computations. MAX_SIZE
> has no effect on code generation and no attempt is made to check
> its compatibility with SIZE.
works for me.
>> Also it seems that __builtin_alloca_with_align (20, 8, 16) will still
>> account 20 as the size and not 16 compared to 20 arriving in a variable
>> which is when 16 will be used. So at least for accounting always use MIN
>> (size, max_size)?
>
> The implementation is in keeping with the above documentation, i.e. SIZE will
> prevail if its value can be computed at compile time.
OK. Just wanted to mention it, there'll likely be cases where -O0 then
reports a smaller stack usage than -O2 because of this.
Thanks,
Richard.
> --
> Eric Botcazou