From 1c252ef3cbf964ce6022e5431de7f264a929a100 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 6 Dec 2018 11:32:09 +0000 Subject: [PATCH] bitmap.c (bitmap_head::crashme): Define. 2018-12-06 Richard Biener * bitmap.c (bitmap_head::crashme): Define. * bitmap.h (bitmap_head): Add constexpr default constructor poisoning the obstack member. (bitmap_head::crashme): Declare. (bitmap_release): New function clearing a bitmap and poisoning the obstack member. * gengtype.c (main): Make it recognize CONSTEXPR. * lra-constraints.c (lra_inheritance): Use bitmap_release instead of bitmap_clear. * ira.c (ira): Work around class-memaccess warning. * regrename.c (create_new_chain): Likewise. From-SVN: r266850 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/bitmap.c | 4 ++++ gcc/bitmap.h | 18 ++++++++++++++++++ gcc/gengtype.c | 1 + gcc/ira.c | 2 +- gcc/lra-constraints.c | 10 +++++----- gcc/regrename.c | 2 +- 7 files changed, 44 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a40d99e..e52f2f9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2018-12-06 Richard Biener + + * bitmap.c (bitmap_head::crashme): Define. + * bitmap.h (bitmap_head): Add constexpr default constructor + poisoning the obstack member. + (bitmap_head::crashme): Declare. + (bitmap_release): New function clearing a bitmap and poisoning + the obstack member. + * gengtype.c (main): Make it recognize CONSTEXPR. + * lra-constraints.c (lra_inheritance): Use bitmap_release + instead of bitmap_clear. + * ira.c (ira): Work around class-memaccess warning. + * regrename.c (create_new_chain): Likewise. + 2018-12-06 Jakub Jelinek PR tree-optimization/85726 diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 0255944..0552579 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -26,6 +26,10 @@ along with GCC; see the file COPYING3. If not see /* Memory allocation statistics purpose instance. */ mem_alloc_description bitmap_mem_desc; +/* Static zero-initialized bitmap obstack used for default initialization + of bitmap_head. */ +bitmap_obstack bitmap_head::crashme; + static bitmap_element *bitmap_tree_listify_from (bitmap, bitmap_element *); /* Register new bitmap. */ diff --git a/gcc/bitmap.h b/gcc/bitmap.h index 9a180da..7499ebe 100644 --- a/gcc/bitmap.h +++ b/gcc/bitmap.h @@ -323,6 +323,12 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) bitmap_element { already pointed to by the chain started by first, so GTY((skip)) it. */ struct GTY(()) bitmap_head { + static bitmap_obstack crashme; + /* Poison obstack to not make it not a valid initialized GC bitmap. */ + CONSTEXPR bitmap_head() + : indx(0), tree_form(false), first(NULL), current(NULL), + obstack (&crashme) + {} /* Index of last element looked at. */ unsigned int indx; /* False if the bitmap is in list form; true if the bitmap is in tree form. @@ -441,6 +447,18 @@ bitmap_initialize (bitmap head, bitmap_obstack *obstack CXX_MEM_STAT_INFO) bitmap_register (head PASS_MEM_STAT); } +/* Release a bitmap (but not its head). This is suitable for pairing with + bitmap_initialize. */ + +static inline void +bitmap_release (bitmap head) +{ + bitmap_clear (head); + /* Poison the obstack pointer so the obstack can be safely released. + Do not zero it as the bitmap then becomes initialized GC. */ + head->obstack = &bitmap_head::crashme; +} + /* Allocate and free bitmaps from obstack, malloc and gc'd memory. */ extern bitmap bitmap_alloc (bitmap_obstack *obstack CXX_MEM_STAT_INFO); #define BITMAP_ALLOC bitmap_alloc diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 40406df..49393dd 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -5205,6 +5205,7 @@ main (int argc, char **argv) POS_HERE (do_scalar_typedef ("void", &pos)); POS_HERE (do_scalar_typedef ("machine_mode", &pos)); POS_HERE (do_scalar_typedef ("fixed_size_mode", &pos)); + POS_HERE (do_scalar_typedef ("CONSTEXPR", &pos)); POS_HERE (do_typedef ("PTR", create_pointer (resolve_typedef ("void", &pos)), &pos)); diff --git a/gcc/ira.c b/gcc/ira.c index def194a..8258750 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -5417,7 +5417,7 @@ ira (FILE *f) = ((struct ira_spilled_reg_stack_slot *) ira_allocate (max_regno * sizeof (struct ira_spilled_reg_stack_slot))); - memset (ira_spilled_reg_stack_slots, 0, + memset ((void *)ira_spilled_reg_stack_slots, 0, max_regno * sizeof (struct ira_spilled_reg_stack_slot)); } } diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 09bd7aa..ba35b95 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -6651,11 +6651,11 @@ lra_inheritance (void) inherit_in_ebb. */ update_ebb_live_info (BB_HEAD (start_bb), BB_END (bb)); } - bitmap_clear (&ebb_global_regs); - bitmap_clear (&temp_bitmap); - bitmap_clear (&live_regs); - bitmap_clear (&invalid_invariant_regs); - bitmap_clear (&check_only_regs); + bitmap_release (&ebb_global_regs); + bitmap_release (&temp_bitmap); + bitmap_release (&live_regs); + bitmap_release (&invalid_invariant_regs); + bitmap_release (&check_only_regs); free (usage_insns); timevar_pop (TV_LRA_INHERITANCE); diff --git a/gcc/regrename.c b/gcc/regrename.c index 8424093..7294107 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -231,7 +231,7 @@ create_new_chain (unsigned this_regno, unsigned this_nregs, rtx *loc, struct du_chain *this_du; int nregs; - memset (head, 0, sizeof *head); + memset ((void *)head, 0, sizeof *head); head->next_chain = open_chains; head->regno = this_regno; head->nregs = this_nregs; -- 2.7.4