https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63191
Bug ID: 63191 Summary: 32-bit gcc uses excessive memory during dead store elimination with -fPIC Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: woodfin at intersystems dot com Created attachment 33453 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33453&action=edit Source triggering memory usage Every version of gcc I try from 4.4 -> 4.9.1 on 32-bit Linux uses excessive memory (eventually exhausting all 3GB of virtual address space) when I compile the attached (generated, simplified) source with g++ -c -O2 -fPIC badmatch.cpp 4.3 does not exhibit the issue. 64-bit Linux (gcc 4.4.4 in that case) does not exhibit the issue, and memory usage tops out at ~440MB. gcc 4.4.4 on 32-bit Linux does exhibit the issue. Dropping -fPIC causes memory usage to top out at ~175MB and the compile to succeed. -no-dse eliminates the problem as well. A look at the mallocs in the debugger suggests that the explosion of allocations is happening under rest_of_handle_dse(), e.g.: #0 0x00332e46 in malloc () from /lib/libc.so.6 #1 0x08a26148 in xmalloc () #2 0x0829285b in pool_alloc(alloc_pool_def*) () at ../.././gcc/alloc-pool.c:281 #3 0x082f076e in cselib_lookup(rtx_def*, machine_mode, int, machine_mode) () at ../.././gcc/cselib.c:1303 #4 0x089536e2 in canon_address(rtx_def*, int*, int*, long long*, cselib_val**) () at ../.././gcc/dse.c:1182 #5 0x08954770 in record_store(rtx_def*, bb_info*) () at ../.././gcc/dse.c:1443 #6 0x08955e6a in rest_of_handle_dse() () at ../.././gcc/dse.c:2616 #7 0x084bd923 in execute_one_pass(opt_pass*) () at ../.././gcc/passes.c:2233 The most recent version with which I have tested: >g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/nethome/woodfin/opt/lnxrhx86/gcc-4.9.1/libexec/gcc/i686-pc-linux-gnu/4.9.1/lto-wrapper Target: i686-pc-linux-gnu Configured with: ./configure --prefix=/nethome/woodfin/opt/lnxrhx86/gcc-4.9.1 --enable-languages=c,c++ --with-mpfr=/nethome/woodfin/opt/lnxrhx86/mpfr-2.4.2 --with-gmp=/nethome/woodfin/opt/lnxrhx86/gmp-4.3.2 --with-mpc=/nethome/woodfin/opt/lnxrhx86/mpc-1.0.2 Thread model: posix gcc version 4.9.1 (GCC)