[Bug tree-optimization/70804] Missed tail-call
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 27 07:57:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70804
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-04-27
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed on x86_64.
/* Make sure the tail invocation of this function does not refer
to local variables. */
FOR_EACH_LOCAL_DECL (cfun, idx, var)
{
if (TREE_CODE (var) != PARM_DECL
&& auto_var_in_fn_p (var, cfun->decl)
&& (ref_maybe_used_by_stmt_p (call, var)
|| call_may_clobber_ref_p (call, var)))
return;
}
prevents this.
void f() ()
{
struct B b;
<bb 2>:
MEM[(struct E *)&b]._vptr.E = &MEM[(void *)&_ZTV1E + 16B];
E::destroy (&b.D.2301);
b ={v} {CLOBBER};
return;
here ::destroy may use/clobber the stack-local b. Not sure if we can argue
that if after the tailcall there is a clobber of b then that is safe or
what exactly was the logic with the check.
More information about the Gcc-bugs
mailing list