Bug 36498 - [4.3 Regression] time/memory hog for large c++ source.
Summary: [4.3 Regression] time/memory hog for large c++ source.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.3.1
: P2 normal
Target Milestone: 4.3.2
Assignee: Richard Biener
URL:
Keywords: compile-time-hog, memory-hog
Depends on:
Blocks:
 
Reported: 2008-06-11 14:04 UTC by Pawel Sikora
Modified: 2008-06-23 10:13 UTC (History)
2 users (show)

See Also:
Host: x86_64-gnu-linux
Target: i486-gnu-linux
Build:
Known to work: 4.3.0 4.4.0
Known to fail: 4.3.1
Last reconfirmed: 2008-06-11 19:36:06


Attachments
testcase (256.19 KB, application/octet-stream)
2008-06-11 14:05 UTC, Pawel Sikora
Details
unincluded testcase (226.11 KB, application/octet-stream)
2008-06-11 14:55 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2008-06-11 14:04:58 UTC
the 4.3.1 release introduces a new time/memory hog
which wasn't present in 4.3.0-20080417.

results (with default max-fields-for-field-sensitive param):
4.3.0-20080417 : mem: 580MB, time: 1min32sec.
4.3.1          : aborted at 4.3GB/14min.
Comment 1 Pawel Sikora 2008-06-11 14:05:41 UTC
Created attachment 15749 [details]
testcase
Comment 2 Pawel Sikora 2008-06-11 14:10:34 UTC
testcase tested with:

$ i486-gnu-linux-g++ -g0 -O2 -std=gnu++0x -fno-threadsafe-statics
                     -fPIC hescoreScr.ii -c

gdb report still the same backtrace:

(gdb) bt
#0  0x000000000066891b in set_bb_for_stmt ()
#1  0x000000000069c4cb in create_phi_node ()
#2  0x000000000068d066 in insert_phi_nodes_for ()
#3  0x000000000068d3e8 in insert_updated_phi_nodes_for ()
#4  0x000000000068e59c in update_ssa ()
#5  0x00000000006bd21a in compute_may_aliases ()
#6  0x00000000005f2c8a in execute_function_todo ()
#7  0x00000000005f274d in execute_todo ()
#8  0x00000000005f294a in execute_one_pass ()
#9  0x00000000005f2a9c in execute_pass_list ()
#10 0x00000000005f2aae in execute_pass_list ()
#11 0x0000000000695892 in tree_rest_of_compilation ()
#12 0x0000000000792902 in cgraph_expand_function ()
#13 0x000000000079404e in cgraph_optimize ()
#14 0x00000000004482ef in cp_write_global_declarations ()
#15 0x000000000066362e in toplev_main ()
#16 0x00002b69a416c4a4 in __libc_start_main () from /lib64/libc.so.6
#17 0x00000000004023a9 in _start ()
Comment 3 Richard Biener 2008-06-11 14:46:25 UTC
Eventually the fix for PR36154 may be the cause.  Can you check backing out

2008-05-08  Richard Guenther  <rguenther@suse.de>

        PR middle-end/36154
        * tree-ssa-structalias.c (push_fields_onto_fieldstack): Make
        sure to create a representative for trailing arrays for PTA.

?

Or the fix for PR36339, which would be

2008-05-28  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/36339
        * tree-ssa-alias.c (set_initial_properties): Move pt_anything
        and subvariable clobbering code out of the loop.

2008-05-27  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/36339
        * tree-ssa-alias.c (set_initial_properties): Escaped pt_anything
        pointers cause all addressable variables to be call clobbered.
Comment 4 Richard Biener 2008-06-11 14:55:37 UTC
Created attachment 15750 [details]
unincluded testcase
Comment 5 Richard Biener 2008-06-11 15:20:42 UTC
The offending function is

virtual bool hcScr::hescoreScr::init(Tcl_Interp*, hc::IAccessBase*, vcm::vcmptr<cfgmgr::IConfigManager>)

but probably only after inlining.  The trunk is fine, as is compiling
with --param max-fields-for-field-sensitive=0.

Most of the time/memory is spent in update_ssa () in phi-insertion.
Comment 6 Pawel Sikora 2008-06-11 19:27:44 UTC
this patch causes regression.

------------------------------------------------------------------------
r135125 | rguenth | 2008-05-09 21:19:33 +0200 (Fri, 09 May 2008) | 10 lines

2008-05-09  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/36187
        * tree-dfa.c (dump_variable): Correct dumping of
        SFT_BASE_FOR_COMPONENTS_P.
        * tree-ssa-structalias.c (set_uids_in_ptset): Set
        SFT_UNPARTITIONABLE_P correctly for the union case.
Comment 7 Richard Biener 2008-06-11 19:36:06 UTC
Then the following should fix it.

Index: tree-flow-inline.h
===================================================================
--- tree-flow-inline.h	(revision 135770)
+++ tree-flow-inline.h	(working copy)
@@ -1712,6 +1712,11 @@ var_can_have_subvars (const_tree v)
   if (!DECL_P (v) || MTAG_P (v))
     return false;
 
+  /* Unions cannot have subvars.  */
+  if (TREE_CODE (TREE_TYPE (v)) == UNION_TYPE
+      || TREE_CODE (TREE_TYPE (v)) == QUAL_UNION_TYPE)
+    return false;
+
   /* Aggregates can have subvars.  */
   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
     return true;
Comment 8 Pawel Sikora 2008-06-11 20:14:47 UTC
(In reply to comment #7)
> Then the following should fix it.
> 
> Index: tree-flow-inline.h
> ===================================================================
> --- tree-flow-inline.h  (revision 135770)
> +++ tree-flow-inline.h  (working copy)
> @@ -1712,6 +1712,11 @@ var_can_have_subvars (const_tree v)
>    if (!DECL_P (v) || MTAG_P (v))
>      return false;
> 
> +  /* Unions cannot have subvars.  */
> +  if (TREE_CODE (TREE_TYPE (v)) == UNION_TYPE
> +      || TREE_CODE (TREE_TYPE (v)) == QUAL_UNION_TYPE)
> +    return false;
> +
>    /* Aggregates can have subvars.  */
>    if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
>      return true;
> 

with this change g++ needs ~1GB and ~4minutes.
Comment 9 Richard Biener 2008-06-11 20:41:54 UTC
Hm, the patch in comment #6 only affects the case where we have a union with
subvars.  Did you check that just reverting this patch brings us back to
580MB and 1min32?
Comment 10 Pawel Sikora 2008-06-11 20:50:12 UTC
(In reply to comment #9)
> Hm, the patch in comment #6 only affects the case where we have a union with
> subvars.  Did you check that just reverting this patch brings us back to
> 580MB and 1min32?

yes, i've checked r135124 and it needs only ~580MB.
Comment 11 Richard Biener 2008-06-11 21:04:38 UTC
Ah, but that test also reverts all followup patches, like

2008-05-28  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/36339
        * tree-ssa-alias.c (set_initial_properties): Move pt_anything
        and subvariable clobbering code out of the loop.

2008-05-27  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/36339
        * tree-ssa-alias.c (set_initial_properties): Escaped pt_anything
        pointers cause all addressable variables to be call clobbered.

so, did you apply the patch in comment #7 on top of r135125 or on top
of the branch head?
Comment 12 Pawel Sikora 2008-06-11 21:17:57 UTC
(In reply to comment #11)
> Ah, but that test also reverts all followup patches, like
> (...)
> so, did you apply the patch in comment #7 on top of r135125 or on top
> of the branch head?

on top of the branch head (r136662).

summary:
r135124 needs max. 580MB(the 'virt' column from htop)/~1.5min
r135125 and newer needs at least 4.3GB/14min.
r136662 with suggested patch needs ~1GB/4min.
Comment 13 Richard Biener 2008-06-13 08:42:29 UTC
Subject: Bug 36498

Author: rguenth
Date: Fri Jun 13 08:41:45 2008
New Revision: 136744

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136744
Log:
2008-06-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/36498
	* tree-flow-inline.h (var_can_have_subvars): Unions cannot
	have subvars.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/tree-flow-inline.h

Comment 14 Mark Mitchell 2008-06-13 21:53:12 UTC
Richard --

Is this still an issue, after your patch?

Thanks,

-- Mark
Comment 15 rguenther@suse.de 2008-06-14 22:04:04 UTC
Subject: Re:  [4.3 Regression] time/memory hog for large
 c++ source.

On Fri, 13 Jun 2008, mmitchel at gcc dot gnu dot org wrote:

> Richard --
> 
> Is this still an issue, after your patch?

It's still 4 times slower and uses twice as much memory.  It will
be fixed with the partitioning patch I posted yesterday.

Richard.
Comment 16 Richard Biener 2008-06-23 10:13:28 UTC
Fixed.