Re: jsonapi: scary new warnings with LTO enabled - Mailing list pgsql-hackers

From Tom Lane
Subject Re: jsonapi: scary new warnings with LTO enabled
Date
Msg-id 2078511.1744841564@sss.pgh.pa.us
Whole thread Raw
In response to Re: jsonapi: scary new warnings with LTO enabled  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: jsonapi: scary new warnings with LTO enabled
List pgsql-hackers
Daniel Gustafsson <daniel@yesql.se> writes:
>> On 16 Apr 2025, at 23:42, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm not sure
>> how other than giving up on stack allocation of JsonLexContexts,
>> though, especially if we consider the jsonapi API frozen.  But seeing
>> that there are only three such call sites and none of them seem in the
>> least performance-critical, maybe we should just do that?

> I can't see any other option really, and there is no performance angle really
> so that should be safe.  Since I committed at least one of these, let me know
> if you want me to tackle it.

The only alternative I can see that might stop the warning is if we
can find a way to make it clearer to the optimizer that the FREE()
isn't reached.  But I'm not sure about a trustworthy way to make that
happen.  Maybe it'd work to change the signature of freeJsonLexContext
(or perhaps better, add a separate entry point) so that the caller is
passing a bool constant that controls whether to free the struct.
We could have an Assert that compares that to the state of the
JSONLEX_FREE_STRUCT flag to catch mistakes.  This seems kind of messy
though.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: jsonapi: scary new warnings with LTO enabled
Next
From: Ranier Vilela
Date:
Subject: Re: jsonapi: scary new warnings with LTO enabled