On Sun, Oct 30, 2011 at 09:55:42PM -0400, David Miller wrote: > --- a/gcc/dwarf2out.c > +++ b/gcc/dwarf2out.c > @@ -20149,7 +20151,35 @@ dwarf2out_var_location (rtx loc_note) > if (var_loc_p && !DECL_P (NOTE_VAR_LOCATION_DECL (loc_note))) > return; > > - next_real = next_real_insn (loc_note); > + /* Optimize processing a large consecutive sequence of location > + notes so we don't spend too much time in next_real_insn. If the > + next insn is another location note, remember the next_real_insn > + calculation for next time. */ > + next_real = cached_next_real_insn; > + if (next_real) > + { > + if (expected_next_loc_note != loc_note) > + next_real = NULL_RTX; > + } > + > + next_note = NEXT_INSN (loc_note); > + if (! next_note > + || INSN_DELETED_P (next_note) > + || GET_CODE (next_note) != NOTE > + || (NOTE_KIND (next_note) != NOTE_INSN_VAR_LOCATION
I think for next_note being NOTE_INSN_VAR_LOCATION you want to set next_note to NULL_RTX if !DECL_P (NOTE_VAR_LOCATION_DECL (next_note)). Otherwise you risk that the above if (var_loc_p && !DECL_P (NOTE_VAR_LOCATION_DECL (loc_note))) return; will not clear the cache, you reach end of function and in the next function when dwarf2out_var_location is called for the first time, cached_next_real_insn will be non-NULL and if you have really bad luck it will be called on insn that has the same address as expected_next_loc_note (GC collection could happen in between). Or alternatively you could remove the whole if (! !next_note ...) next_note = NULL_RTX; stmt and move your cache to a global var and clear it when reaching end of function (like e.g. last_var_location_insn is cleared in dwarf2out_end_epilogue). Jakub