Re: RFA: Add a target_globals destructor
On Mon, Sep 8, 2014 at 5:21 PM, Richard Sandiford wrote: > This is a prerequisite for a cleaned-up version of the patch in: > https://gcc.gnu.org/ml/gcc/2014-03/msg00163.html . Thanks to Trevor's > recent(ish) changes, it's now possible for GC structures to have > destructors. This means that we can go back to xmalloc()ing the parts > of target_globals that don't point to GCed data. > > Also, some non-GC default_* variables had redundant GTY markers. > > Tested on x86_64-linux-gnu. OK to install? Ok. Thanks, Richard. > Richard > > > gcc/ > * bb-reorder.h (default_target_bb_reorder): Remove redundant GTY. > * builtins.h (default_target_builtins): Likewise. > * gcse.h (default_target_gcse): Likewise. > * target-globals.h (target_globals): Add a destructor. Convert > void-pointer fields back to their real type and change from > GTY((atomic)) to GTY((skip)). > (restore_target_globals): Remove casts accordingly. > * target-globals.c (save_target_globals): Use XCNEW rather than > ggc_internal_cleared_alloc to allocate non-GC structures. > Use ggc_cleared_alloc to allocate the target_globals structure > itself. > (target_globals::~target_globals): Define. > > Index: gcc/bb-reorder.h > === > --- gcc/bb-reorder.h2014-09-05 16:07:26.791345611 +0100 > +++ gcc/bb-reorder.h2014-09-05 16:07:26.787345661 +0100 > @@ -26,7 +26,7 @@ struct target_bb_reorder { >int x_uncond_jump_length; > }; > > -extern GTY(()) struct target_bb_reorder default_target_bb_reorder; > +extern struct target_bb_reorder default_target_bb_reorder; > #if SWITCHABLE_TARGET > extern struct target_bb_reorder *this_target_bb_reorder; > #else > Index: gcc/builtins.h > === > --- gcc/builtins.h 2014-09-05 16:07:26.791345611 +0100 > +++ gcc/builtins.h 2014-09-05 16:07:26.787345661 +0100 > @@ -39,7 +39,7 @@ struct target_builtins { >enum machine_mode x_apply_result_mode[FIRST_PSEUDO_REGISTER]; > }; > > -extern GTY(()) struct target_builtins default_target_builtins; > +extern struct target_builtins default_target_builtins; > #if SWITCHABLE_TARGET > extern struct target_builtins *this_target_builtins; > #else > Index: gcc/gcse.h > === > --- gcc/gcse.h 2014-09-05 16:07:26.791345611 +0100 > +++ gcc/gcse.h 2014-09-05 16:07:26.787345661 +0100 > @@ -32,7 +32,7 @@ struct target_gcse { >bool x_can_copy_init_p; > }; > > -extern GTY(()) struct target_gcse default_target_gcse; > +extern struct target_gcse default_target_gcse; > #if SWITCHABLE_TARGET > extern struct target_gcse *this_target_gcse; > #else > Index: gcc/target-globals.h > === > --- gcc/target-globals.h2014-09-05 16:07:26.791345611 +0100 > +++ gcc/target-globals.h2014-09-05 16:07:26.787345661 +0100 > @@ -40,18 +40,20 @@ #define TARGET_GLOBALS_H 1 > #endif > > struct GTY(()) target_globals { > + ~target_globals (); > + >struct target_flag_state *GTY((skip)) flag_state; > - void *GTY((atomic)) regs; > + struct target_regs *GTY((skip)) regs; >struct target_rtl *rtl; > - void *GTY((atomic)) recog; > - void *GTY((atomic)) hard_regs; > - void *GTY((atomic)) reload; > - void *GTY((atomic)) expmed; > + struct target_recog *GTY((skip)) recog; > + struct target_hard_regs *GTY((skip)) hard_regs; > + struct target_reload *GTY((skip)) reload; > + struct target_expmed *GTY((skip)) expmed; >struct target_optabs *GTY((skip)) optabs; >struct target_libfuncs *libfuncs; >struct target_cfgloop *GTY((skip)) cfgloop; > - void *GTY((atomic)) ira; > - void *GTY((atomic)) ira_int; > + struct target_ira *GTY((skip)) ira; > + struct target_ira_int *GTY((skip)) ira_int; >struct target_builtins *GTY((skip)) builtins; >struct target_gcse *GTY((skip)) gcse; >struct target_bb_reorder *GTY((skip)) bb_reorder; > @@ -68,17 +70,17 @@ extern struct target_globals *save_targe > restore_target_globals (struct target_globals *g) > { >this_target_flag_state = g->flag_state; > - this_target_regs = (struct target_regs *) g->regs; > + this_target_regs = g->regs; >this_target_rtl = g->rtl; > - this_target_recog = (struct target_recog *) g->recog; > - this_target_hard_regs = (struct target_hard_regs *) g->hard_regs; > - this_target_reload = (struct target_reload *) g->reload; > - this_target_expmed = (struct target_expmed *) g->expmed; > + this_target_recog = g->recog; > + this_target_hard_regs = g->hard_regs; > + this_target_reload = g->reload; > + this_target_expmed = g->expmed; >this_target_optabs = g->optabs; >this_target_libfuncs = g->libfuncs; >this_target_cfgloop = g->cfgloop; > - this_target_ira = (struct target_ira *) g->ira; > - this_target_ira_int =
RFA: Add a target_globals destructor
This is a prerequisite for a cleaned-up version of the patch in: https://gcc.gnu.org/ml/gcc/2014-03/msg00163.html . Thanks to Trevor's recent(ish) changes, it's now possible for GC structures to have destructors. This means that we can go back to xmalloc()ing the parts of target_globals that don't point to GCed data. Also, some non-GC default_* variables had redundant GTY markers. Tested on x86_64-linux-gnu. OK to install? Richard gcc/ * bb-reorder.h (default_target_bb_reorder): Remove redundant GTY. * builtins.h (default_target_builtins): Likewise. * gcse.h (default_target_gcse): Likewise. * target-globals.h (target_globals): Add a destructor. Convert void-pointer fields back to their real type and change from GTY((atomic)) to GTY((skip)). (restore_target_globals): Remove casts accordingly. * target-globals.c (save_target_globals): Use XCNEW rather than ggc_internal_cleared_alloc to allocate non-GC structures. Use ggc_cleared_alloc to allocate the target_globals structure itself. (target_globals::~target_globals): Define. Index: gcc/bb-reorder.h === --- gcc/bb-reorder.h2014-09-05 16:07:26.791345611 +0100 +++ gcc/bb-reorder.h2014-09-05 16:07:26.787345661 +0100 @@ -26,7 +26,7 @@ struct target_bb_reorder { int x_uncond_jump_length; }; -extern GTY(()) struct target_bb_reorder default_target_bb_reorder; +extern struct target_bb_reorder default_target_bb_reorder; #if SWITCHABLE_TARGET extern struct target_bb_reorder *this_target_bb_reorder; #else Index: gcc/builtins.h === --- gcc/builtins.h 2014-09-05 16:07:26.791345611 +0100 +++ gcc/builtins.h 2014-09-05 16:07:26.787345661 +0100 @@ -39,7 +39,7 @@ struct target_builtins { enum machine_mode x_apply_result_mode[FIRST_PSEUDO_REGISTER]; }; -extern GTY(()) struct target_builtins default_target_builtins; +extern struct target_builtins default_target_builtins; #if SWITCHABLE_TARGET extern struct target_builtins *this_target_builtins; #else Index: gcc/gcse.h === --- gcc/gcse.h 2014-09-05 16:07:26.791345611 +0100 +++ gcc/gcse.h 2014-09-05 16:07:26.787345661 +0100 @@ -32,7 +32,7 @@ struct target_gcse { bool x_can_copy_init_p; }; -extern GTY(()) struct target_gcse default_target_gcse; +extern struct target_gcse default_target_gcse; #if SWITCHABLE_TARGET extern struct target_gcse *this_target_gcse; #else Index: gcc/target-globals.h === --- gcc/target-globals.h2014-09-05 16:07:26.791345611 +0100 +++ gcc/target-globals.h2014-09-05 16:07:26.787345661 +0100 @@ -40,18 +40,20 @@ #define TARGET_GLOBALS_H 1 #endif struct GTY(()) target_globals { + ~target_globals (); + struct target_flag_state *GTY((skip)) flag_state; - void *GTY((atomic)) regs; + struct target_regs *GTY((skip)) regs; struct target_rtl *rtl; - void *GTY((atomic)) recog; - void *GTY((atomic)) hard_regs; - void *GTY((atomic)) reload; - void *GTY((atomic)) expmed; + struct target_recog *GTY((skip)) recog; + struct target_hard_regs *GTY((skip)) hard_regs; + struct target_reload *GTY((skip)) reload; + struct target_expmed *GTY((skip)) expmed; struct target_optabs *GTY((skip)) optabs; struct target_libfuncs *libfuncs; struct target_cfgloop *GTY((skip)) cfgloop; - void *GTY((atomic)) ira; - void *GTY((atomic)) ira_int; + struct target_ira *GTY((skip)) ira; + struct target_ira_int *GTY((skip)) ira_int; struct target_builtins *GTY((skip)) builtins; struct target_gcse *GTY((skip)) gcse; struct target_bb_reorder *GTY((skip)) bb_reorder; @@ -68,17 +70,17 @@ extern struct target_globals *save_targe restore_target_globals (struct target_globals *g) { this_target_flag_state = g->flag_state; - this_target_regs = (struct target_regs *) g->regs; + this_target_regs = g->regs; this_target_rtl = g->rtl; - this_target_recog = (struct target_recog *) g->recog; - this_target_hard_regs = (struct target_hard_regs *) g->hard_regs; - this_target_reload = (struct target_reload *) g->reload; - this_target_expmed = (struct target_expmed *) g->expmed; + this_target_recog = g->recog; + this_target_hard_regs = g->hard_regs; + this_target_reload = g->reload; + this_target_expmed = g->expmed; this_target_optabs = g->optabs; this_target_libfuncs = g->libfuncs; this_target_cfgloop = g->cfgloop; - this_target_ira = (struct target_ira *) g->ira; - this_target_ira_int = (struct target_ira_int *) g->ira_int; + this_target_ira = g->ira; + this_target_ira_int = g->ira_int; this_target_builtins = g->builtins; this_target_gcse = g->gcse; this_target_bb_reorder = g->bb_reorder; Index: gcc/target-globals.c =