https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87094
Bug ID: 87094 Summary: Suboptimal accounting for stack growth in inlining Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: amonakov at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- On this small example: void g(int, char *); static void f(int x) { char c[2048]; g(x, c); } void h(int x) { f(x); } GCC does not inline f into h due to reaching stack growth limit. However, since f is called unconditionally, the original stack growth is at least max(f_stack, h_stack), and post-inlining stack growth is at most f_stack+h_stack. Since h_stack is 0, both are equal and inlining should be considered. If h called f only conditionally, avoiding inlining would be correct.