diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-06-18 17:21:54 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-06-18 17:21:54 -0300 |
commit | 35bfd2e0d64af8962593a77a9b382d45866cebf9 (patch) | |
tree | 62059b3eeee18844d48ab85a6f80453b88b10ac8 /gcc | |
parent | affffe8d3130277801f15d108654a896322e914c (diff) | |
download | gcc-35bfd2e0d64af8962593a77a9b382d45866cebf9.zip gcc-35bfd2e0d64af8962593a77a9b382d45866cebf9.tar.gz gcc-35bfd2e0d64af8962593a77a9b382d45866cebf9.tar.bz2 |
Manage to get bootstrap to work.
Previously, Bootstrap was not working by the following reasons:
* The gimplifier was emiting assembler early on the compilation
* The driver was spamming as many processes in parallel as it
could (fork bomb), crashing the computer.
In this commit we fix these issues.
gcc/ChangeLog
2020-06-18 Giuliano Belinassi <giuliano.belinassi@usp.br>
* toplev.c (lang_dependent_init): Move call to init_asm output to
* cgraphunit.c (compile): Here. Also run handle_additional_asm if
split_outputs is provided.
* gcc.c (append_split_ouputs): Record asm temporary file.
(execute): Run a max of 4 jobs in parallel instead of n_commands.
* cgraph.h: Update finalize_compilation_unit and compile
declarations.
2020-06-18 Richard Biener <rguenther@suse.de>
* varasm.c (assemble_variable): Make sure to not
defer output when outputting addressed constants.
(output_constant_def_contents): Likewise.
(add_constant_to_table): Take and pass on whether to
defer output.
(output_addressed_constants): Likewise.
(output_constant_def): Pass on whether to defer output
to add_constant_to_table.
(tree_output_constant_def): Defer output of constants.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/cgraph.h | 4 | ||||
-rw-r--r-- | gcc/cgraphunit.c | 11 | ||||
-rw-r--r-- | gcc/gcc.c | 39 | ||||
-rw-r--r-- | gcc/lto/lto.c | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 13 | ||||
-rw-r--r-- | gcc/toplev.h | 1 | ||||
-rw-r--r-- | gcc/varasm.c | 26 |
8 files changed, 78 insertions, 40 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e6611a..c50fe1c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2020-06-18 Giuliano Belinassi <giuliano.belinassi@usp.br> + + * toplev.c (lang_dependent_init): Move call to init_asm output to + * cgraphunit.c (compile): Here. Also run handle_additional_asm if + split_outputs is provided. + * gcc.c (append_split_ouputs): Record asm temporary file. + (execute): Run a max of 4 jobs in parallel instead of n_commands. + * cgraph.h: Update finalize_compilation_unit and compile + declarations. + +2020-06-18 Richard Biener <rguenther@suse.de> + + * varasm.c (assemble_variable): Make sure to not + defer output when outputting addressed constants. + (output_constant_def_contents): Likewise. + (add_constant_to_table): Take and pass on whether to + defer output. + (output_addressed_constants): Likewise. + (output_constant_def): Pass on whether to defer output + to add_constant_to_table. + (tree_output_constant_def): Defer output of constants. + 2020-06-17 Giuliano Belinassi <giuliano.belinassi@usp.br> * cgraphunit.c (ipa_passes): Flush asm file, and handle diff --git a/gcc/cgraph.h b/gcc/cgraph.h index f2f1444..5678696 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -2273,7 +2273,7 @@ public: inline asm_node *finalize_toplevel_asm (tree asm_str); /* Analyze the whole compilation unit once it is parsed completely. */ - void finalize_compilation_unit (void); + void finalize_compilation_unit (const char *); /* C++ frontend produce same body aliases all over the place, even before PCH gets streamed out. It relies on us linking the aliases with their function @@ -2283,7 +2283,7 @@ public: void process_same_body_aliases (void); /* Perform simple optimizations based on callgraph. */ - void compile (void); + void compile (const char *); /* Process CGRAPH_NEW_FUNCTIONS and perform actions necessary to add these functions into callgraph in a way so they look like ordinary reachable diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 8e27e87..f479c7a 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2709,7 +2709,6 @@ ipa_passes (void) pids[i] = fork (); if (pids[i] == 0) { - handle_additional_asm (true); lto_apply_partition_mask (ltrans_partitions[i]); goto continue_compilation; @@ -2828,7 +2827,7 @@ symbol_table::output_weakrefs (void) /* Perform simple optimizations based on callgraph. */ void -symbol_table::compile (void) +symbol_table::compile (const char *name) { if (seen_error ()) return; @@ -2873,6 +2872,10 @@ symbol_table::compile (void) timevar_pop (TV_CGRAPHOPT); /* Output everything. */ + init_asm_output (name); + if (split_outputs) + handle_additional_asm (true); + switch_to_section (text_section); (*debug_hooks->assembly_start) (); if (!quiet_flag) @@ -3040,7 +3043,7 @@ debuginfo_early_stop (void) /* Analyze the whole compilation unit once it is parsed completely. */ void -symbol_table::finalize_compilation_unit (void) +symbol_table::finalize_compilation_unit (const char *name) { timevar_push (TV_CGRAPH); @@ -3097,7 +3100,7 @@ symbol_table::finalize_compilation_unit (void) } /* Finally drive the pass manager. */ - compile (); + compile (name); timevar_pop (TV_CGRAPH); } @@ -3412,6 +3412,7 @@ static void append_split_outputs (extra_arg_storer *storer, const char **argv = storer->create_new (orig_argc + 1); const char *temp_obj = make_temp_file ("additional-obj.o"); record_temp_file (temp_obj, true, true); + record_temp_file (additional_asm_files[i], true, true); memcpy (argv, orig_argv, (orig_argc + 1) * sizeof (const char *)); @@ -3860,6 +3861,9 @@ execute (void) struct command additional_ld = {NULL, NULL}; extra_arg_storer storer; + struct command *commands_batch; + int n; + gcc_assert (!processing_spec_function); if (wrapper_string) @@ -3903,22 +3907,33 @@ execute (void) append_valgrind (&to_be_released, n_commands, commands); #endif - /* Run each piped subprocess. */ + /* FIXME: Interact with GNU Jobserver if necessary. */ - pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file) - ? PEX_RECORD_TIMES : 0), - progname, temp_filename); - if (pex == NULL) - fatal_error (input_location, "%<pex_init%> failed: %m"); + commands_batch = commands; + n = MIN (4, n_commands); + + for (int i = 0; n > 0; i += 4, n = MIN (4, n_commands - i)) + { + /* Run each piped subprocess. */ + + pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file) + ? PEX_RECORD_TIMES : 0), + progname, temp_filename); + if (pex == NULL) + fatal_error (input_location, "%<pex_init%> failed: %m"); - /* Lauch the commands. */ - async_launch_commands (pex, n_commands, commands); + /* Lauch the commands. */ + async_launch_commands (pex, n, commands_batch); - /* Await them to be done. */ - ret = await_commands_to_finish (pex, n_commands, commands); + /* Await them to be done. */ + ret |= await_commands_to_finish (pex, n, commands_batch); + + commands_batch = commands_batch + n; + + /* Cleanup. */ + pex_free (pex); + } - /* Cleanup. */ - pex_free (pex); if (ret != 0) goto cleanup; diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 803b992..51a27b2 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -650,7 +650,7 @@ lto_main (void) /* Let the middle end know that we have read and merged all of the input files. */ - symtab->compile (); + symtab->compile (main_input_filename); timevar_stop (TV_PHASE_OPT_GEN); diff --git a/gcc/toplev.c b/gcc/toplev.c index 447cb8f..b62ba25 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -105,11 +105,10 @@ static void do_compile (); static void process_options (void); static void backend_init (void); static int lang_dependent_init (const char *); -static void init_asm_output (const char *); static void finalize (bool); static void crash_signal (int) ATTRIBUTE_NORETURN; -static void compile_file (void); +static void compile_file (const char *); /* True if we don't need a backend (e.g. preprocessing only). */ static bool no_backend; @@ -452,7 +451,7 @@ wrapup_global_declarations (tree *vec, int len) output and various debugging dumps. */ static void -compile_file (void) +compile_file (const char *name) { timevar_start (TV_PHASE_PARSING); timevar_push (TV_PARSE_GLOBAL); @@ -483,7 +482,7 @@ compile_file (void) if (!in_lto_p) { timevar_start (TV_PHASE_OPT_GEN); - symtab->finalize_compilation_unit (); + symtab->finalize_compilation_unit (name); timevar_stop (TV_PHASE_OPT_GEN); } @@ -834,7 +833,7 @@ print_switch_values (print_switch_fn_type print_fn) on, because then the driver will have provided the name of a temporary file or bit bucket for us. NAME is the file specified on the command line, possibly NULL. */ -static void +void init_asm_output (const char *name) { if (name == NULL && asm_file_name == 0) @@ -2018,8 +2017,6 @@ lang_dependent_init (const char *name) if (!flag_wpa) { - init_asm_output (name); - /* If stack usage information is desired, open the output file. */ if (flag_stack_usage && !flag_generate_lto) stack_usage_file = open_auxiliary_file ("su"); @@ -2318,7 +2315,7 @@ do_compile () timevar_stop (TV_PHASE_SETUP); - compile_file (); + compile_file (main_input_filename); } else { diff --git a/gcc/toplev.h b/gcc/toplev.h index 11a1d3d..7159f5f 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -52,6 +52,7 @@ extern void rest_of_decl_compilation (tree, int, int); extern void rest_of_type_compilation (tree, int); extern void init_optimization_passes (void); extern bool enable_rtl_dump_file (void); +extern void init_asm_output (const char *); /* In except.c. Initialize exception handling. This is used by the Ada and LTO front ends to initialize EH "on demand". See lto-streamer-in.c diff --git a/gcc/varasm.c b/gcc/varasm.c index f062e48..6d2766b 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -110,7 +110,7 @@ static void decode_addr_const (tree, class addr_const *); static hashval_t const_hash_1 (const tree); static int compare_constant (const tree, const tree); static void output_constant_def_contents (rtx); -static void output_addressed_constants (tree); +static void output_addressed_constants (tree, int); static unsigned HOST_WIDE_INT output_constant (tree, unsigned HOST_WIDE_INT, unsigned int, bool, bool); static void globalize_decl (tree); @@ -2272,7 +2272,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, /* Output any data that we will need to use the address of. */ if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node) - output_addressed_constants (DECL_INITIAL (decl)); + output_addressed_constants (DECL_INITIAL (decl), 0); /* dbxout.c needs to know this. */ if (sect && (sect->common.flags & SECTION_CODE) != 0) @@ -3427,11 +3427,11 @@ build_constant_desc (tree exp) already have labels. */ static constant_descriptor_tree * -add_constant_to_table (tree exp) +add_constant_to_table (tree exp, int defer) { /* The hash table methods may call output_constant_def for addressed constants, so handle them first. */ - output_addressed_constants (exp); + output_addressed_constants (exp, defer); /* Sanity check to catch recursive insertion. */ static bool inserting; @@ -3475,7 +3475,7 @@ add_constant_to_table (tree exp) rtx output_constant_def (tree exp, int defer) { - struct constant_descriptor_tree *desc = add_constant_to_table (exp); + struct constant_descriptor_tree *desc = add_constant_to_table (exp, defer); maybe_output_constant_def_contents (desc, defer); return desc->rtl; } @@ -3545,7 +3545,7 @@ output_constant_def_contents (rtx symbol) /* Make sure any other constants whose addresses appear in EXP are assigned label numbers. */ - output_addressed_constants (exp); + output_addressed_constants (exp, 0); /* We are no longer deferring this constant. */ TREE_ASM_WRITTEN (decl) = TREE_ASM_WRITTEN (exp) = 1; @@ -3609,7 +3609,7 @@ lookup_constant_def (tree exp) tree tree_output_constant_def (tree exp) { - struct constant_descriptor_tree *desc = add_constant_to_table (exp); + struct constant_descriptor_tree *desc = add_constant_to_table (exp, 1); tree decl = SYMBOL_REF_DECL (XEXP (desc->rtl, 0)); varpool_node::finalize_decl (decl); return decl; @@ -4328,7 +4328,7 @@ compute_reloc_for_constant (tree exp) Indicate whether an ADDR_EXPR has been encountered. */ static void -output_addressed_constants (tree exp) +output_addressed_constants (tree exp, int defer) { tree tem; @@ -4348,21 +4348,21 @@ output_addressed_constants (tree exp) tem = DECL_INITIAL (tem); if (CONSTANT_CLASS_P (tem) || TREE_CODE (tem) == CONSTRUCTOR) - output_constant_def (tem, 0); + output_constant_def (tem, defer); if (TREE_CODE (tem) == MEM_REF) - output_addressed_constants (TREE_OPERAND (tem, 0)); + output_addressed_constants (TREE_OPERAND (tem, 0), defer); break; case PLUS_EXPR: case POINTER_PLUS_EXPR: case MINUS_EXPR: - output_addressed_constants (TREE_OPERAND (exp, 1)); + output_addressed_constants (TREE_OPERAND (exp, 1), defer); gcc_fallthrough (); CASE_CONVERT: case VIEW_CONVERT_EXPR: - output_addressed_constants (TREE_OPERAND (exp, 0)); + output_addressed_constants (TREE_OPERAND (exp, 0), defer); break; case CONSTRUCTOR: @@ -4370,7 +4370,7 @@ output_addressed_constants (tree exp) unsigned HOST_WIDE_INT idx; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, tem) if (tem != 0) - output_addressed_constants (tem); + output_addressed_constants (tem, defer); } break; |