Summary: | [4.2 Regression] g++-4.1: out of memory with -O1/-O2 | ||
---|---|---|---|
Product: | gcc | Reporter: | alexander <alexander> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | dberlin, fang, gcc-bugs, rguenth |
Priority: | P2 | Keywords: | alias, compile-time-hog, memory-hog |
Version: | 4.1.1 | ||
Target Milestone: | 4.3.0 | ||
See Also: |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103823 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47334 |
||
Host: | Target: | ||
Build: | Known to work: | 4.0.4 4.3.0 | |
Known to fail: | 4.1.2 4.2.5 | Last reconfirmed: | 2008-01-08 16:54:31 |
Attachments: | testcase |
Description
alexander@kogan.nnov.ru
2007-05-08 09:22:34 UTC
Created attachment 13530 [details]
testcase
Until I killed cc1plus we have (mainline): samples % symbol name 50115 28.3000 push_fields_onto_fieldstack 12370 6.9853 bitpos_of_field 10174 5.7453 tree_low_cst 8825 4.9835 host_integerp 5204 2.9387 walk_tree 3666 2.0702 pointer_set_insert 2434 1.3745 cp_walk_subtrees 2199 1.2418 comptypes 2039 1.1514 ggc_alloc_stat which suspiciously hints at aliasing...!? Need to go for a bigger machine... cc1plus: out of memory allocating 18888764584 bytes after a total of 16482304 bytes so this actually killed even the 16GB box. Danny, push_fields_onto_fieldstack is going crazy on this. Note the interesting debuggable testcase is if you remove from getInstance() all template params from ClassSpec<Key, A020, 21> on. Around that one you'll clearly see exponential behavior in memory use ;) 4.2 (RC2, 20070430) also explodes (OOM) with the test case, using -O2. whereas 4.0.1 (powerpc-apple-darwin8) peaks out at 280 MB (cc1plus), which is reasonable and typical. Flag as 4.1/4.2/4.3 regression? Well, 4.0 didn't have struct aliasing, so yes. Though it's unlikely to be fixed for 4.1.x. Each one of thousands of temporary variables ends up with 12000 fields. Hi! Is there any progress with this bug? We are waiting impatiently for fix! Subject: Re: [4.1/4.2/4.3 Regression] g++-4.1: out of memory
with -O1/-O2
On Tue, 18 Sep 2007, alexander at kogan dot nnov dot ru wrote:
> ------- Comment #10 from alexander at kogan dot nnov dot ru 2007-09-18 04:58 -------
> Hi!
>
> Is there any progress with this bug?
> We are waiting impatiently for fix!
I have one fix in this are in the queue, but it does unfortunately
not completely solve this problem.
What do u mean 'not completely'? Can I try this fix? Subject: Re: [4.1/4.2/4.3 Regression] g++-4.1:
out of memory with -O1/-O2
On Tue, 18 Sep 2007, alexander at kogan dot nnov dot ru wrote:
> ------- Comment #12 from alexander at kogan dot nnov dot ru 2007-09-18 09:07 -------
> What do u mean 'not completely'?
> Can I try this fix?
I mean there is a memleak that I plugged, but memory usage is still
exponential in the number of template parameters.
Ok. Do you mean the attached test doesn't work even with this fix? But are there plans to eliminate this problem completely? Subject: Re: [4.1/4.2/4.3 Regression] g++-4.1:
out of memory with -O1/-O2
On Tue, 18 Sep 2007, alexander at kogan dot nnov dot ru wrote:
> ------- Comment #14 from alexander at kogan dot nnov dot ru 2007-09-18 09:55 -------
> Ok. Do you mean the attached test doesn't work even with this fix? But are
> there plans to eliminate this problem completely?
The testcase doesn't work with the fix.
Subject: Bug 31863 Author: rguenth Date: Tue Sep 18 11:22:47 2007 New Revision: 128573 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128573 Log: 2007-09-18 Richard Guenther <rguenther@suse.de> PR tree-optimization/31863 * tree-ssa-structalias.c (create_variable_info_for): Always free the fieldstack. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-structalias.c Note that the double virtual inheritance in the Serializer template creates the exponential behavior. You can fix this at the source level by instead doing template <class Key, class Head> class Serializer<Key, Loki::Typelist<Head, Loki::NullType> >: public virtual Serializer<Key, Head> { }; template <class Key, class Head, class Tail> class Serializer<Key, Loki::Typelist<Head, Tail> >: public virtual Serializer<Key, Head>, public Serializer<Key, Tail> { }; template <class Key> class Serializer<Key, Loki::NullType> : public virtual Factory<Key> { }; which also makes more sense(?). Back to marking this as possibly a C++ frontend bug - though I'm inclined to close this bug as INVALID. Thank you very much for this workaround. Really we do not need virtual inheritance there, we need only virtual inheritance from Factory. In this case it works! I believe that empty base optimization doesn't work for virtual inheritance. Whether this is a GCC specific problem or a general fact I don't know. So this bug was worked around -- but can this be fixed properly for GCC 4.3? Richi, is this just another example of the SFT problems reported in other PRs? Well, the many SFTs don't help the situation for sure. But we can't do anything for 4.3 here, as only after walking all the fields in push_fields_to_fieldstack we figure out we better not generate SFTs here. Which is too late. But yes, I suppose I can simply early exit from that function now that we always punt if the number of fields is too large. Subject: Bug 31863 Author: rguenth Date: Tue Jan 8 21:35:25 2008 New Revision: 131405 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131405 Log: 2008-01-08 Richard Guenther <rguenther@suse.de> PR middle-end/31863 * tree-ssa-structalias.c (push_fields_onto_fieldstack): Bail out early if the result will be unused. * g++.dg/torture/pr31863.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/torture/pr31863.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-structalias.c Fixed on the trunk. Closing 4.1 branch. Closing 4.2 branch, fixed in 4.3. |