https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87639
Bug ID: 87639
Summary: GCC fails to consider end of automatic object lifetime
when determining sibcall eligibility
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: bugdal at aerifal dot cx
Target Milestone: ---
Test case:
void bar();
void bah(void *);
void foo2()
{
{
char buf[1000];
bah(buf);
}
bar();
}
Since buf's address leaked to bah, gcc concludes that it cannot generate a
sibcall to bar. However, at the end of the block in which its declaration is
contained, buf's lifetime has ended.
The above test case is mildly artificial, but the same thing happens with
inlining, and results in long-lived large stack frames (and possibly stack
overflow if tail-recursion was desired), when a function comparable to the
block containing buf gets inlined into the function that should end with a
sibcall. This imposes the need for manual barriers against inlining or unnatual
splitting of functions when the stack usage is a problem.