Bug 19876

Summary: [4.0 Regression] g++ starts eating all the memory and the CPU
Product: gcc Reporter: Pierre <pied>
Component: tree-optimizationAssignee: Steven Bosscher <steven>
Status: RESOLVED FIXED    
Severity: normal CC: dberlin, gcc-bugs, mueller, pinskia
Priority: P2 Keywords: memory-hog
Version: 4.0.0   
Target Milestone: 4.0.0   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu Known to work: 3.3.2
Known to fail: 4.0.0 Last reconfirmed: 2005-02-10 19:15:22
Attachments: The prepocessed source
Partial revision of the problematic patch

Description Pierre 2005-02-10 18:02:44 UTC
Hi    
    
I'm developing a linux distribution with friends, and we decided to use gcc 4.    
A few days ago, KDE 3.3.92 was released.     
But it doesn't compile :( Especially, with the kdepim package, g++ starts    
eating all the memory and all the CPU on a file.     
I can't submit this file because it relies on a lot of headers and libs from    
KDE and Qt so it would be to heavy.    
Here is the command line :   
if /bin/sh ../libtool --silent --mode=compile --tag=CXX g++ -DHAVE_CONFIG_H   
-I. -I. -I.. -I../libkmime -I../libkpgp -I../libkdenetwork -I../libkdepim   
-I../libkpimidentities -I../libemailfunctions -I../libksieve -I../mimelib   
-I../certmanager/lib -I..  -I../libkdepim -I/usr/lib/qt3/include   
-I/usr/X11R6/include   -DQT_THREAD_SUPPORT  -D_REENTRANT   
-D_FILE_OFFSET_BITS=64  -Wnon-virtual-dtor -Wno-long-long -Wundef -ansi   
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts   
-Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security   
-Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common   
-DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT   
-DQT_NO_TRANSLATION  -MT globalsettings.lo -MD -MP -MF   
".deps/globalsettings.Tpo" -c -o globalsettings.lo globalsettings.cpp; \   
then mv -f ".deps/globalsettings.Tpo" ".deps/globalsettings.Plo"; else rm -f   
".deps/globalsettings.Tpo"; exit 1; fi   
   
Configure of gcc :   
../gcc-4.0-20050130/configure --prefix=/usr --libexecdir=/usr/lib  
--enable-shared --enable-threads=posix --enable-__cxa_atexit  
--enable-clocale=gnu --enable-languages=c,c++,java,objc --with-libffi  
--enable-libffi  
 
I reported the bug on bugs.kde.org too : 
http://bugs.kde.org/show_bug.cgi?id=99045 
 
Thanks
Comment 1 Andrew Pinski 2005-02-10 18:06:55 UTC
Did you read <http://gcc.gnu.org/bugs.html>.  We need the preprocessed source.
Comment 2 Pierre 2005-02-10 18:13:08 UTC
Created attachment 8162 [details]
The prepocessed source

I'm sorry, really sorry !
I generated the file, but forget to send it :/
Comment 3 Andrew Pinski 2005-02-10 18:30:08 UTC
Ok, I can confirm this with the following options on powerpc-darwin (which means it is most likely a 
tree optimizator problem but I could be wrong).
 -fno-exceptions -fno-check-new -fno-common -O2

It worked in 3.3.2 so this is a regression.
Comment 4 Andrew Pinski 2005-02-10 18:35:13 UTC
PRE is eating up a huge amount of memory.
Comment 5 Andrew Pinski 2005-02-10 19:04:05 UTC
Reverting the following patch fixes the bug:
2005-01-14  Steven Bosscher  <stevenb@suse.de>

        * tree-ssa-dce.c (visited_control_parents): New sbitmap to
        replace BB_VISITED uses.
        (find_obviously_necessary_stmts): Don't clear BB_VISITED.
        (propagate_necessity): Check the bitmap instead of BB_VISITED.
        (tree_dce_done): Free visited_control_parents.
        (perform_tree_ssa_dce): Allocate and clear it.
        * tree-ssa-pre.c (compute_antic_aux): Make non-recursive.
        (compute_antic): Iterate from here using a DFS.  Use an sbitmap
        instead of BB_VISITED.
Comment 6 Daniel Berlin 2005-02-10 19:06:38 UTC
Pinski is correct (i know because i told him that was the cause :P)

It no longer converges (i suspect some strange bug in your logic).
Before it converged in 2 iterations.
I stopped it at 958 iterations because i was running out of memory.

Comment 7 Steven Bosscher 2005-02-10 19:15:21 UTC
I'll look into it. 
 
Comment 8 Steven Bosscher 2005-02-10 22:35:38 UTC
Created attachment 8166 [details]
Partial revision of the problematic patch

I'm not sure what exactly is wrong here.  I suggest we revert the parts of the
patch that are unrelated to BB_VISITED for now.  This is what the attached
patch does.  I'll test it and commit it if it passes.
Comment 9 GCC Commits 2005-02-11 21:52:50 UTC
Subject: Bug 19876

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	steven@gcc.gnu.org	2005-02-11 21:52:39

Modified files:
	gcc            : ChangeLog tree-ssa-pre.c 

Log message:
	PR tree-optimization/19876
	Partially revert my change from 2005-01-14
	* tree-ssa-pre.c (compute_antic_aux): Make recursive once again...
	(compute_antic): ...and remove the loop here.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7450&r2=2.7451
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-pre.c.diff?cvsroot=gcc&r1=2.63&r2=2.64

Comment 10 Steven Bosscher 2005-02-11 21:56:52 UTC
Should be fixed now.  Bash me if it is not.