On Thu, Nov 03, 2011 at 02:07:31PM +0100, Michael Matz wrote: > In this specific case we could notice that resx1 actually is the outermost > resume, hence only will leave the function and therefore the clobber is > useless (as in, moving them down actually removes them from the function > body). But suppose the whole code above would itself be contained in some > other region to which the resx1 would lead. We could move the clobber > there (and to the fall thru path that skips that region, which is the case > with catch region), that it safe (outer cleanup regions are always outer > or following scopes, and moving clobber outwards or lower is > conservatively correct), but extends the life area of the variables in > question.
Well, for just the clobber stmts followed by resx that isn't caught in the function at least we definitely shouldn't catch it, do nothing and rethrow. struct POD { char a[10]; }; extern void bar (POD *); extern void baz (); void foo (bool cond) { if (cond) { POD pod; bar (&pod); } baz (); } I'd certainly hope we don't generate here any catch/rethrow (similarly for non-PODs with trivial dtors). > The other possibility would be removing the clobbers (all of them) right > before ehcleanup2 (shortly before expand) and somehow remember the edges > over which the variables die. That seems a bit fragile as there are some > more passes between them that fiddle with edges. Can't you, if you detect only clobber stmts followed up by rethrow, just move the clobber stmts to where the throw would be caught resp. remove if not caught? Jakub