+2020-08-07 Giuliano Belinasssi <giuliano.belinassi@usp.br>
+
+ * cgraphunit.c (childno): New variable.
+ (maybe_compile_in_parallel): Store current child number.
+ * gcc.c (sort_asm_files): New function.
+ * toplev.c (init_additional_asm_names_file): Output child number.
+ * toplev.h (init_additional_asm_names_file): Update interface.
+ * tree.c (get_file_function_name): Do not use randomness when
+ promoting names.
+
2020-08-06 Giuliano Belinasssi <giuliano.belinassi@usp.br>
* symtab.c (change_decl_assembler_name): Remove RTL output if
return true;
}
-static bool maybe_compile_in_parallel (void)
+/* If forked, which child am I? */
+
+static int childno = -1;
+
+static bool
+maybe_compile_in_parallel (void)
{
struct symtab_node *node;
int partitions, i, j;
pids[j] = fork ();
if (pids[j] == 0)
{
+ childno = j;
lto_apply_partition_mask (ltrans_partitions[j]);
return true;
}
/* Output everything. */
init_asm_output (name);
if (split_outputs)
- handle_additional_asm (true);
+ handle_additional_asm (childno);
switch_to_section (text_section);
(*debug_hooks->assembly_start) ();
return false;
}
+static void
+sort_asm_files (vec <char *> *_lines)
+{
+ vec <char *> &lines = *_lines;
+ int i, n = lines.length ();
+ char **temp_buf = XALLOCAVEC (char *, n);
+
+ for (i = 0; i < n; i++)
+ temp_buf[i] = lines[i];
+
+ for (i = 0; i < n; i++)
+ {
+ char *no_str = strtok (temp_buf[i], " ");
+ char *name = strtok (NULL, "");
+
+ int pos = atoi (no_str);
+ lines[pos] = name;
+ }
+}
+
/* Append -fsplit-output=<tempfile> to all calls to compilers. Return true
if a additional call to LD is required to merge the resulting files. */
parallelize. */
}
+ sort_asm_files (&additional_asm_files);
+
if (n_commands != 1)
fatal_error (input_location,
"Auto parallelism is unsupported when piping commands");
/* Reinitialize the assembler file and store it in the additional asm file. */
-void handle_additional_asm (bool child)
+void
+handle_additional_asm (int childno)
{
gcc_assert (split_outputs);
- if (child)
- {
- const char *temp_asm_name = make_temp_file (".s");
- asm_file_name = temp_asm_name;
+ if (childno < 0)
+ return;
- if (asm_out_file == stdout)
- fatal_error (UNKNOWN_LOCATION, "Unexpected asm output to stdout");
+ const char *temp_asm_name = make_temp_file (".s");
+ asm_file_name = temp_asm_name;
- fclose (asm_out_file);
+ if (asm_out_file == stdout)
+ fatal_error (UNKNOWN_LOCATION, "Unexpected asm output to stdout");
- asm_out_file = fopen (temp_asm_name, "w");
- if (!asm_out_file)
- fatal_error (UNKNOWN_LOCATION, "Unable to create asm output file.");
- }
+ fclose (asm_out_file);
- /* Reopen file as append mode. Here we assume that write to append file is
- atomic, as it is in Linux. */
- additional_asm_filenames = fopen (split_outputs, "a");
- if (!additional_asm_filenames)
- fatal_error (UNKNOWN_LOCATION, "Unable open the temporary asm files container.");
+ asm_out_file = fopen (temp_asm_name, "w");
+ if (!asm_out_file)
+ fatal_error (UNKNOWN_LOCATION, "Unable to create asm output file");
- fprintf (additional_asm_filenames, "%s\n", asm_file_name);
- fclose (additional_asm_filenames);
+ /* Reopen file as append mode. Here we assume that write to append file is
+ atomic, as it is in Linux. */
+ additional_asm_filenames = fopen (split_outputs, "a");
+ if (!additional_asm_filenames)
+ fatal_error (UNKNOWN_LOCATION, "Unable to open the temporary asm files container");
+
+ fprintf (additional_asm_filenames, "%d %s\n", childno, asm_file_name);
+ fclose (additional_asm_filenames);
}
/* A helper function; used as the reallocator function for cpp's line
extern void initialize_rtl (void);
extern void init_additional_asm_names_file (void);
-extern void handle_additional_asm (bool);
+extern void handle_additional_asm (int);
#endif /* ! GCC_TOPLEV_H */
q = (char *) alloca (9 + 19 + len + 1);
memcpy (q, file, len + 1);
- snprintf (q + len, 9 + 19 + 1, "_%08X_" HOST_WIDE_INT_PRINT_HEX,
- crc32_string (0, name), get_random_seed (false));
+ snprintf (q + len, 9 + 19 + 1, "_%08X", crc32_string (0, name));
p = q;
}
Use a global object (which is already required to be unique over
the program) rather than the file name (which imposes extra
constraints). */
+
sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
filter_name (buf);