Bug 48190 - [regression?] Huge memory use while compiling qemu-0.4.0
Summary: [regression?] Huge memory use while compiling qemu-0.4.0
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.2
: P3 normal
Target Milestone: ---
Assignee: Richard Sandiford
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-18 16:25 UTC by walt
Modified: 2011-11-25 10:47 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-03-28 08:59:13


Attachments
The patch to qemu code that causes gcc-4.5.2 to hog memory (658 bytes, patch)
2011-03-18 16:25 UTC, walt
Details | Diff
trunk change 171655 backported to 4.6. (3.63 KB, patch)
2011-10-27 23:26 UTC, Henrik Nordström
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description walt 2011-03-18 16:25:35 UTC
Created attachment 23709 [details]
The patch to qemu code that causes gcc-4.5.2 to hog memory

While compiling qemu-0.4.0, gcc-4.5.2 consumes > 3GB of RAM at one point
(building target-i386/translate.c) instead of < 1GB needed by gcc-4.4.4.

$gcc -v
Using built-in specs.
COLLECT_GCC=/usr/i686-pc-linux-gnu/gcc-bin/4.5.2/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.5.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /U/portage/sys-devel/gcc-4.5.2/work/gcc-4.5.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.5.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.5.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.5.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.5.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --disable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.5.2/python --enable-checking=release --enable-java-awt=gtk --with-arch=i686 --enable-languages=c,c++,java --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.2 p1.1, pie-0.4.5'
Thread model: posix
gcc version 4.5.2 (Gentoo 4.5.2 p1.1, pie-0.4.5) 

CFLAGS="-march=athlon-xp -O2 -pipe"

The memory hogging started with this commit to the qemu git repository, which I will attach:

commit c832e3de64f1069313fc0672087791cc3dd5b4d8
Author: Richard Henderson
Date:   Mon Jan 10 19:23:47 2011 -0800

    target-i386: Use deposit operation.
    
    Use this for assignment to the low byte or low word of a register.
Comment 1 walt 2011-03-19 16:20:24 UTC
This bug is a duplicate of https://bugs.launchpad.net/gcc-linaro/+bug/714921

I tried to mark it as a duplicate, but bugzilla won't accept a bug number
from a different project.  Hmph.
Comment 2 Henrik Nordström 2011-10-27 23:10:20 UTC
Problem still exists in 4.6.2.

A patch for this was committed to trunk on 29 Mar 2011 / revision 171655.
Comment 3 Henrik Nordström 2011-10-27 23:26:05 UTC
Created attachment 25640 [details]
trunk change 171655 backported to 4.6.
Comment 4 Richard Sandiford 2011-11-25 10:41:22 UTC
Author: rsandifo
Date: Fri Nov 25 10:41:17 2011
New Revision: 181716

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181716
Log:
gcc/
	Backport from mainline:

	2011-03-29  Richard Sandiford  <richard.sandiford@linaro.org>

	PR debug/48190
	* dwarf2out.c (dw_loc_list_node): Add resolved_addr and replaced.
	(cached_dw_loc_list_def): New structure.
	(cached_dw_loc_list): New typedef.
	(cached_dw_loc_list_table): New variable.
	(cached_dw_loc_list_table_hash): New function.
	(cached_dw_loc_list_table_eq): Likewise.
	(add_location_or_const_value_attribute): Take a bool cache_p.
	Cache the list when the parameter is true.
	(gen_formal_parameter_die): Update caller.
	(gen_variable_die): Likewise.
	(dwarf2out_finish): Likewise.
	(dwarf2out_abstract_function): Nullify cached_dw_loc_list_table
	while generating debug info for the decl.
	(dwarf2out_function_decl): Clear cached_dw_loc_list_table.
	(dwarf2out_init): Initialize cached_dw_loc_list_table.
	(resolve_addr): Cache the result of resolving a chain of
	location lists.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/dwarf2out.c
Comment 5 Richard Sandiford 2011-11-25 10:44:01 UTC
Author: rsandifo
Date: Fri Nov 25 10:43:58 2011
New Revision: 181717

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181717
Log:
gcc/
	Backport from mainline:

	2011-03-29  Richard Sandiford  <richard.sandiford@linaro.org>

	PR debug/48190
	* dwarf2out.c (dw_loc_list_node): Add resolved_addr and replaced.
	(cached_dw_loc_list_def): New structure.
	(cached_dw_loc_list): New typedef.
	(cached_dw_loc_list_table): New variable.
	(cached_dw_loc_list_table_hash): New function.
	(cached_dw_loc_list_table_eq): Likewise.
	(add_location_or_const_value_attribute): Take a bool cache_p.
	Cache the list when the parameter is true.
	(gen_formal_parameter_die): Update caller.
	(gen_variable_die): Likewise.
	(dwarf2out_finish): Likewise.
	(dwarf2out_abstract_function): Nullify cached_dw_loc_list_table
	while generating debug info for the decl.
	(dwarf2out_function_decl): Clear cached_dw_loc_list_table.
	(dwarf2out_init): Initialize cached_dw_loc_list_table.
	(resolve_addr): Cache the result of resolving a chain of
	location lists.

	From: 2010-10-12  Jakub Jelinek  <jakub@redhat.com>
	* dwarf2out.c (dw_loc_list_node): Add emitted field.
	(output_loc_list): Return immediately if emitted is set, set it.

Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/dwarf2out.c
Comment 6 Richard Sandiford 2011-11-25 10:47:02 UTC
Patch applied to 4.5, 4.6 and trunk.