Bug 63242 - memory starvation caused by flatten attribute
Summary: memory starvation caused by flatten attribute
Status: RESOLVED DUPLICATE of bug 77472
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: compile-time-hog
Depends on:
Blocks:
 
Reported: 2014-09-12 12:56 UTC by wbrana
Modified: 2023-09-29 19:56 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-09-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wbrana 2014-09-12 12:56:38 UTC
forwarded from https://bugs.freedesktop.org/show_bug.cgi?id=77580

Hello,
    I've been testing GCC 4.9 for a virtual gentoo machine and I noticed that you us flatten attribute in source code. In case of src/sna/sna_glyphs.c flatten functions, inliner inlines about 3.3M functions and crashes because of no free memory (I have 8GB memory).

Please notice that LTO has ability to optimize whole program. As a result, it sees almost all function bodies and that leads to enormous inlining.

Suggested patch removes these flatten attributes for selected functions.

Thank you,
MArtin
Comment 1 Andrew Pinski 2014-09-12 15:02:50 UTC
It would nice if you attach a testcase which uses large amount of memory.
Comment 2 wbrana 2014-09-12 15:34:18 UTC
How I can create such testcase?

I can reproduce it on Gentoo by adding -flto to /etc/portage/make.conf
and running: emerge xf86-video-intel
but can't reproduce from command-line
gcc  -std=gnu99 -O3 -shared -fPIC -flto sna_glyphs.i -o test.so
Comment 3 Richard Biener 2014-09-15 09:11:13 UTC
Heh, yeah.  flatten with LTO will indeed have the possibility to inline very
many functions ;)  Note that all limits we expose on inlining (large function,
large unit, etc.) are not applied here.

Not sure if limiting flatten to early inlining would be a good idea (you'd
never get cross-module inlining on flatten that way, similar to always_inline).

Maybe we should impose a really-large-function limit ... (and flatten in
function size order).
Comment 4 Andrew Pinski 2016-09-17 13:26:37 UTC
,  There is another bug about this now too.
Comment 5 Andrew Pinski 2016-09-17 13:27:31 UTC
Dup of bug 77472.

*** This bug has been marked as a duplicate of bug 77472 ***