[llvm-bugs] [Bug 42551] New: excessive stack usage compiling linux amdgpu kernel driver

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 9 01:27:31 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42551

            Bug ID: 42551
           Summary: excessive stack usage compiling linux amdgpu kernel
                    driver
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arnd at linaro.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 22208
  --> https://bugs.llvm.org/attachment.cgi?id=22208&action=edit
preprocessed and partially reduced file

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:

https://godbolt.org/z/ZlDp0Z

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190709/c8593d4c/attachment-0001.html>


More information about the llvm-bugs mailing list