https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99993
Bug ID: 99993 Summary: Inlining limit on stack growth behaves oddly Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- extern void foo(void); int a, b, *c; static void d(int f) { if (f) foo(); } static int e(int f) { int g[] = {2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 2}; int h[60]; h[0] = g != c; if (b) while (a) { int *i[1] = {&h[6]}; } return f; } static int *j(int *p) { return 0; } int main () { int m = e(0); d(m); int l[8]; if (j(l)) while (1) ; return 0; } at -O1 we IPA inline e() while at -O3 we IPA CP the zero but fail to inline the otherwise identical clone: t.c:19:11: missed: not inlinable: main/6 -> e.constprop/8, --param large-stack-frame-growth limit reached but with -O1 this doesn't seem to be a consideration. There: IPA function summary for main/6 inlinable global time: 35.600000 self size: 11 global size: 11 min size: 8 self stack: 32 global stack: 32 size:0.000000, time:0.000000 size:3.000000, time:0.600000, executed if:(not inlined) calls: j/5 function not considered for inlining freq:1.00 loop depth: 0 size: 3 time: 12 callee size: 1 stack: 0 op0 is compile time invariant op0 points to local or readonly memory d/3 function not considered for inlining freq:1.00 loop depth: 0 size: 2 time: 11 callee size: 3 stack: 0 e/4 function not considered for inlining freq:1.00 loop depth: 0 size: 3 time: 12 callee size:10 stack:284 op0 is compile time invariant op0 points to local or readonly memory compared to IPA function summary for main/6 inlinable global time: 19.300000 self size: 9 global size: 9 min size: 6 self stack: 0 global stack: 0 size:2.000000, time:2.000000 size:3.000000, time:2.000000, executed if:(not inlined) calls: foo/7 function body not available freq:0.33 loop depth: 0 size: 1 time: 10 e.constprop/8 function not considered for inlining freq:1.00 loop depth: 0 size: 3 time: 12 callee size:10 stack:284 op0 is compile time invariant op0 points to local or readonly memory maybe the issue is that at -O3 main()s self-stack is zero (it has 'l' early inlined). Indeed the growth limit seems to be zero if the estimated self size is zero ... but even with forcing a main stack size of 4 we run into the limit. Somehow this looks off (esp. considering this is a single call to e that is inlined so the net effect on the stack is zero?). Honza?