On Mon, 9 Jun 2025, Jakub Jelinek wrote: > Hi! > > For C++26 P2786R13 I'm afraid I'll need 4 new flags on class types > in struct lang_type (1 bit for trivially_relocatable_if_eligible, > 1 for replaceable_if_eligible, 1 for not_trivially_relocatable and > 1 for not_replaceable) and there are just 2 bits left. > > The following patch is an attempt to save 8 bytes of memory > in those structures when not compiling ObjC or ObjC++ (I think those > are used fairly rarely and the patch keeps the sizes unmodified for > those 2). The old allocations were 32 bytes for C and 120 bytes > for C++. The patch moves the objc_info member last in the C++ case > (it was already last in the C case), arranges for GC to skip it > for C and C++ but walk for ObjC and ObjC++ and allocates or > copies over just offsetof bytes instead of sizeof. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2025-06-09 Jakub Jelinek <ja...@redhat.com> > > gcc/c/ > * c-lang.h (union lang_type::maybe_objc_info): New type. > (struct lang_type): Use union maybe_objc_info info member > instead of tree objc_info. > * c-decl.cc (finish_struct): Allocate struct lang_type using > ggc_internal_cleared_alloc instead of ggc_cleared_alloc, > and use sizeof (struct lang_type) for ObjC and otherwise > offsetof (struct lang_type, info) as size. > (finish_enum): Likewise.
The C changes are OK. -- Joseph S. Myers josmy...@redhat.com