Bug 29512 - compile time hog / deadloop.
Summary: compile time hog / deadloop.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 24308 31015 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-10-19 08:59 UTC by Pawel Sikora
Modified: 2007-03-02 16:35 UTC (History)
5 users (show)

See Also:
Host:
Target: x86_64-linux
Build:
Known to work: 4.3.0
Known to fail: 4.1.2 4.2.0
Last reconfirmed:


Attachments
testcase (172.54 KB, application/octet-stream)
2006-10-19 09:00 UTC, Pawel Sikora
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2006-10-19 08:59:14 UTC
[4.1] mem usage: ~120MB, compile time: +inf? (canceled after 980 minutes).
[4.2] mem usage:  ~90MB, compile time: +inf? (similiar).
Comment 1 Pawel Sikora 2006-10-19 09:00:03 UTC
Created attachment 12458 [details]
testcase
Comment 2 Pawel Sikora 2006-10-19 09:35:37 UTC
4.1 backtrace:

#0  0x00000000005a65ad in mul_double ()
#1  0x00000000005a70e2 in int_const_binop ()
#2  0x00000000005b0796 in size_binop ()
#3  0x0000000000717d9a in bit_from_pos ()
#4  0x0000000000725157 in bit_position ()
#5  0x0000000000725165 in int_bit_position ()
#6  0x000000000075474e in classify_argument ()
#7  0x0000000000754785 in classify_argument ()
#8  0x0000000000754785 in classify_argument ()
#9  0x0000000000754785 in classify_argument ()
#10 0x0000000000754785 in classify_argument ()
#11 0x000000000075463b in classify_argument ()
#12 0x0000000000754785 in classify_argument ()
#13 0x0000000000754785 in classify_argument ()
#14 0x0000000000754785 in classify_argument ()
#15 0x0000000000754785 in classify_argument ()
#16 0x0000000000754785 in classify_argument ()
#17 0x000000000075463b in classify_argument ()
#18 0x0000000000754785 in classify_argument ()
#19 0x000000000075463b in classify_argument ()
#20 0x0000000000754785 in classify_argument ()
#21 0x0000000000754785 in classify_argument ()
#22 0x0000000000754785 in classify_argument ()
#23 0x0000000000754785 in classify_argument ()
#24 0x0000000000754785 in classify_argument ()
#25 0x000000000075463b in classify_argument ()
#26 0x0000000000754785 in classify_argument ()
#27 0x000000000075463b in classify_argument ()
#28 0x0000000000754785 in classify_argument ()
#29 0x000000000075463b in classify_argument ()
#30 0x0000000000754785 in classify_argument ()
#31 0x000000000075463b in classify_argument ()
#32 0x0000000000754785 in classify_argument ()
#33 0x000000000075463b in classify_argument ()
#34 0x0000000000754785 in classify_argument ()
#35 0x0000000000754785 in classify_argument ()
#36 0x0000000000754785 in classify_argument ()
#37 0x0000000000754785 in classify_argument ()
#38 0x0000000000754785 in classify_argument ()
#39 0x000000000075463b in classify_argument ()
#40 0x0000000000754785 in classify_argument ()
#41 0x0000000000754785 in classify_argument ()
#42 0x0000000000754c72 in examine_argument ()
#43 0x0000000000755627 in construct_container ()
#44 0x000000000075621c in ix86_function_value ()
#45 0x000000000057d938 in hard_function_value ()
#46 0x00000000005bb8aa in aggregate_value_p ()
#47 0x00000000004c130e in gimplify_modify_expr_rhs ()
#48 0x00000000004c1550 in gimplify_modify_expr ()
#49 0x00000000004c1dd5 in gimplify_expr ()
#50 0x00000000004c3fcf in gimplify_target_expr ()
#51 0x00000000004c2a55 in gimplify_expr ()
#52 0x00000000004c1f19 in gimplify_expr ()
#53 0x00000000004c4719 in gimplify_arg ()
#54 0x00000000004c48af in gimplify_call_expr ()
#55 0x00000000004c1d51 in gimplify_expr ()
#56 0x00000000004c331d in gimplify_stmt ()
#57 0x00000000004c3655 in gimplify_to_stmt_list ()
#58 0x00000000004c2947 in gimplify_expr ()
#59 0x00000000004c331d in gimplify_stmt ()
#60 0x00000000004c2b02 in gimplify_expr ()
#61 0x00000000004c331d in gimplify_stmt ()
#62 0x00000000004c3655 in gimplify_to_stmt_list ()
#63 0x00000000004c28e9 in gimplify_expr ()
#64 0x00000000004c331d in gimplify_stmt ()
#65 0x00000000004c2b02 in gimplify_expr ()
#66 0x00000000004c331d in gimplify_stmt ()
#67 0x00000000004c3655 in gimplify_to_stmt_list ()
#68 0x00000000004c28e9 in gimplify_expr ()
#69 0x00000000004c331d in gimplify_stmt ()
#70 0x00000000004c2b02 in gimplify_expr ()
#71 0x00000000004c331d in gimplify_stmt ()
#72 0x00000000004c3655 in gimplify_to_stmt_list ()
#73 0x00000000004c28e9 in gimplify_expr ()
#74 0x00000000004c331d in gimplify_stmt ()
#75 0x00000000004c2b02 in gimplify_expr ()
#76 0x00000000004c331d in gimplify_stmt ()
#77 0x00000000004c3655 in gimplify_to_stmt_list ()
#78 0x00000000004c28e9 in gimplify_expr ()
#79 0x00000000004c331d in gimplify_stmt ()
#80 0x00000000004c2b02 in gimplify_expr ()
#81 0x00000000004c331d in gimplify_stmt ()
#82 0x00000000004c3655 in gimplify_to_stmt_list ()
#83 0x00000000004c28e9 in gimplify_expr ()
#84 0x00000000004c331d in gimplify_stmt ()
#85 0x00000000004c2b02 in gimplify_expr ()
#86 0x00000000004c331d in gimplify_stmt ()
#87 0x00000000004c3655 in gimplify_to_stmt_list ()
#88 0x00000000004c28e9 in gimplify_expr ()
#89 0x00000000004c331d in gimplify_stmt ()
#90 0x00000000004c2b02 in gimplify_expr ()
#91 0x00000000004c331d in gimplify_stmt ()
#92 0x00000000004c3655 in gimplify_to_stmt_list ()
#93 0x00000000004c28e9 in gimplify_expr ()
#94 0x00000000004c331d in gimplify_stmt ()
#95 0x00000000004c2b02 in gimplify_expr ()
#96 0x00000000004c331d in gimplify_stmt ()
#97 0x00000000004c3655 in gimplify_to_stmt_list ()
#98 0x00000000004c28e9 in gimplify_expr ()
#99 0x00000000004c331d in gimplify_stmt ()
#100 0x00000000004c2b02 in gimplify_expr ()
#101 0x00000000004c331d in gimplify_stmt ()
#102 0x00000000004c3655 in gimplify_to_stmt_list ()
#103 0x00000000004c28e9 in gimplify_expr ()
#104 0x00000000004c331d in gimplify_stmt ()
#105 0x00000000004c2b02 in gimplify_expr ()
#106 0x00000000004c331d in gimplify_stmt ()
#107 0x00000000004c3655 in gimplify_to_stmt_list ()
#108 0x00000000004c28e9 in gimplify_expr ()
#109 0x00000000004c331d in gimplify_stmt ()
#110 0x00000000004c2b02 in gimplify_expr ()
#111 0x00000000004c331d in gimplify_stmt ()
#112 0x00000000004c3655 in gimplify_to_stmt_list ()
#113 0x00000000004c28e9 in gimplify_expr ()
#114 0x00000000004c331d in gimplify_stmt ()
#115 0x00000000004c2b02 in gimplify_expr ()
#116 0x00000000004c331d in gimplify_stmt ()
#117 0x00000000004c3655 in gimplify_to_stmt_list ()
#118 0x00000000004c28e9 in gimplify_expr ()
#119 0x00000000004c331d in gimplify_stmt ()
#120 0x00000000004c2b02 in gimplify_expr ()
#121 0x00000000004c331d in gimplify_stmt ()
#122 0x00000000004c3655 in gimplify_to_stmt_list ()
#123 0x00000000004c28e9 in gimplify_expr ()
#124 0x00000000004c331d in gimplify_stmt ()
#125 0x00000000004c2b02 in gimplify_expr ()
#126 0x00000000004c331d in gimplify_stmt ()
#127 0x00000000004c3655 in gimplify_to_stmt_list ()
#128 0x00000000004c28e9 in gimplify_expr ()
---Type <return> to continue, or q <return> to quit---
#129 0x00000000004c331d in gimplify_stmt ()
#130 0x00000000004c2b02 in gimplify_expr ()
#131 0x00000000004c331d in gimplify_stmt ()
#132 0x00000000004c3655 in gimplify_to_stmt_list ()
#133 0x00000000004c28e9 in gimplify_expr ()
#134 0x00000000004c331d in gimplify_stmt ()
#135 0x00000000004c2b02 in gimplify_expr ()
#136 0x00000000004c331d in gimplify_stmt ()
#137 0x00000000004c3655 in gimplify_to_stmt_list ()
#138 0x00000000004c28e9 in gimplify_expr ()
#139 0x00000000004c331d in gimplify_stmt ()
#140 0x00000000004c2b02 in gimplify_expr ()
#141 0x00000000004c331d in gimplify_stmt ()
#142 0x00000000004c3655 in gimplify_to_stmt_list ()
#143 0x00000000004c28e9 in gimplify_expr ()
#144 0x00000000004c331d in gimplify_stmt ()
#145 0x00000000004c2b02 in gimplify_expr ()
#146 0x00000000004c331d in gimplify_stmt ()
#147 0x00000000004c3655 in gimplify_to_stmt_list ()
#148 0x00000000004c28e9 in gimplify_expr ()
#149 0x00000000004c331d in gimplify_stmt ()
#150 0x00000000004c2b02 in gimplify_expr ()
#151 0x00000000004c331d in gimplify_stmt ()
#152 0x00000000004c3655 in gimplify_to_stmt_list ()
#153 0x00000000004c28e9 in gimplify_expr ()
#154 0x00000000004c331d in gimplify_stmt ()
#155 0x00000000004c2b02 in gimplify_expr ()
#156 0x00000000004c331d in gimplify_stmt ()
#157 0x00000000004c3655 in gimplify_to_stmt_list ()
#158 0x00000000004c28e9 in gimplify_expr ()
#159 0x00000000004c331d in gimplify_stmt ()
#160 0x00000000004c2b02 in gimplify_expr ()
#161 0x00000000004c331d in gimplify_stmt ()
#162 0x00000000004c3655 in gimplify_to_stmt_list ()
#163 0x00000000004c28e9 in gimplify_expr ()
#164 0x00000000004c331d in gimplify_stmt ()
#165 0x00000000004c2b02 in gimplify_expr ()
#166 0x00000000004c331d in gimplify_stmt ()
#167 0x00000000004c3655 in gimplify_to_stmt_list ()
#168 0x00000000004c28e9 in gimplify_expr ()
#169 0x00000000004c331d in gimplify_stmt ()
#170 0x00000000004c2b02 in gimplify_expr ()
#171 0x00000000004c331d in gimplify_stmt ()
#172 0x00000000004c3655 in gimplify_to_stmt_list ()
#173 0x00000000004c28e9 in gimplify_expr ()
#174 0x00000000004c331d in gimplify_stmt ()
#175 0x00000000004c2b02 in gimplify_expr ()
#176 0x00000000004c331d in gimplify_stmt ()
#177 0x00000000004c3655 in gimplify_to_stmt_list ()
#178 0x00000000004c28e9 in gimplify_expr ()
#179 0x00000000004c331d in gimplify_stmt ()
#180 0x00000000004c2b02 in gimplify_expr ()
#181 0x00000000004c331d in gimplify_stmt ()
#182 0x00000000004c3655 in gimplify_to_stmt_list ()
#183 0x00000000004c28e9 in gimplify_expr ()
#184 0x00000000004c331d in gimplify_stmt ()
#185 0x00000000004c2b02 in gimplify_expr ()
#186 0x00000000004c331d in gimplify_stmt ()
#187 0x00000000004c3655 in gimplify_to_stmt_list ()
#188 0x00000000004c3737 in gimplify_bind_expr ()
#189 0x00000000004c240c in gimplify_expr ()
#190 0x00000000004c331d in gimplify_stmt ()
#191 0x00000000004c33b5 in gimplify_body ()
#192 0x00000000004c355a in gimplify_function_tree ()
#193 0x00000000004ac9e3 in c_genericize ()
#194 0x0000000000485fc5 in cp_genericize ()
#195 0x000000000041a05a in finish_function ()
#196 0x0000000000429390 in instantiate_decl ()
#197 0x000000000042b0b3 in instantiate_pending_templates ()
#198 0x000000000043b781 in cp_finish_file ()
#199 0x00000000004024fe in finish_file ()
#200 0x00000000004a789f in c_common_parse_file ()
#201 0x000000000071d144 in toplev_main ()
#202 0x00000000004b0275 in main ()
Comment 3 Richard Biener 2006-10-19 14:31:49 UTC
I can confirm this.  We are gimplifying some large tree(s) like

#150 0x00000000005257ff in gimplify_stmt (stmt_p=0x7fffcff543e8)
    at /space//rguenther/src/svn/gcc-4_1-branch/gcc/gimplify.c:4028
4028      gimplify_expr (stmt_p, NULL, NULL, is_gimple_stmt, fb_none);
(gdb) call debug_generic_expr (*stmt_p)
operator= (&TARGET_EXPR <D.120775, operator| (D.121290, (struct parser<boost::spirit::alternative<boost::spirit::alternative
.......
[return slot optimization]>, &((struct definition<boost::spirit::scanner<const char*, boost::spirit::scanner_policies<boost::spirit::skipper_iteration_policy<boost::spirit::iteration_policy>, boost::spirit::match_policy, boost::spirit::action_policy> > >D.98251 *) thisD.100424)->hex_digit_ntD.101683)

and thus spend a lot of time in

#60 0x0000000000524020 in gimplify_modify_expr_rhs (expr_p=0x7fffcff50c60, 
    from_p=0x2ac5e2795090, to_p=0x2ac5e2795088, pre_p=0x7fffcff542e8, 
    post_p=0x7fffcff50f40, want_value=0 '\0')
    at /space//rguenther/src/svn/gcc-4_1-branch/gcc/gimplify.c:3183
3183            if (!CALL_EXPR_RETURN_SLOT_OPT (*from_p)

which in turn dispatches to i386.c:classify_argument at some point which is
a nice (*cough*) O(n^m) with m >= 2 complexity function.

And for some reason we won't return from frame #55, which is the topmost
classify_argument frame:

#57 0x00000000008ed590 in ix86_return_in_memory (type=0x2ac5dfd980b0)
    at /space//rguenther/src/svn/gcc-4_1-branch/gcc/config/i386/i386.c:3531
3531        return !examine_argument (mode, type, 1, &needed_intregs, &needed_sseregs);
(gdb) down
#56 0x00000000008ebf29 in examine_argument (mode=BLKmode, type=0x2ac5dfd980b0, 
    in_return=1, int_nregs=0x7fffcff509c4, sse_nregs=0x7fffcff509c0)
    at /space//rguenther/src/svn/gcc-4_1-branch/gcc/config/i386/i386.c:2882
2882      int n = classify_argument (mode, type, class, 0);
(gdb) 
#55 0x00000000008eb47a in classify_argument (mode=BLKmode, 
    type=0x2ac5dfd980b0, classes=0x7fffcff50980, bit_offset=0)
    at /space//rguenther/src/svn/gcc-4_1-branch/gcc/config/i386/i386.c:2637
2637                       num = classify_argument (TYPE_MODE (type),
(gdb) finish
Run till exit from #55 0x00000000008eb47a in classify_argument (mode=BLKmode, 
    type=0x2ac5dfd980b0, classes=0x7fffcff50980, bit_offset=0)
    at /space//rguenther/src/svn/gcc-4_1-branch/gcc/config/i386/i386.c:2637

(it's probably not really dead here, just taking a long time to complete, as
finishing earlier frames takes more and more time)
Comment 4 Pawel Sikora 2006-10-19 14:46:53 UTC
(In reply to comment #3)

> (it's probably not really dead here, just taking a long time to complete, as
> finishing earlier frames takes more and more time)

compilation for i486 target takes ~20 seconds and ~300MB of memory.
for x86_64 target the 16 hours in not enough.
Comment 5 Richard Biener 2006-10-19 15:15:58 UTC
It _looks_ like we're needlessly recursing into the BINFOs in the i386 backend.
Comment 6 Jan Hubicka 2006-10-19 19:36:12 UTC
Subject: Re:  compile time hog / deadloop.

> 
> 
> ------- Comment #5 from rguenth at gcc dot gnu dot org  2006-10-19 15:15 -------
> It _looks_ like we're needlessly recursing into the BINFOs in the i386 backend.

What that code is shooting for is to interpret the class hiearchy as an
union - each base class is walked and classified.
This is not exactly my area, but does the testcase really have so deep
nesting of base classes to this shows up in profiles?

Honza
Comment 7 Richard Biener 2006-10-19 20:45:51 UTC
I wonder why we walk the class hierarchy using the BINFOs at all.  It contains lots of recursively empty structures - maybe better just walk the TYPE_FIELDS
list recursively?
Comment 8 Richard Biener 2006-10-19 20:47:26 UTC
Btw. - completely killing the BINFO walking bootstraps and regtests ok...
Comment 9 Jan Hubicka 2006-10-19 23:32:39 UTC
Subject: Re:  compile time hog / deadloop.

Just for a record, we discussed this a bit on IRC.  I origionally wrote
that loop copying logic from alias.c just to be sure that all the fields
from base clases are merged into the result.

It seems that TYPE_FIELDS should already contain all of them and if this
is true, I think it is safe to drop the first loop as Richard suggest,
since we should not worry about other properties of the base class, like
aliasing does.

The merging does slightly more than just dump merging of all fields into
the classes array. For instance it might be convinced that something is
missaligned and dump whole thing to memory, so I would preffer that that
the patch is tested by comparing assembly of some non-trivial C++ code.
But looking at the function, I can't come with scenario, where this
would change ABI behaviour.

Honza

PS: Thianks for looking into this obviously my failure!
Comment 10 Richard Biener 2006-10-21 10:05:32 UTC
Subject: Bug 29512

Author: rguenth
Date: Sat Oct 21 10:05:21 2006
New Revision: 117927

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117927
Log:
2006-10-21  Richard Guenther  <rguenther@suse.de>

	PR target/29512
	* config/i386/i386.c (classify_argument): Remove redundant
	walking of the BINFOs.
	(contains_128bit_aligned_vector_p): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c

Comment 11 Richard Biener 2006-10-21 10:09:11 UTC
Fixed for 4.3.
Comment 12 Andrew Pinski 2006-10-21 20:58:56 UTC
*** Bug 24308 has been marked as a duplicate of this bug. ***
Comment 13 Andrew Pinski 2006-10-21 21:03:40 UTC
Fixed so closing.
Comment 14 Pawel Sikora 2006-12-01 12:24:34 UTC
no backport to 4.1/4.2 ?
Comment 15 Richard Biener 2006-12-01 16:04:39 UTC
Not a regression.
Comment 16 Richard Biener 2007-03-02 15:16:03 UTC
*** Bug 31015 has been marked as a duplicate of this bug. ***