Re: jsonapi: scary new warnings with LTO enabled

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: jsonapi: scary new warnings with LTO enabled
Date: 2025-04-17 11:43:18
Message-ID: 0A596D8B-24F3-408F-B89B-B42014B00A05@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 17 Apr 2025, at 01:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> writes:
>> On Wed, Apr 16, 2025 at 4:04 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Looking through all of the callers of freeJsonLexContext, quite
>>> a lot of them use local JsonLexContext structs, and probably some
>>> of them are more performance-critical than these. So that raises
>>> the question of why are we seeing warnings for only these call
>>> sites?
>
>> Yeah, I had the same question...
>
> After making another pass through the callers of freeJsonLexContext,
> I observe that the warnings appear in callers that use a local
> variable *and* contain goto statements. So I'm betting that the
> presence of goto's causes the LTO optimizer to pull in its horns
> quite a bit and thereby fail to detect the flag correlation.

That seems plausible given the selective warnings.

>>> Maybe there is a more elegant way to suppress them.
>
>> Can we brute-force ignore this particular warning site with a #pragma
>> (suggested in [1])?
>
> That's surely not elegant :-(. However, I don't especially want to
> rewrite away the goto's in these callers ...

Agreed, moving to heap allocated structures for these callsites seem much
better. Something like the attached should be enough I think?

--
Daniel Gustafsson

Attachment Content-Type Size
0001-Allocate-JsonLexContexts-on-the-heap-to-avoid-warnin.patch application/octet-stream 5.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rahila Syed 2025-04-17 12:25:04 Re: Align memory context level numbering in pg_log_backend_memory_contexts()
Previous Message Daniel Gustafsson 2025-04-17 11:32:06 Re: Missing comma in libpq.sgml