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.
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.
Problem still exists in 4.6.2. A patch for this was committed to trunk on 29 Mar 2011 / revision 171655.
Created attachment 25640 [details] trunk change 171655 backported to 4.6.
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
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
Patch applied to 4.5, 4.6 and trunk.