public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/casm-state-v3)] Use lto_debug_asm.
@ 2021-09-14 12:36 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-09-14 12:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:96c091ccb471d4faf61374b83046e4696de12a0e

commit 96c091ccb471d4faf61374b83046e4696de12a0e
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Sep 9 14:52:11 2021 +0200

    Use lto_debug_asm.

Diff:
---
 gcc/dwarf2out.c |  6 ++++++
 gcc/output.h    |  5 +++++
 gcc/toplev.c    |  5 ++++-
 gcc/varasm.c    | 20 ++++++++++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index cdfdee3cd9a..1d0b09bdaa5 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -32872,6 +32872,10 @@ dwarf2out_early_finish (const char *filename)
       || TARGET_PECOFF || TARGET_COFF)
     return;
 
+  /* Initialize an early LTO debug output file.  */
+  lto_debug_asm->out_file = fopen ("/tmp/lto-debug.s", "w");
+  push_asm (lto_debug_asm);
+
   /* Now as we are going to output for LTO initialize sections and labels
      to the LTO variants.  We don't need a random-seed postfix as other
      LTO sections as linking the LTO debug sections into one in a partial
@@ -32995,6 +32999,8 @@ dwarf2out_early_finish (const char *filename)
 				    output_indirect_string> (form);
     }
 
+  pop_asm ();
+
   /* Switch back to the text section.  */
   switch_to_section (casm->sections.text);
 }
diff --git a/gcc/output.h b/gcc/output.h
index 3fdc559fec5..d2b7ffb8db5 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -383,6 +383,11 @@ struct GTY(()) asm_out_state
 
 extern GTY(()) asm_out_state *casm;
 
+extern GTY(()) asm_out_state *lto_debug_asm;
+
+extern void push_asm (asm_out_state *asm_state);
+extern void pop_asm (void);
+
 /* Helper macro for commonly used accesses.  */
 #define asm_out_file casm->out_file
 
diff --git a/gcc/toplev.c b/gcc/toplev.c
index fcc7b39f624..c0b5b86c42a 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -171,9 +171,11 @@ const char *user_label_prefix;
 
 /* Output files for assembler code (real compiler output)
    and debugging dumps.  */
-
 asm_out_state *casm;
 
+/* Early LTO debug info output.  */
+asm_out_state *lto_debug_asm;
+
 FILE *aux_info_file;
 FILE *callgraph_info_file = NULL;
 static bitmap callgraph_info_external_printed;
@@ -1115,6 +1117,7 @@ general_init (const char *argv0, bool init_signals)
 
   /* Initialize ASM out state.  */
   casm = new (ggc_alloc<asm_out_state> ()) asm_out_state ();
+  lto_debug_asm = new (ggc_alloc<asm_out_state> ()) asm_out_state ();
 
   statistics_early_init ();
   debuginfo_early_init ();
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 61064df9dc8..a79b4edd8ca 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -8450,4 +8450,24 @@ handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
 #endif
 }
 
+/* Stack of assembly output states.  */
+static vec<asm_out_state *> casm_stack;
+
+/* Push ASM_STATE as a current casm.  */
+
+void
+push_asm (asm_out_state *asm_state)
+{
+  casm_stack.safe_push (casm);
+  casm = asm_state;
+}
+
+/* Return to previous casm state.  */
+
+void
+pop_asm ()
+{
+  casm = casm_stack.pop ();
+}
+
 #include "gt-varasm.h"


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-14 12:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 12:36 [gcc(refs/users/marxin/heads/casm-state-v3)] Use lto_debug_asm 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).