On Tue, Jan 28, 2014 at 11:48:16AM +0100, Richard Biener wrote: > On Mon, Jan 20, 2014 at 5:22 PM, Jan Hubicka <hubi...@ucw.cz> wrote: > >> > >> Yes. Say, this could be surrounded by some try/catch, if we do it the > >> first > >> way, a would be still considered live across the EH path to whatever > >> catches > >> it. > >> > >> The EH optimizations involving cleanups with only clobbers in them are that > >> if at the end of the cleanup after only CLOBBER stmts you would rethrow > >> the exception > >> externally, then the clobber isn't needed and the whole cleanup can be > >> removed. And, if it rethrows somewhere internally, we can move the clobber > >> stmts to the landing pad of wherever it would be caught. > > > > OK, I still do not see how ehclanup1 can then safely remove them pre-inline > > given that the whole function body can be inlined into another containing > > the > > outer EH region. > > That's true.
There are two kinds of clobbers, the direct ones, which surely can be safely removed by ehcleanup1 if they are the only reason why there is a landing pad which will be rethrown outside of the current function, and then the indirect ones, meant primarily for C++ destructors on *this, which are just heuristics and current state seems to be working good enough for them IMHO. For the direct cleanups, the important thing is that they are necessarily local variables in the current function, so when returning from that function, whether normally or abnormally, the inliner still has all the info about them. If it wants, it can add the corresponding clobbers itself (not sure if it does or doesn't bother, but if it doesn't bother right now, it certainly could add those in the future if it proves to be important). For the indirect clobbers, typically if you inline some destructor, you either inline it into another destructor which will also have (a larger) clobber for *this afterwards, or into a function that defines the var as local and there will be a normal direct clobber for it. Jakub