On Mon, Apr 08, 2024 at 05:40:23PM +0200, Aldy Hernandez wrote: > > PR middle-end/114604 > > * gimple-range.cc (enable_ranger): Initialize the global > > bitmap obstack. > > (disable_ranger): Release it. > > --- > > gcc/gimple-range.cc | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc > > index c16b776c1e3..4d3b1ce8588 100644 > > --- a/gcc/gimple-range.cc > > +++ b/gcc/gimple-range.cc > > @@ -689,6 +689,8 @@ enable_ranger (struct function *fun, bool use_imm_uses) > > { > > gimple_ranger *r; > > > > + bitmap_obstack_initialize (NULL); > > + > > gcc_checking_assert (!fun->x_range_query); > > r = new gimple_ranger (use_imm_uses); > > fun->x_range_query = r; > > @@ -705,6 +707,8 @@ disable_ranger (struct function *fun) > > gcc_checking_assert (fun->x_range_query); > > delete fun->x_range_query; > > fun->x_range_query = NULL; > > + > > + bitmap_obstack_release (NULL); > > Are you not allowed to initialize/use obstacks unless > bitmap_obstack_initialize(NULL) is called?
You can use it with some other obstack, just not the default one. > If so, wouldn't it be > better to lazily initialize it downstream (bitmap_alloc, or whomever > needs it initialized)? No, you still need to decide where is the safe point to release it. Unlike the non-default bitmap_obstack_initialize/bitmap_obstack_release, the default one can nest (has associated nesting counter). So, the above patch just says that ranger starts using the default obstack in enable_ranger and stops using it in disable_ranger and anything ranger associated in the obstack can be freed at that point. If one uses this from a pass which has its own bitmap_obstack_{initializer,release} (NULL) around this, then the above will not do anything, just bump the nesting counter and decrease it later. But if some pass doesn't, i.e. the pass itself doesn't use the default obstack, only ranger does, then the above seems like the right change to me. > Unless I'm misunderstanding something, it > doesn't seem like ranger is the correct place to fix this. Jakub