Bug 44694 - [4.5 Regression] Long var tracking compile time of GiNaC tests
Summary: [4.5 Regression] Long var tracking compile time of GiNaC tests
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.1
Assignee: Jakub Jelinek
URL:
Keywords: compile-time-hog
Depends on:
Blocks:
 
Reported: 2010-06-27 23:55 UTC by Jan Hubicka
Modified: 2010-07-01 12:37 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-06-28 09:13:08


Attachments
testcase (162.56 KB, application/octet-stream)
2010-06-27 23:57 UTC, Jan Hubicka
Details
unincluded testcase (37.89 KB, application/octet-stream)
2010-06-28 09:13 UTC, Richard Biener
Details
gcc46-pr44694.patch (575 bytes, patch)
2010-06-29 08:53 UTC, Jakub Jelinek
Details | Diff
gcc46-pr44694.patch (1.70 KB, patch)
2010-06-29 14:11 UTC, Jakub Jelinek
Details | Diff
testcase for introduced regression (1.35 KB, text/plain)
2010-06-30 23:43 UTC, Richard Earnshaw
Details
testcase for introduced regression (1.35 KB, text/plain)
2010-06-30 23:55 UTC, Richard Earnshaw
Details
gcc46-pr44694-arm.patch (574 bytes, patch)
2010-07-01 07:13 UTC, Jakub Jelinek
Details | Diff
gcc46-pr44694-arm.patch (693 bytes, patch)
2010-07-01 07:24 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2010-06-27 23:55:57 UTC
Compile time of GiNaC tests increased a lot (to about 10 minutes) since 4.4

 variable tracking     : 315.80 (96%) usr   0.27 (36%) sys 316.16 (96%) wall   54301 kB (15%) ggc
Comment 1 Jan Hubicka 2010-06-27 23:57:03 UTC
Created attachment 21020 [details]
testcase
Comment 2 Richard Biener 2010-06-28 09:13:08 UTC
Confirmed.  At -O2 -g we get for 4.4.x

 variable tracking     :   0.26 ( 1%) usr   0.00 ( 0%) sys   0.24 ( 1%) wall    1870 kB ( 1%) ggc
 TOTAL                 :  26.74             1.19            29.62             282737 kB

while for the current 4.5 branch we have

 variable tracking     : 392.60 (96%) usr   2.69 (73%) sys 397.72 (96%) wall   30099 kB (11%) ggc
 TOTAL                 : 409.66             3.69           415.97             279266 kB
Comment 3 Richard Biener 2010-06-28 09:13:41 UTC
Created attachment 21023 [details]
unincluded testcase
Comment 4 Jakub Jelinek 2010-06-28 16:12:39 UTC
Seems the problem here is extremely long loc_chain lists (the longest one in insert_into_intersection has 3740 entries), so e.g. insert_into_intersection is extremely time consuming.  Most of the locations in the long lists are of the form
(plus:DI (value:DI ...) (const_int ...))
with different values and offsets.
Comment 5 Jakub Jelinek 2010-06-29 06:28:51 UTC
The extremely long location lists are caused mainly by reverse_op created equivalences.  Wonder whether we shouldn't on RHS replace sp and sp + const_int
with framep and framep + const_int even outside of memory addresses and of course not do reverse_op if the register is framep - the framep is always computable, so it isn't useful to reverse it.
Comment 6 Jakub Jelinek 2010-06-29 08:53:15 UTC
Created attachment 21035 [details]
gcc46-pr44694.patch

With this patchlet the compile time on ginac.ii went down from more than 3 minutes to 16 seconds.  The same number of DIEs as before have DW_AT_location, just .debug_loc got bigger, so need to investigate whether it is because the debug info is more completely, or if it is worse or just less compact.
Comment 7 Jakub Jelinek 2010-06-29 09:09:16 UTC
readelf -wo ginac.o1 | grep 'End of' | wc -l; readelf -wo ginac.o2 | grep 'End of' | wc -l; readelf -wo ginac.o1 | wc -l; readelf -wo ginac.o2 | wc -l; readelf -wo ginac.o1 | grep fbreg | wc -l; readelf -wo ginac.o2 | grep fbreg | wc -l
11850
11796
351354
462546
8117
341790

As the number of DW_AT_location (and DW_AT_const_value) attributes in .debug_info is identical, the above means that with the patch 54 vars no longer use .debug_loc (which means they cover the whole function while before they didn't).  For the tiny bit fewer location lists the patched version has more entries in many of them (which can still mean either that the coverage is better, or worse (there could be more holes)) and that DW_OP_fbreg is now used much more often than before (that is quite expected with this patch).
Comment 8 Jakub Jelinek 2010-06-29 14:11:47 UTC
Created attachment 21039 [details]
gcc46-pr44694.patch

Updated patch that actually passed bootstrap/regtested on x86_64-linux and i686-linux.  When (frame) is present outside of MEM addresses, some tweaks to cselib are needed, otherwise it ICEs quite often.
Comment 9 Jakub Jelinek 2010-06-30 06:12:41 UTC
Subject: Bug 44694

Author: jakub
Date: Wed Jun 30 06:12:22 2010
New Revision: 161587

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161587
Log:
	PR debug/44694
	* cselib.h (cselib_preserve_cfa_base_value): Add regno argument.
	* cselib.c (cfa_base_preserved_regno): New static variable.
	(cselib_reset_table): Don't reset cfa_base_preserved_regno instead
	of REGNO (cfa_base_preserved_val->locs->loc).
	(cselib_preserve_cfa_base_value): Add regno argument, set
	cfa_base_preserved_regno to it.
	(cselib_invalidate_regno): Allow removal of registers other than
	cfa_base_preserved_regno from cfa_base_preserved_val.
	(cselib_finish): Set cfa_base_preserved_regno to INVALID_REGNUM.
	* var-tracking.c (adjust_mems): Replace sp or hfp even outside
	of MEM addresses, if not on LHS.
	(reverse_op): Don't add reverse ops for cfa_base_rtx.
	(vt_init_cfa_base): Adjust cselib_preserve_cfa_base_value caller.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cselib.c
    trunk/gcc/cselib.h
    trunk/gcc/var-tracking.c

Comment 10 Jakub Jelinek 2010-06-30 07:16:32 UTC
Fixed on the trunk so far.
Comment 11 Jakub Jelinek 2010-06-30 15:41:16 UTC
Subject: Bug 44694

Author: jakub
Date: Wed Jun 30 15:40:53 2010
New Revision: 161610

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161610
Log:
	Backport from mainline
	2010-06-30  Jakub Jelinek  <jakub@redhat.com>

	PR debug/44694
	* cselib.h (cselib_preserve_cfa_base_value): Add regno argument.
	* cselib.c (cfa_base_preserved_regno): New static variable.
	(cselib_reset_table): Don't reset cfa_base_preserved_regno instead
	of REGNO (cfa_base_preserved_val->locs->loc).
	(cselib_preserve_cfa_base_value): Add regno argument, set
	cfa_base_preserved_regno to it.
	(cselib_invalidate_regno): Allow removal of registers other than
	cfa_base_preserved_regno from cfa_base_preserved_val.
	(cselib_finish): Set cfa_base_preserved_regno to INVALID_REGNUM.
	* var-tracking.c (adjust_mems): Replace sp or hfp even outside
	of MEM addresses, if not on LHS.
	(reverse_op): Don't add reverse ops for cfa_base_rtx.
	(vt_init_cfa_base): Adjust cselib_preserve_cfa_base_value caller.

Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/cselib.c
    branches/gcc-4_5-branch/gcc/cselib.h
    branches/gcc-4_5-branch/gcc/var-tracking.c

Comment 12 Richard Earnshaw 2010-06-30 23:42:31 UTC
(In reply to comment #9)
> Subject: Bug 44694
> 
> Author: jakub
> Date: Wed Jun 30 06:12:22 2010
> New Revision: 161587
> 
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161587
> Log:
>         PR debug/44694
>
This patch causes a build failure on arm-eabi when building libstdc++.  The compiler ends up passing the internal version of the frame pointer register (which has to be eliminated into either SP of FP) to arm_dbx_register_number().
Comment 13 Richard Earnshaw 2010-06-30 23:43:58 UTC
Created attachment 21048 [details]
testcase for introduced regression

compiler options in first line of testcase.
Comment 14 Richard Earnshaw 2010-06-30 23:55:36 UTC
Created attachment 21050 [details]
testcase for introduced regression

compiler options in first line of testcase.
Comment 15 Jakub Jelinek 2010-07-01 07:13:35 UTC
Created attachment 21052 [details]
gcc46-pr44694-arm.patch

Untested fix for this issue.
Comment 16 Jakub Jelinek 2010-07-01 07:24:32 UTC
Created attachment 21053 [details]
gcc46-pr44694-arm.patch

Actually that was wrong, we need to emit DW_OP_fbreg offset DW_OP_stack_value
in that case instead.
Comment 17 Jakub Jelinek 2010-07-01 11:12:01 UTC
Subject: Bug 44694

Author: jakub
Date: Thu Jul  1 11:11:46 2010
New Revision: 161662

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161662
Log:
	PR debug/44694
	* dwarf2out.c (reg_loc_descriptor): For eliminated arg_pointer_rtx
	or frame_pointer_rtx use DW_OP_fbreg offset DW_OP_stack_value.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c

Comment 18 Jakub Jelinek 2010-07-01 11:13:02 UTC
Subject: Bug 44694

Author: jakub
Date: Thu Jul  1 11:12:24 2010
New Revision: 161663

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161663
Log:
	PR debug/44694
	* dwarf2out.c (reg_loc_descriptor): For eliminated arg_pointer_rtx
	or frame_pointer_rtx use DW_OP_fbreg offset DW_OP_stack_value.

Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/dwarf2out.c

Comment 19 Jakub Jelinek 2010-07-01 12:37:38 UTC
Fixed.