Bug 58087 - Huge memory consumption with #pragma GCC optimize, __attribute__ and long output paths
Summary: Huge memory consumption with #pragma GCC optimize, __attribute__ and long out...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: opt-attribute
Depends on:
Blocks:
 
Reported: 2013-08-05 13:00 UTC by Sandro Mani
Modified: 2021-12-15 11:08 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sandro Mani 2013-08-05 13:00:43 UTC
Using gcc version 4.8.1 20130717 (Red Hat 4.8.1-5) (GCC)

Description:
Any code containing #pragma GCC optimize, lots of __attribute__(()) will result in cc1 taking up huge amounts of memory _depending_ on the length of the output path.

Test case:
$ for i in $(seq 1 10000); do echo -e "void __attribute__(()) fz$i();" >> test.h; done

$ cat > test.c <<EOF
#pragma GCC optimize ("-O1")
#include "test.h"
int main(){ return 0; }
EOF

$ wget https://gist.github.com/netj/526585/raw/9044a9972fd71d215ba034a38174960c1c9079ad/memusg
$ chmod +x memusg

$ mkdir a
$ ./memusg gcc -c -o a/test.o test.c
memusg: peak=485796

$ mkdir aaaaaaaaaaaaaaaaaaaaaaa
$ ./memusg gcc -c -o aaaaaaaaaaaaaaaaaaaaaaa/test.o test.c
memusg: peak=4827100

Observations:
- The "-O1" is not important, passing any other string to #pragma GCC optimize (regardless of whether it is valid or invalid) will also trigger the issue
- As noted, the memory consumption depends on the length of the output path
Comment 1 Sandro Mani 2014-01-18 16:18:01 UTC
Still applies to 4.8.2. Changing component to a (hopefully) more relevant one.