From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id D18D43857C59; Tue, 14 Sep 2021 12:35:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D18D43857C59 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/casm-state-v3)] Step #1. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/casm-state-v3 X-Git-Oldrev: e2103982da7be8781900653a5f7c5a5d0a57d38a X-Git-Newrev: de2e6a6036388de831a20678f543b5034b7c8e22 Message-Id: <20210914123513.D18D43857C59@sourceware.org> Date: Tue, 14 Sep 2021 12:35:13 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 12:35:13 -0000 https://gcc.gnu.org/g:de2e6a6036388de831a20678f543b5034b7c8e22 commit de2e6a6036388de831a20678f543b5034b7c8e22 Author: Martin Liska Date: Tue Sep 7 13:32:57 2021 +0200 Step #1. Diff: --- gcc/config/i386/i386.c | 12 ++++++------ gcc/output.h | 25 +++++++++++++++++++------ gcc/toplev.c | 37 ++++++++++++++++++++----------------- gcc/varasm.c | 8 -------- 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7b173bc0beb..3b2dcb47b05 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -1567,7 +1567,7 @@ ix86_function_naked (const_tree fn) /* Write the extra assembler code needed to declare a function properly. */ void -ix86_asm_output_function_label (FILE *asm_out_file, const char *fname, +ix86_asm_output_function_label (FILE *out_file, const char *fname, tree decl) { bool is_ms_hook = ix86_function_ms_hook_prologue (decl); @@ -1581,14 +1581,14 @@ ix86_asm_output_function_label (FILE *asm_out_file, const char *fname, unsigned int filler_cc = 0xcccccccc; for (i = 0; i < filler_count; i += 4) - fprintf (asm_out_file, ASM_LONG " %#x\n", filler_cc); + fprintf (out_file, ASM_LONG " %#x\n", filler_cc); } #ifdef SUBTARGET_ASM_UNWIND_INIT - SUBTARGET_ASM_UNWIND_INIT (asm_out_file); + SUBTARGET_ASM_UNWIND_INIT (out_file); #endif - ASM_OUTPUT_LABEL (asm_out_file, fname); + ASM_OUTPUT_LABEL (out_file, fname); /* Output magic byte marker, if hot-patch attribute is set. */ if (is_ms_hook) @@ -1597,14 +1597,14 @@ ix86_asm_output_function_label (FILE *asm_out_file, const char *fname, { /* leaq [%rsp + 0], %rsp */ fputs (ASM_BYTE "0x48, 0x8d, 0xa4, 0x24, 0x00, 0x00, 0x00, 0x00\n", - asm_out_file); + out_file); } else { /* movl.s %edi, %edi push %ebp movl.s %esp, %ebp */ - fputs (ASM_BYTE "0x8b, 0xff, 0x55, 0x8b, 0xec\n", asm_out_file); + fputs (ASM_BYTE "0x8b, 0xff, 0x55, 0x8b, 0xec\n", out_file); } } } diff --git a/gcc/output.h b/gcc/output.h index 73ca4545f4f..c7ee25c2bd4 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -313,9 +313,25 @@ extern rtx_sequence *final_sequence; /* File in which assembler code is being written. */ -#ifdef BUFSIZ -extern FILE *asm_out_file; -#endif +struct GTY(()) asm_out_state +{ + asm_out_state (): out_file (NULL), m_in_section (NULL), + m_in_cold_section_p (false) + {} + + /* Assembly output stream. */ + FILE * GTY((skip)) out_file; + + section *m_in_section; + bool m_in_cold_section_p; +}; + +extern GTY(()) asm_out_state *casm; + +/* Helper macro for commonly used accesses. */ +#define asm_out_file casm->out_file +#define in_section casm->m_in_section +#define in_cold_section_p casm->m_in_cold_section_p /* The first global object in the file. */ extern const char *first_global_object_name; @@ -526,9 +542,6 @@ extern GTY(()) section *comm_section; extern GTY(()) section *lcomm_section; extern GTY(()) section *bss_noswitch_section; -extern GTY(()) section *in_section; -extern GTY(()) bool in_cold_section_p; - extern section *get_unnamed_section (unsigned int, void (*) (const void *), const void *); extern section *get_section (const char *, unsigned int, tree, diff --git a/gcc/toplev.c b/gcc/toplev.c index 14d1335e79e..8d525e3a267 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -172,7 +172,8 @@ const char *user_label_prefix; /* Output files for assembler code (real compiler output) and debugging dumps. */ -FILE *asm_out_file; +asm_out_state *casm; + FILE *aux_info_file; FILE *callgraph_info_file = NULL; static bitmap callgraph_info_external_printed; @@ -552,13 +553,13 @@ compile_file (void) if (flag_generate_lto && !flag_fat_lto_objects) { #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON - ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, NULL_TREE, "__gnu_lto_slim", + ASM_OUTPUT_ALIGNED_DECL_COMMON (casm->out_file, NULL_TREE, "__gnu_lto_slim", HOST_WIDE_INT_1U, 8); #elif defined ASM_OUTPUT_ALIGNED_COMMON - ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, "__gnu_lto_slim", + ASM_OUTPUT_ALIGNED_COMMON (casm->out_file, "__gnu_lto_slim", HOST_WIDE_INT_1U, 8); #else - ASM_OUTPUT_COMMON (asm_out_file, "__gnu_lto_slim", + ASM_OUTPUT_COMMON (casm->out_file, "__gnu_lto_slim", HOST_WIDE_INT_1U, HOST_WIDE_INT_1U); #endif @@ -696,7 +697,7 @@ static void init_asm_output (const char *name) { if (name == NULL && asm_file_name == 0) - asm_out_file = stdout; + casm->out_file = stdout; else { if (asm_file_name == 0) @@ -710,17 +711,17 @@ init_asm_output (const char *name) asm_file_name = dumpname; } if (!strcmp (asm_file_name, "-")) - asm_out_file = stdout; + casm->out_file = stdout; else if (!canonical_filename_eq (asm_file_name, name) || !strcmp (asm_file_name, HOST_BIT_BUCKET)) - asm_out_file = fopen (asm_file_name, "w"); + casm->out_file = fopen (asm_file_name, "w"); else /* Use UNKOWN_LOCATION to prevent gcc from printing the first line in the current file. */ fatal_error (UNKNOWN_LOCATION, "input file %qs is the same as output file", asm_file_name); - if (asm_out_file == 0) + if (casm->out_file == 0) fatal_error (UNKNOWN_LOCATION, "cannot open %qs for writing: %m", asm_file_name); } @@ -747,14 +748,14 @@ init_asm_output (const char *name) if (flag_verbose_asm) { - print_version (asm_out_file, ASM_COMMENT_START, true); - fputs (ASM_COMMENT_START, asm_out_file); - fputs (" options passed: ", asm_out_file); + print_version (casm->out_file, ASM_COMMENT_START, true); + fputs (ASM_COMMENT_START, casm->out_file); + fputs (" options passed: ", casm->out_file); char *cmdline = gen_command_line_string (save_decoded_options, save_decoded_options_count); - fputs (cmdline, asm_out_file); + fputs (cmdline, casm->out_file); free (cmdline); - fputc ('\n', asm_out_file); + fputc ('\n', casm->out_file); } } } @@ -1112,6 +1113,9 @@ general_init (const char *argv0, bool init_signals) symtab = new (ggc_alloc ()) symbol_table (); + /* Initialize ASM out state. */ + casm = new (ggc_alloc ()) asm_out_state (); + statistics_early_init (); debuginfo_early_init (); } @@ -2083,13 +2087,12 @@ finalize (bool no_backend) whether fclose returns an error, since the pages might still be on the buffer chain while the file is open. */ - if (asm_out_file) + if (casm->out_file) { - if (ferror (asm_out_file) != 0) + if (ferror (casm->out_file) != 0) fatal_error (input_location, "error writing to %s: %m", asm_file_name); - if (fclose (asm_out_file) != 0) + if (fclose (casm->out_file) != 0) fatal_error (input_location, "error closing %s: %m", asm_file_name); - asm_out_file = NULL; } if (stack_usage_file) diff --git a/gcc/varasm.c b/gcc/varasm.c index 53cf6dea3f3..b876063f5be 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -159,14 +159,6 @@ section *exception_section; first call to switch_to_eh_frame_section. */ section *eh_frame_section; -/* asm_out_file's current section. This is NULL if no section has yet - been selected or if we lose track of what the current section is. */ -section *in_section; - -/* True if code for the current function is currently being directed - at the cold section. */ -bool in_cold_section_p; - /* The following global holds the "function name" for the code in the cold section of a function, if hot/cold function splitting is enabled and there was actually code that went into the cold section. A