Bug 29330 - [4.2 Regression] -O -ftree-loop-linear --> virtual memory exhausted
Summary: [4.2 Regression] -O -ftree-loop-linear --> virtual memory exhausted
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Jakub Jelinek
URL:
Keywords: memory-hog
Depends on:
Blocks:
 
Reported: 2006-10-03 11:53 UTC by Wouter Vermaelen
Modified: 2006-10-06 17:17 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2
Known to fail: 4.2.0
Last reconfirmed: 2006-10-06 12:49:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Vermaelen 2006-10-03 11:53:34 UTC
> g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../configure -v --enable-languages=c,c++ --prefix=/home/wouter/gcc/local --enable-shared --with-system-zlib --enable-nls --enable-threads=posix --without-included-gettext --disable-werror --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug i486-linux-gnu --enable-libmudflap --enable-checking=release
Thread model: posix
gcc version 4.2.0 20061003 (experimental)


> g++ -O -ftree-loop-linear foo.cpp
virtual memory exhausted: Cannot allocate memory


> cat foo.cpp
int buf[2][2][2][2];

void f()
{
    for (int a = 0; a < 2; ++a) {
        for (int b = 0; b < 2; ++b) {
            for (int c = 0; c < 2; ++c) {
                for (int d = 0; d < 2; ++d) {
                    buf[a][b][c][d] = 0;
                }
            }
        }
    }
}
Comment 1 Andrew Pinski 2006-10-03 16:17:30 UTC
We are trying to allocate 3.65 GB.
Comment 2 Andrew Pinski 2006-10-03 16:21:27 UTC
Confirmed.
Comment 3 Pawel Sikora 2006-10-03 18:19:32 UTC
works fine with 4.1.2svn.

$ g++ gcc-pr29330.c -Wall -c -O -ftree-loop-linear -m32 -fmem-report

Memory still allocated at the end of the compilation process
Size   Allocated        Used    Overhead
8           4096          56         120
16            16k         12k        352
64           124k        119k       1984
128         8192        6528         112
256          424k        421k       5936
512           12k       9216         168
1024         112k        112k       1568
2048          16k         12k        224
4096          80k         80k       1120
8192          48k         48k        336
16384         16k         16k         56
32768         32k         32k         56
65536        576k        576k        504
524288        512k          0          56
112          216k        207k       3024
208           16k         12k        224
192           12k         11k        168
160         8192        5440         112
176          152k        149k       2128
48           228k        225k       3648
32            44k         43k        792
80            80k         79k       1120
Total       2736k       2180k         23k
Comment 4 Andrew Pinski 2006-10-05 04:47:52 UTC
Works with 4.1.2 20061004
so yes this is a regression.
Comment 5 Robert Wilhelm 2006-10-06 04:36:53 UTC
valgrind output:

==6316== Invalid read of size 4
==6316==    at 0x8598C55: compute_all_dependences (tree-data-ref.c:3975)
==6316==  Address 0x44C0D20 is 0 bytes inside a block of size 20 free'd
==6316==    at 0x40052ED: realloc (vg_replace_malloc.c:306)
==6316==    by 0x86634B1: xrealloc (xmalloc.c:179)
==6316==
==6316== Invalid read of size 4
==6316==    at 0x8598C7A: compute_all_dependences (lambda.h:227)
==6316==  Address 0x44C0D20 is 0 bytes inside a block of size 20 free'd
==6316==    at 0x40052ED: realloc (vg_replace_malloc.c:306)
==6316==    by 0x86634B1: xrealloc (xmalloc.c:179)

Comment 6 Jakub Jelinek 2006-10-06 16:57:36 UTC
Subject: Bug 29330

Author: jakub
Date: Fri Oct  6 16:57:27 2006
New Revision: 117509

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117509
Log:
	PR tree-optimization/29330
	* tree-data-ref.c (free_data_ref): Use DR_FREE_ACCESS_FNS macro.
	(initialize_data_dependence_relation): Clear DDR_LOOP_NEST pointer
	on newly allocated ddrs.
	(find_loop_nest_1, find_loop_nest): Change LOOP_NEST to a pointer
	to VEC (loop_p, heap) pointer.
	(compute_data_dependences_for_loop): Adjust caller.
	(free_dependence_relations): Free DDR_LOOP_NEST.

	* tree-loop-linear.c (linear_transform_loops): Don't forget to
	free DEPENDENCE_RELATIONS and DATAREFS.

	* gcc.dg/pr29330.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr29330.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-data-ref.c
    trunk/gcc/tree-loop-linear.c

Comment 7 Jakub Jelinek 2006-10-06 17:17:32 UTC
Fixed in SVN.