This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Merging debug strings
- From: Ben Young <ben dot young at transversal dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 2 Oct 2003 08:16:42 +0000 (GMT)
- Subject: Merging debug strings
Hi there!
This is my first time posting on this mailing list, so if I have got the
format wrong, or if I am posting to the wrong list please bear with me.
Our company untill recently was have severe problems with our link times.
Looking at various mailing lists it appeared the problem could be in the
string constant merging algorithm, but -fno-merge-constants did not appear
to help.
Investigating further we noticed that nearly all the time was stend
merging the strings in the debug_str sections. This was confirmed by the
fact that linking without -g was very quick. As there doesn't seem to be a
option for disableing this string merging, and as we still needed the
debug symbols we produced this patch.
It has been tested with gcc 3.2.1 and 3.2.3
Please could you take a look and see whether it it suitable for including
in gcc or whether we have missed the point and should be doing something
else.
Ben
---
P.S This reduced one particular link time from 20mins to 4s!
diff -ur gcc-3.2.1/gcc/dwarf2out.c gcc-3.2.1-patched/gcc/dwarf2out.c
--- gcc-3.2.1/gcc/dwarf2out.c 2003-09-30 14:07:14.000000000 +0100
+++ gcc-3.2.1-patched/gcc/dwarf2out.c 2003-09-30 12:03:51.000000000
+0100
@@ -12112,7 +12112,11 @@
if (node->form == DW_FORM_strp)
{
- named_section_flags (DEBUG_STR_SECTION, DEBUG_STR_SECTION_FLAGS);
+ int flags = DEBUG_STR_SECTION_FLAGS;
+ if ( !flag_merge_debug_strs )
+ flags &=~ ( SECTION_MERGE | SECTION_STRINGS | SECTION_ENTSIZE );
+
+ named_section_flags (DEBUG_STR_SECTION, flags);
ASM_OUTPUT_LABEL (asm_out_file, node->label);
assemble_string ((const char *) HT_STR (&node->id),
HT_LEN (&node->id) + 1);
diff -ur gcc-3.2.1/gcc/flags.h gcc-3.2.1-patched/gcc/flags.h
--- gcc-3.2.1/gcc/flags.h 2003-09-30 14:07:14.000000000 +0100
+++ gcc-3.2.1-patched/gcc/flags.h 2003-09-30 11:05:07.000000000
+0100
@@ -566,6 +566,10 @@
variables. */
extern int flag_merge_constants;
+
+/* This will attempt to merge .debug_str section strings */
+extern int flag_merge_debug_strs;
+
/* If one, renumber instruction UIDs to reduce the number of
unused UIDs if there are a lot of instructions. If greater than
one, unconditionally renumber instruction UIDs. */
diff -ur gcc-3.2.1/gcc/toplev.c gcc-3.2.1-patched/gcc/toplev.c
--- gcc-3.2.1/gcc/toplev.c 2003-09-30 14:10:36.000000000 +0100
+++ gcc-3.2.1-patched/gcc/toplev.c 2003-09-30 11:04:24.000000000
+0100
@@ -862,6 +862,9 @@
variables. */
int flag_merge_constants = 1;
+/* This will attempt to merge .debug_str section strings */
+int flag_merge_debug_strs = 1;
+
/* If one, renumber instruction UIDs to reduce the number of
unused UIDs if there are a lot of instructions. If greater than
one, unconditionally renumber instruction UIDs. */
@@ -1120,9 +1123,11 @@
{"align-functions", &align_functions, 0,
N_("Align the start of functions") },
{"merge-constants", &flag_merge_constants, 1,
- N_("Attempt to merge identical constants accross compilation units")
},
+ N_("Attempt to merge identical constants across compilation units") },
{"merge-all-constants", &flag_merge_constants, 2,
N_("Attempt to merge identical constants and constant variables") },
+ {"merge-debug-strs", &flag_merge_debug_strs, 1,
+ N_("Attempt to merge identical .debug_str strings across compilation
units") },
{"dump-unnumbered", &flag_dump_unnumbered, 1,
N_("Suppress output of instruction numbers and line number notes in
debugging dumps") },
{"instrument-functions", &flag_instrument_function_entry_exit, 1,