https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116743
--- Comment #7 from Rama Malladi <rvmallad at amazon dot com> ---
I haven't been successful to create a reproducer yet. A simple `test.cc` as
follows isn't showing this behavior as the compiler inlines these irrespective
(at `-O3`).
```
#include<iostream>
#define N 30
void init_array(int *a, int x)
{
for (int i = 0; i < N*N*N; i++)
a[i] = i + x;
}
int D(int *arr, int n);
int C(int *a, int n)
{
for (int i = 0; i < N*N*N; i+=8){
n += a[i];
< unrolled 8 times>
}
return D(a,n);
}
int B(int *arr, int n)
{
int result = n;
for (int i = 0; i < N*N*N; i++)
result += arr[i];
result = C(arr, result);
return result;
}
int D(int *arr, int n)
{
<large function body>
}
int A(int *arr, int x)
{
int callerResult = x;
if (x > 99000)
callerResult += B(arr, x);
return callerResult;
}
int main(int argc, char* argv[])
{
int arr[N*N*N];
int outval = atoi(argv[1]);
init_array(arr, 2);
for(int i=0; i<100000; i++)
outval += A(arr, i);
for(int i=0; i<100000; i++)
outval += C(arr, outval);
outval += D(arr, outval);
std::cout<<outval<<std::endl;
return 0;
}
```
Here are some diagnostic prints. Expected behavior that `B` and `D` are less
often called and hence not inlined into `main`. I was also expecting that `C`
and `D` wouldn't be inlined into `B`. But this wasn't the case.
```
test.cc:21:10: missed: not inlinable: int main(int, char**)/546 -> int
D(int*, int)/544, call is unlikely and code size would grow
test.cc:70:19: missed: not inlinable: int main(int, char**)/546 -> int
B(int*, int)/543, call is unlikely and code size would grow
test.cc:38:15: optimized: Inlined int C(int*, int)/1240 into int B(int*,
int)/543 which now has time 8335.001846 and size 91, net change of +42.
test.cc:21:10: optimized: Inlined int D(int*, int)/1241 into int C(int*,
int)/542 which now has time 12282.002762 and size 127, net change of +78.
```
I will continue to attempt creating a stand-alone test-case or if get a
compilation unit extracted from the MySQL code itself and upload it.