From: Richard Sandiford Date: Tue, 9 Sep 2014 12:12:06 +0000 (+0000) Subject: bb-reorder.h (default_target_bb_reorder): Remove redundant GTY. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1942d1a9e17406469aef7d38e927dd7a14f5b376;p=gcc.git bb-reorder.h (default_target_bb_reorder): Remove redundant GTY. 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. From-SVN: r215063 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be964cbcfce..ad2092b770f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2014-09-09 Richard Sandiford + + * 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. + 2014-09-09 Kyrylo Tkachov * config/arm/arm.md (vfp_pop_multiple_with_writeback): Use vldm diff --git a/gcc/bb-reorder.h b/gcc/bb-reorder.h index 4dbb56f1e80..1200f0fc7e8 100644 --- a/gcc/bb-reorder.h +++ b/gcc/bb-reorder.h @@ -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 diff --git a/gcc/builtins.h b/gcc/builtins.h index cac2de6a06f..dd1cdbcec7e 100644 --- a/gcc/builtins.h +++ b/gcc/builtins.h @@ -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 diff --git a/gcc/gcse.h b/gcc/gcse.h index 8589808dcb7..1b8c1c65a2b 100644 --- a/gcc/gcse.h +++ b/gcc/gcse.h @@ -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 diff --git a/gcc/target-globals.c b/gcc/target-globals.c index ac661623fc6..5a9843f6bb9 100644 --- a/gcc/target-globals.c +++ b/gcc/target-globals.c @@ -67,37 +67,23 @@ struct target_globals default_target_globals = { struct target_globals * save_target_globals (void) { - struct target_globals *g; - struct target_globals_extra { - struct target_globals g; - struct target_flag_state flag_state; - struct target_optabs optabs; - struct target_cfgloop cfgloop; - struct target_builtins builtins; - struct target_gcse gcse; - struct target_bb_reorder bb_reorder; - struct target_lower_subreg lower_subreg; - } *p; - p = (struct target_globals_extra *) - ggc_internal_cleared_alloc (sizeof (struct target_globals_extra)); - g = (struct target_globals *) p; - g->flag_state = &p->flag_state; - g->regs = ggc_internal_cleared_alloc (sizeof (struct target_regs)); + struct target_globals *g = ggc_cleared_alloc (); + g->flag_state = XCNEW (struct target_flag_state); + g->regs = XCNEW (struct target_regs); g->rtl = ggc_cleared_alloc (); - g->recog = ggc_internal_cleared_alloc (sizeof (struct target_recog)); - g->hard_regs - = ggc_internal_cleared_alloc (sizeof (struct target_hard_regs)); - g->reload = ggc_internal_cleared_alloc (sizeof (struct target_reload)); - g->expmed = ggc_internal_cleared_alloc (sizeof (struct target_expmed)); - g->optabs = &p->optabs; + g->recog = XCNEW (struct target_recog); + g->hard_regs = XCNEW (struct target_hard_regs); + g->reload = XCNEW (struct target_reload); + g->expmed = XCNEW (struct target_expmed); + g->optabs = XCNEW (struct target_optabs); g->libfuncs = ggc_cleared_alloc (); - g->cfgloop = &p->cfgloop; - g->ira = ggc_internal_cleared_alloc (sizeof (struct target_ira)); - g->ira_int = ggc_internal_cleared_alloc (sizeof (struct target_ira_int)); - g->builtins = &p->builtins; - g->gcse = &p->gcse; - g->bb_reorder = &p->bb_reorder; - g->lower_subreg = &p->lower_subreg; + g->cfgloop = XCNEW (struct target_cfgloop); + g->ira = XCNEW (struct target_ira); + g->ira_int = XCNEW (struct target_ira_int); + g->builtins = XCNEW (struct target_builtins); + g->gcse = XCNEW (struct target_gcse); + g->bb_reorder = XCNEW (struct target_bb_reorder); + g->lower_subreg = XCNEW (struct target_lower_subreg); restore_target_globals (g); init_reg_sets (); target_reinit (); @@ -133,4 +119,26 @@ save_target_globals_default_opts () return save_target_globals (); } +target_globals::~target_globals () +{ + /* default_target_globals points to static data so shouldn't be freed. */ + if (this != &default_target_globals) + { + XDELETE (flag_state); + XDELETE (regs); + XDELETE (recog); + XDELETE (hard_regs); + XDELETE (reload); + XDELETE (expmed); + XDELETE (optabs); + XDELETE (cfgloop); + XDELETE (ira); + XDELETE (ira_int); + XDELETE (builtins); + XDELETE (gcse); + XDELETE (bb_reorder); + XDELETE (lower_subreg); + } +} + #endif diff --git a/gcc/target-globals.h b/gcc/target-globals.h index 4e1a9480777..fc9d36eae15 100644 --- a/gcc/target-globals.h +++ b/gcc/target-globals.h @@ -40,18 +40,20 @@ extern struct target_lower_subreg *this_target_lower_subreg; #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 @@ static inline void 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;