On Fri, Mar 14, 2014 at 11:45:48PM -0300, Alexandre Oliva wrote: > This bug report had various testcases that had to do with full loop > unrolling with non-automatic iterators and fixed boundaries, which > resulted in duplicating debug stmts in the loop for each iteration. In > some cases, the resulting executable code is none, but the debug stmts > add up to millions. Just dropping them on the floor is somewhat > undesirable, even though they're not usable for much with today's > compiler and debugger infrastructure. I decided to introduce a param to > limit debug stmts, so that this sort of testcase doesn't run nearly > forever, eating up all memory while at that. This is what this patchset > does.
To some extent this is really a big hammer approach, on the other side we already have a precedent here, the max-vartrack-size limit, and if we have too many debug stmts in a single function, we also most likely hit the max-vartrack-size limit anyway. It would be nice if for the loop unrolling we could try to do something smarter (as I wrote in the PR, I think it would be e.g. nice to preserve debug stmts on the first few unrolled iterations and the last one and just say the vars are all unavailable for the middle iterations or something, instead of dropping everything). > --- a/gcc/function.c > +++ b/gcc/function.c > @@ -4498,6 +4498,8 @@ allocate_struct_function (tree fndecl, bool abstract_p) > > cfun = ggc_alloc_cleared_function (); > > + SET_BUILD_DEBUG_STMTS (cfun, flag_var_tracking_assignments); Dunno how this plays together with __attribute__((optimize(...))), I'm afraid not very well. E.g. if in -O0 -g compilation some function is __attribute__((optimize(2))) then we want to have debug stmts in there, but the above would preclude it, on the other wise in -O2 -g compilation with __attribute__((optimize(0))) function in it, we don't want debug stmts in there. So perhaps it needs to be updated when handling the optimize attribute if the function doesn't have a body yet or something similar? > @@ -121,6 +121,12 @@ gimple_alloc_stat (enum gimple_code code, unsigned > num_ops MEM_STAT_DECL) > size_t size; > gimple stmt; > > + if (code == GIMPLE_DEBUG) > + { > + gcc_checking_assert (MAY_HAVE_DEBUG_STMTS); > + cfun->debug_stmts++; > + } > + > size = gimple_size (code); > if (num_ops > 0) > size += sizeof (tree) * (num_ops - 1); I'd strongly prefer it you could move this hunk to gimple_build_debug_bind_stat and gimple_build_debug_source_bind_stat, yeah, it is duplication of it, but adding a branch for all GIMPLE allocation doesn't look like a good idea to me. Jakub