On Mon, Apr 8, 2024 at 11:50 AM Richard Biener <rguent...@suse.de> wrote: > > The following fixes ranger bitmap allocation when invoked from IPA > context where the global bitmap obstack possibly isn't initialized. > Instead of trying to use one of the ranger obstacks the following > simply initializes the global bitmap obstack around an active ranger. > > Bootstrapped and tested on x86_64-unknown-linux-gnu with bitmap_alloc > instrumentation (all ICEs gone, so ranger was the only offender). > > OK? > > Thanks, > Richard. > > 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? If so, wouldn't it be better to lazily initialize it downstream (bitmap_alloc, or whomever needs it initialized)? Unless I'm misunderstanding something, it doesn't seem like ranger is the correct place to fix this. Aldy