<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - excessive stack usage compiling linux amdgpu kernel driver"
href="https://bugs.llvm.org/show_bug.cgi?id=42551">42551</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>excessive stack usage compiling linux amdgpu kernel driver
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arnd@linaro.org
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22208" name="attach_22208" title="preprocessed and partially reduced file">attachment 22208</a> <a href="attachment.cgi?id=22208&action=edit" title="preprocessed and partially reduced file">[details]</a></span>
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:
<a href="https://godbolt.org/z/ZlDp0Z">https://godbolt.org/z/ZlDp0Z</a>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>