-
Notifications
You must be signed in to change notification settings - Fork 15k
Description
Bugzilla Link | 42551 |
Version | trunk |
OS | Linux |
Blocks | #4440 |
Attachments | preprocessed and partially reduced file, original source file, preprocessed and compressed, kernel patch to avoid passing structures by value |
CC | @kbeyls,@nickdesaulniers,@ostannard,@zygoloid,@smithp35 |
Extended Description
One file in the linux kernel appears to trigger a failed optimization that leads to large stack usage. Compiling a 32-bit ARM defconfig with the amdgpu driver enabled, I get
drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dce_calcs.c:2987:6: error: stack frame size of 1344 bytes in function 'bw_calcs' [-Werror,-Wframe-larger-than=]
bool bw_calcs(struct dc_context *ctx,
^
drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dce_calcs.c:76:13: error: stack frame size of 5328 bytes in function 'calculate_bandwidth' [-Werror,-Wframe-larger-than=]
I managed to partially reduce the preprocessed source file to illustrate the problem better:
The stack usage is highly target architecture dependent:
gcc arm-linux-gnueabi: 208 bytes
clang-8 arm-linux-gnueabi: 4144 bytes
clang-9 arm-linux-gnueabi: 4992 bytes
clang-9 aarch64-linux-gnu: 272 bytes
clang-9 powerpc64: 4272 bytes
clang-9 powerpc32: 4112 bytes
clang-9 s390-32: 4168 bytes
clang-9 s390-64: 4168 bytes
clang-9 sparc32: 10272 bytes
clang-9 sparc64: 432 bytes
$ clang-9 -Wframe-larger-than=10 --target=arm-linux-gnu -O2 -fno-strict-overflow -S dce-calcs-clang-noinline.i -m32 -Wno-unused-value -Wno-logical-op-parentheses -Wno-return-type -Wno-implicit-int
dce-calcs-clang.i:275:4: warning: stack frame size of 4944 bytes in function 'calculate_bandwidth' [-Wframe-larger-than=]
calculate_bandwidth(struct bw_calcs_dceip *dceip, struct bw_calcs_vbios *vbios, struct bw_calcs_data *data) {
^
Note that we build 32-bit kernels with -Wframe-larger-than=1024 because of the highly limited available stack space, and using 5KB of stack is likely to result in a kernel crash.