From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69100 invoked by alias); 10 Mar 2015 12:51:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 69014 invoked by uid 55); 10 Mar 2015 12:51:45 -0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/44563] GCC uses a lot of RAM when compiling a large numbers of functions Date: Tue, 10 Mar 2015 12:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.3.4 X-Bugzilla-Keywords: compile-time-hog, memory-hog X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01113.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44563 --- Comment #27 from rguenther at suse dot de --- On Tue, 10 Mar 2015, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44563 > > Jakub Jelinek changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |jakub at gcc dot gnu.org > > --- Comment #25 from Jakub Jelinek --- > Or perhaps add split_block variant that uses the old bb for the second part > rather than the first one, and use it in the inliner? Seems like Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 221317) +++ gcc/tree-inline.c (working copy) @@ -4777,18 +4781,19 @@ static bool gimple_expand_calls_inline (basic_block bb, copy_body_data *id) { gimple_stmt_iterator gsi; + bool inlined = false; - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi);) { gimple stmt = gsi_stmt (gsi); + gsi_prev (&gsi); if (is_gimple_call (stmt) - && !gimple_call_internal_p (stmt) - && expand_call_inline (bb, stmt, id)) - return true; + && !gimple_call_internal_p (stmt)) + inlined |= expand_call_inline (bb, stmt, id); } - return false; + return inlined; } fixes the issue as well as gsi stays valid over inline expansion if we advance it before that.