https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78685
--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 21 Dec 2016, eggert at gnu dot org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78685 > > --- Comment #5 from Paul Eggert <eggert at gnu dot org> --- > Just to clarify: 'main' (in the sample program) is just an example. The > problems developers are seeing when debugging Emacs almost all involve > functions other than 'main'. > > It should be OK for -Og to optimize significantly less than it does now, so > long as -Og remains better than -O0. As things stand, -Og is pretty much > useless for its stated purpose because GDB so often cannot display values of > locals, and I expect this partly explains why -Og is so rarely used in > practice. > > In Emacs, developers use -O0 for debugging, but this can be reeeaally slow > because -O0 does not inline and Emacs relies heavily on small inlined > functions. Although Emacs works around this problem by using macros instead of > functions, such workarounds have obvious drawbacks. For Emacs, it would be > nice > if -Og did not discard locals, but continued to inline. It doesn't really discard them, it just doesn't preserve their values at points they are no longer necessary... I presume you really want not only the inlining to happen but also at least _some_ of the optimization triggered by it as well (for Emacs). This is somewhat in conflict with the desire to preserve every value of every variable at any point in time during their lifetime ... But yes, for the testcase I can see what you expect and the expectation is of course reasonable, it's just somewhat hard to implement. I guess making every user variable set an association barrier might be a start.