[PATCH RFA] vec: Fix --enable-gather-detailed-mem-stats
Jason Merrill
jason@redhat.com
Tue Oct 5 18:44:38 GMT 2021
On 10/5/21 07:27, Richard Biener wrote:
> On Mon, Oct 4, 2021 at 8:28 PM Jason Merrill via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> When r12-4038 introduced the global auto_vec save_opt_decoded_options,
>> it broke compilers configured with --enable-gather-detailed-mem-stats,
>> due to the memory descriptors getting discarded before the auto_vec was
>> destroyed. Attached below are two approaches to making this work,
>> either by using the init_priority attribute, or turning vec_mem_desc
>> into a singleton function. I prefer the first one, primarily because it
>> doesn't require auto_vec variables to force immediate allocation. It
>> relies on a G++ extension, but I figure that's OK for code that is only
>> exercised with a debugging configure flag.
>>
>> Thoughts? Either one OK for trunk?
>
> Hmm, isn't the way to fix this to turn the global auto_vec into
> vec<> *x and allocate it at runtime (thus explicitly mange its
> lifetime?). We don't want global CTORs/DTORs in general
> because of startup cost and of course those pesky ordering issues...
That is the usual approach, yes. I was giving up on that, but perhaps
it's better to stick with it. Martin, want to make that fix for
save_opt_decoded_options?
> Oh, and maybe we can make
>
> static mem_alloc_description <vec_usage> vec_mem_desc;
>
> statically initialized with some C++? (constexpr? constinit? whatever?
It can't be statically initialized, because it needs to allocate
multiple maps.
Jason
More information about the Gcc-patches
mailing list