https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100314
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
With -O1 i get:
IPA function summary for main/7 inlinable
global time: 72.936364
self size: 6
global size: 19
min size: 16
self stack: 0
global stack: 44
size:15.000000, time:67.636364
size:3.000000, time:2.000000, executed if:(not inlined)
calls:
d/6 inlined
freq:1.00
Stack frame offset 0, callee self size 0
e/5 inlined
freq:1.00
Stack frame offset 0, callee self size 44
foo/8 function body not available
freq:0.33 loop depth: 0 size: 1 time: 10
So we get 44 bytes of stack use.
However with -O3 we see:
IPA function summary for main/7 inlinable
global time: 14.000000
self size: 6
global size: 6
min size: 3
self stack: 0
global stack: 0
size:1.000000, time:1.000000
size:3.000000, time:2.000000, executed if:(not inlined)
calls:
d/6 function not considered for inlining
freq:1.00 loop depth: 0 size: 2 time: 11 callee size:11 stack:284
IPA function summary for d/6 inlinable
global time: 87.936364
self size: 23
global size: 23
min size: 17
self stack: 284
global stack: 284
size:17.000000, time:80.636364
size:3.000000, time:2.000000, executed if:(not inlined)
size:2.000000, time:2.000000, nonconst if:(op0 changed)
calls:
foo/8 function body not available
freq:0.33 loop depth: 0 size: 1 time: 10 predicate: (op0 != 0)
So now the stack is 284 bytes for d which hits the limits.
It seems to be array h[30] (240 bytes) and l[5] (40 bytes).
With -O1 array h is optimized out completely however with -O3 I see:
void d (int m)
{
int k;
int * l[5];
int * * h[30];
int b.1_8;
int _9;
int g.2_10;
<bb 2> [local count: 118111600]:
MEM <char[232]> [(int * *[30] *)&h + 8B] = {};
h[0] = &c;
if (m_5(D) != 0)
goto <bb 3>; [33.00%]
else
goto <bb 4>; [67.00%]
<bb 3> [local count: 38976828]:
foo ();
<bb 4> [local count: 118111600]:
l[0] = &k;
l[1] = &k;
l[2] = &k;
l[3] = &k;
l[4] = &k;
goto <bb 6>; [100.00%]
<bb 5> [local count: 955630225]:
j = &l[0];
b.1_8 = b;
_9 = b.1_8 + 1;
b = _9;
<bb 6> [local count: 1073741824]:
g.2_10 = g;
if (g.2_10 != 0)
goto <bb 5>; [89.00%]
else
goto <bb 7>; [11.00%]
<bb 7> [local count: 118111600]:
k ={v} {CLOBBER};
l ={v} {CLOBBER};
h ={v} {CLOBBER};
return;
}
So h is dead but DSE did not happen since at DSE time we see:
<bb 2> :
MEM <char[232]> [(int * *[30] *)&h + 8B] = {};
h[0] = &c;
i[0] = &h[3];
if (m_6(D) != 0)
goto <bb 3>; [INV]
else
goto <bb 4>; [INV]
<bb 3> :
foo ();
<bb 4> :
Which keeps h alive.
