On May 30, 2011, Alexandre Oliva wrote: > 1. emit debug temps for replaceable DEFs that end up being referenced in > debug insns. We already have some code to try to deal with this, but it > emits the huge expressions we'd rather avoid, and it may create > unnecessary duplication. This new approach emits a placeholder instead > of skipping replaceable DEFs altogether, and then, if the DEF is > referenced in a debug insn (perhaps during the late debug re-expasion of > some other placeholder), it is expanded. Placeholders that end up not > being referenced are then throw away. This is my favorite option, for it's safest: it doesn't change executable code at all (or should I say it *shouldn't* change it, for I haven't verified that it doesn't), retaining any register pressure benefits from TER. The drawbacks are higher likelihood of loss of debug information as complex debug value expressions now require the recursive expansion of multiple debug temps, which is now more likely to hit the recursion limit. E.g., for a chain of dereferences, before the patch we'd get something like: ;; x_ = ****y_; (actually a sequence of replaceable gimple assignments) ;; debug x => x_ (debug_insn (var_location x (mem (mem (mem (mem (reg y_))))))) [...] ;; ? = x_ + 1; (set (reg) (mem (reg y_))) (set (reg) (mem (reg...))) (set (reg) (mem (reg...))) (set (reg x_) (mem (reg...))) (set (reg ?) (plus (reg x_) (const_int 1))) After the patch, the first two stmts would expand to: ;; x_ = ****y; (replaceable sequence) (debug_insn (var_location D#3 (mem (reg ...)))) (debug_insn (var_location D#2 (mem D#3))) (debug_insn (var_location D#1 (mem D#2))) ;; debug x => x_ (debug_insn (var_location x (mem D#1))) The additional debug temps will likely come at a compile-time cost, especially during var-tracking, but this may be at least in part recovered because the debug temps hold values that are likely to be computed by actual insns, so var-tracking will create value tracking entries for them anyway. Unlike the other patches, this alternative will *not* expand replaceable code at its natural location, so the executable code will remain at the point of use. Single-stepping will therefore remain just as confusing, and since debug bind stmts will likely remain at points one can't stop, they may remain unusable. The debug information extensions I proposed at the GCC Summit last year will alleviate this issue, but I still don't have a concrete plan for completing the implementation of that feature, so this is something to keep in mind if this patch is preferred. Here's the patch. Regstrapped on x86_64-linux-gnu and i686-linux-gnu.