[llvm-bugs] [Bug 40776] New: missed optimization with C constructors of sparse structures
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 19 08:52:32 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40776
Bug ID: 40776
Summary: missed optimization with C constructors of sparse
structures
Product: clang
Version: 8.0
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
I stumbled over a file with excessive stack usage in the Linux kernel when
building with clang, but not with gcc, reduced the test case to:
struct i2c_adapter {
char name[48];
int a[1000];
} hexium_attach_hexium;
void hexium_attach(void) {
hexium_attach_hexium = (struct i2c_adapter){"hexium gemini"};
}
$ clang-8 -Werror -c hexium-gemini.c -Wframe-larger-than=100 -O2
hexium-gemini.c:5:6: error: stack frame size of 4056 bytes in function
'hexium_attach' [-Werror,-Wframe-larger-than=]
Comparing the output shows that clang not only allocates stack space for the
extra copy of the structure, but also fails to optimize the string assignment:
https://godbolt.org/z/7jpy_y
I worked around it in the kernel sources by using an explict memset and
strscpy, but this seems like a generally useful optimization that could be
added.
--
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/20190219/3c140df6/attachment.html>
More information about the llvm-bugs
mailing list