public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/asm_out_file-lto-debug-info)] WIP: early debug emission to a separate file
@ 2022-07-19 12:57 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2022-07-19 12:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:32185ecd36fc5318dc0424e6eff4d562382b36dc
commit 32185ecd36fc5318dc0424e6eff4d562382b36dc
Author: Martin Liska <mliska@suse.cz>
Date: Mon Sep 6 13:28:50 2021 +0200
WIP: early debug emission to a separate file
Diff:
---
gcc/dwarf2out.cc | 40 ++++++++++++++++++++++------------------
gcc/output.h | 4 ++++
gcc/toplev.cc | 19 +++++++++++++++++++
gcc/varasm.cc | 13 +++++++++++--
4 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 3ac39c1a5b0..1ccee860592 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -11469,9 +11469,10 @@ output_comdat_type_unit (comdat_type_node *node,
for (i = 0; i < DWARF_TYPE_SIGNATURE_SIZE; i++)
sprintf (tmp + 3 + i * 2, "%02x", node->signature[i] & 0xff);
comdat_key = get_identifier (tmp);
- targetm.asm_out.named_section (secname,
- SECTION_DEBUG | SECTION_LINKONCE,
- comdat_key);
+ unsigned int flags = SECTION_DEBUG | SECTION_LINKONCE;
+ if (early_lto_debug)
+ flags |= SECTION_EARLY_LTO;
+ targetm.asm_out.named_section (secname, flags, comdat_key);
#else
tmp = XALLOCAVEC (char, 18 + DWARF_TYPE_SIGNATURE_SIZE * 2);
sprintf (tmp, (dwarf_version >= 5
@@ -29238,7 +29239,8 @@ output_macinfo (const char *debug_line_label, bool early_lto_debug)
SECTION_DEBUG
| SECTION_LINKONCE
| (early_lto_debug
- ? SECTION_EXCLUDE : 0),
+ ? (SECTION_EXCLUDE |
+ SECTION_EARLY_LTO): 0),
comdat_key);
ASM_GENERATE_INTERNAL_LABEL (label,
DEBUG_MACRO_SECTION_LABEL,
@@ -29283,33 +29285,35 @@ init_sections_and_labels (bool early_lto_debug)
if (!dwarf_split_debug_info)
{
debug_info_section = get_section (DEBUG_LTO_INFO_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE,
+ SECTION_DEBUG | SECTION_EXCLUDE |
+ SECTION_EARLY_LTO,
NULL);
debug_abbrev_section = get_section (DEBUG_LTO_ABBREV_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE,
+ SECTION_DEBUG | SECTION_EXCLUDE |
+ SECTION_EARLY_LTO,
NULL);
debug_macinfo_section_name
= ((dwarf_strict && dwarf_version < 5)
? DEBUG_LTO_MACINFO_SECTION : DEBUG_LTO_MACRO_SECTION);
debug_macinfo_section = get_section (debug_macinfo_section_name,
SECTION_DEBUG
- | SECTION_EXCLUDE, NULL);
+ | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
}
else
{
/* ??? Which of the following do we need early? */
debug_info_section = get_section (DEBUG_LTO_DWO_INFO_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE,
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO,
NULL);
debug_abbrev_section = get_section (DEBUG_LTO_DWO_ABBREV_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE,
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO,
NULL);
debug_skeleton_info_section = get_section (DEBUG_LTO_INFO_SECTION,
SECTION_DEBUG
- | SECTION_EXCLUDE, NULL);
+ | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
debug_skeleton_abbrev_section
= get_section (DEBUG_LTO_ABBREV_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_abbrev_section_label,
DEBUG_SKELETON_ABBREV_SECTION_LABEL,
init_sections_and_labels_generation);
@@ -29319,42 +29323,42 @@ init_sections_and_labels (bool early_lto_debug)
off dwo. */
debug_skeleton_line_section
= get_section (DEBUG_LTO_LINE_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label,
DEBUG_SKELETON_LINE_SECTION_LABEL,
init_sections_and_labels_generation);
debug_str_offsets_section
= get_section (DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE,
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO,
NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_info_section_label,
DEBUG_SKELETON_INFO_SECTION_LABEL,
init_sections_and_labels_generation);
debug_str_dwo_section = get_section (DEBUG_LTO_STR_DWO_SECTION,
- DEBUG_STR_DWO_SECTION_FLAGS,
+ DEBUG_STR_DWO_SECTION_FLAGS | SECTION_EARLY_LTO,
NULL);
debug_macinfo_section_name
= ((dwarf_strict && dwarf_version < 5)
? DEBUG_LTO_DWO_MACINFO_SECTION : DEBUG_LTO_DWO_MACRO_SECTION);
debug_macinfo_section = get_section (debug_macinfo_section_name,
- SECTION_DEBUG | SECTION_EXCLUDE,
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO,
NULL);
}
/* For macro info and the file table we have to refer to a
debug_line section. */
debug_line_section = get_section (DEBUG_LTO_LINE_SECTION,
- SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ SECTION_DEBUG | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
DEBUG_LINE_SECTION_LABEL,
init_sections_and_labels_generation);
debug_str_section = get_section (DEBUG_LTO_STR_SECTION,
DEBUG_STR_SECTION_FLAGS
- | SECTION_EXCLUDE, NULL);
+ | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
if (!dwarf_split_debug_info)
debug_line_str_section
= get_section (DEBUG_LTO_LINE_STR_SECTION,
- DEBUG_STR_SECTION_FLAGS | SECTION_EXCLUDE, NULL);
+ DEBUG_STR_SECTION_FLAGS | SECTION_EXCLUDE | SECTION_EARLY_LTO, NULL);
}
else
{
diff --git a/gcc/output.h b/gcc/output.h
index 6dea630913a..d95e1007db8 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -315,6 +315,8 @@ extern rtx_sequence *final_sequence;
#ifdef BUFSIZ
extern FILE *asm_out_file;
+extern FILE *original_asm_out_file;
+extern FILE *asm_lto_debug_file;
#endif
/* The first global object in the file. */
@@ -413,6 +415,8 @@ enum section_flag
/* subsequent bits reserved for target */
};
+#define SECTION_EARLY_LTO 0x800000
+
/* A helper function for default_elf_select_section and
default_elf_unique_section. Categorizes the DECL. */
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 61d234a9ef4..a9bd2239fa9 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -167,6 +167,8 @@ const char *user_label_prefix;
and debugging dumps. */
FILE *asm_out_file;
+FILE *original_asm_out_file;
+FILE *asm_lto_debug_file;
FILE *aux_info_file;
FILE *callgraph_info_file = NULL;
static bitmap callgraph_info_external_printed;
@@ -721,6 +723,8 @@ init_asm_output (const char *name)
"cannot open %qs for writing: %m", asm_file_name);
}
+ original_asm_out_file = asm_out_file;
+
if (!flag_syntax_only && !(global_dc->lang_mask & CL_LTODump))
{
targetm.asm_out.file_start ();
@@ -755,6 +759,12 @@ init_asm_output (const char *name)
}
}
+static void
+init_lto_debug_file (void)
+{
+ asm_lto_debug_file = fopen ("/tmp/lto-debug.s", "w");
+}
+
/* A helper function; used as the reallocator function for cpp's line
table. */
static void *
@@ -1840,6 +1850,7 @@ lang_dependent_init (const char *name)
if (!flag_wpa)
{
init_asm_output (name);
+ init_lto_debug_file ();
if (!flag_generate_lto && !flag_compare_debug)
{
@@ -2007,6 +2018,14 @@ finalize (bool no_backend)
asm_out_file = NULL;
}
+ if (asm_lto_debug_file)
+ {
+ // FIXME
+ if (fclose (asm_lto_debug_file) != 0)
+ fatal_error (input_location, "error closing %s: %m", "lto debug file");
+ asm_lto_debug_file = NULL;
+ }
+
if (stack_usage_file)
{
fclose (stack_usage_file);
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 4db8506b106..7c903aab596 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -191,6 +191,7 @@ struct section_hasher : ggc_ptr_hash<section>
/* Hash table of named sections. */
static GTY(()) hash_table<section_hasher> *section_htab;
+static GTY(()) hash_table<section_hasher> *lto_debug_section_htab;
struct object_block_hasher : ggc_ptr_hash<object_block>
{
@@ -294,8 +295,10 @@ get_section (const char *name, unsigned int flags, tree decl,
{
section *sect, **slot;
- slot = section_htab->find_slot_with_hash (name, htab_hash_string (name),
- INSERT);
+ hash_table<section_hasher> *htab
+ = flags | SECTION_EARLY_LTO ? lto_debug_section_htab : section_htab;
+ slot = htab->find_slot_with_hash (name, htab_hash_string (name),
+ INSERT);
flags |= SECTION_NAMED;
if (decl != nullptr
&& DECL_P (decl)
@@ -6610,6 +6613,7 @@ void
init_varasm_once (void)
{
section_htab = hash_table<section_hasher>::create_ggc (31);
+ lto_debug_section_htab = hash_table<section_hasher>::create_ggc (31);
object_block_htab = hash_table<object_block_hasher>::create_ggc (31);
const_desc_htab = hash_table<tree_descriptor_hasher>::create_ggc (1009);
@@ -7799,6 +7803,11 @@ output_section_asm_op (const char *directive)
void
switch_to_section (section *new_section, tree decl)
{
+ if (new_section->common.flags & SECTION_EARLY_LTO)
+ asm_out_file = asm_lto_debug_file;
+ else
+ asm_out_file = original_asm_out_file;
+
bool retain_p;
if ((new_section->common.flags & SECTION_NAMED)
&& decl != nullptr
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-19 12:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 12:57 [gcc(refs/users/marxin/heads/asm_out_file-lto-debug-info)] WIP: early debug emission to a separate file Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).