aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuliano Belinassi <giuliano.belinassi@usp.br>2020-06-05 01:00:51 -0300
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-06-05 01:00:51 -0300
commit374ee317356c39b6ac9d483b3648ffcb6f1d2fd4 (patch)
treedc868a4b38797f636143dbf9f33f1e95f02f9968
parent735b62666917c1e313143f140521e2b9477f24c0 (diff)
downloadgcc-374ee317356c39b6ac9d483b3648ffcb6f1d2fd4.zip
gcc-374ee317356c39b6ac9d483b3648ffcb6f1d2fd4.tar.gz
gcc-374ee317356c39b6ac9d483b3648ffcb6f1d2fd4.tar.bz2
Make libgcc compile
Finally, we managed to get libgcc to compile with this version. Changes to the partitioner were necesary for this, such as merging partitions with calls to static functions in common. gcc/ChangeLog 2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br> * cgraph.h (symtab_node): New attribute aux2. * cgraphunit.c (ipa_passes): Decide not to compile in parallel. * gcc.c (has_hidden_E): New function. * (append_split_outputs): Add fPIC and abort when a hidden -E is provided. * (execute): Do not call append_split_outputs when -E is provided. * lto-partition.c: Merge calls to static functions to same partition. * (lto_check_usage_from_other_partitions): Update used_from_other_partitions to nodes other than varpool. gcc/testsuite/ChangeLog 2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br> * gcc.dg/driver/driver.exp: New test. * gcc.dg/driver/empty.c: New file.
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/cgraph.h1
-rw-r--r--gcc/cgraphunit.c8
-rw-r--r--gcc/gcc.c34
-rw-r--r--gcc/lto-partition.c34
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/driver/driver.exp7
-rw-r--r--gcc/testsuite/gcc.dg/driver/empty.c0
8 files changed, 82 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f41b7a2..79397f9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br>
+
+ * cgraph.h (symtab_node): New attribute aux2.
+ * cgraphunit.c (ipa_passes): Decide not to compile in parallel.
+ * gcc.c (has_hidden_E): New function.
+ * (append_split_outputs): Add fPIC and abort when a hidden -E is
+ provided.
+ * (execute): Do not call append_split_outputs when -E is provided.
+ * lto-partition.c: Merge calls to static functions to same
+ partition.
+ * (lto_check_usage_from_other_partitions): Update
+ used_from_other_partitions to nodes other than varpool.
+
2020-06-04 Giuliano Belinassi <giuliano.belinassi@usp.br>
* lto-partition.c (class union_find): New class.
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 5ddeb65..f2f1444 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -615,6 +615,7 @@ public:
struct lto_file_decl_data * lto_file_data;
PTR GTY ((skip)) aux;
+ int aux2;
/* Comdat group the symbol is in. Can be private if GGC allowed that. */
tree x_comdat_group;
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 3f52b61..5d8cddd 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2664,6 +2664,14 @@ ipa_passes (void)
FOR_EACH_SYMBOL (node)
node->aux = NULL;
+ /* We decided that partitioning is a bad idea. In this case, just
+ proceed with the default compilation method. */
+ if (ltrans_partitions.length () <= 1)
+ {
+ flag_wpa = NULL;
+ goto continue_compilation;
+ }
+
/* Find out statics that need to be promoted
to globals with hidden visibility because they are accessed from
multiple partitions. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 2403c8f..5144ae2 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3299,6 +3299,18 @@ static const char *get_path_to_ld (void)
return ret;
}
+/* Check if a hidden -E was passed as argument to something. */
+
+static bool has_hidden_E (int argc, const char *argv[])
+{
+ int i;
+ for (i = 0; i < argc; ++i)
+ if (!strcmp (argv[i], "-E"))
+ return true;
+
+ return false;
+}
+
/* Append -fsplit-output=<tempfile> to all calls to compilers. Return true
if a additional call to LD is required to merge the resulting files. */
@@ -3317,16 +3329,21 @@ static void append_split_outputs (extra_arg_storer *storer,
if (is_compiler (commands[0].prog))
{
- const char *extra_argument = fsplit_arg (storer);
-
argc = get_number_of_args (commands[0].argv);
- argv = storer->create_new (argc + 3);
+ argv = storer->create_new (argc + 4);
memcpy (argv, commands[0].argv, argc * sizeof (const char *));
- argv[argc++] = extra_argument;
+
+ if (!has_hidden_E (argc, commands[0].argv))
+ {
+ const char *extra_argument = fsplit_arg (storer);
+ argv[argc++] = extra_argument;
+ }
+
if (have_c)
- argv[argc++] = "-fPIE"; /* Necessary when -c is provided for some
- reason. */
+ argv[argc++] = "-fPIE";
+ argv[argc++] = "-fPIC";
+
argv[argc] = NULL;
commands[0].argv = argv;
@@ -3854,7 +3871,7 @@ execute (void)
/* Parse the argbuf into several commands. */
commands = parse_argbuf (&argbuf, &n_commands);
- if (!have_S)
+ if (!have_S && !have_E)
append_split_outputs (&storer, &additional_ld, &commands, &n_commands);
if (!wrapper_string)
@@ -4013,6 +4030,9 @@ static const char *fsplit_arg (extra_arg_storer *storer)
gcc_assert (current_infile);
current_infile->temp_additional_asm = tempname;
+ /* Remove file, once we may not even need it and create it later. */
+ /* FIXME: This is a little hackish. */
+ remove (tempname);
final = storer->create_string (n);
diff --git a/gcc/lto-partition.c b/gcc/lto-partition.c
index 1e854b5..449dcfa 100644
--- a/gcc/lto-partition.c
+++ b/gcc/lto-partition.c
@@ -465,7 +465,7 @@ lto_max_no_alonevap_map (void)
int *compression;
FOR_EACH_SYMBOL (node)
- node->aux = (void *) n++;
+ node->aux2 = n++;
union_find disjoint_sets = union_find (n);
@@ -482,9 +482,22 @@ lto_max_no_alonevap_map (void)
FOR_EACH_FUNCTION (cnode)
{
struct ipa_ref *ref = NULL;
+ cgraph_edge *e;
+
for (i = 0; cnode->iterate_reference (i, ref); i++)
- if (is_a <varpool_node *> (ref->referred))
- disjoint_sets.unite (int_cast (cnode->aux), int_cast (ref->referred->aux));
+ {
+ symtab_node *node = ref->referred;
+ if (is_a <varpool_node *> (node))
+ disjoint_sets.unite (cnode->aux2, node->aux2);
+ }
+
+ for (e = cnode->callees; e; e = e->next_callee)
+ {
+ cgraph_node *node = e->callee;
+ if (TREE_STATIC (node->decl))
+ disjoint_sets.unite (cnode->aux2, node->aux2);
+ }
+
}
/* Allocate a compression vector, where we will map each disjoint set into
@@ -508,7 +521,7 @@ lto_max_no_alonevap_map (void)
FOR_EACH_SYMBOL (node)
{
int root = disjoint_sets.find (i);
- node->aux = (void *) root;
+ node->aux2 = root;
if (compression[root] < 0)
compression[root] = j++;
i++;
@@ -521,8 +534,8 @@ lto_max_no_alonevap_map (void)
variable. Complexity: n. */
FOR_EACH_SYMBOL (node)
{
- int p = compression[int_cast (node->aux)];
- node->aux = NULL;
+ int p = compression[node->aux2];
+ node->aux2 = -1;
if (node->get_partitioning_class () != SYMBOL_PARTITION
|| symbol_partitioned_p (node))
@@ -1360,13 +1373,12 @@ lto_check_usage_from_other_partitions (void)
for (i = 0; i < ltrans_partitions.length (); i++)
{
vec<lto_encoder_entry> &nodes = (ltrans_partitions[i])->encoder->nodes;
-
+
for (j = 0; j < nodes.length (); j++)
{
- varpool_node *vnode = dyn_cast<varpool_node *> (nodes[j].node);
- if (vnode && !nodes[j].in_partition)
- vnode->used_from_other_partition = true;
+ symtab_node *node = nodes[j].node;
+ if (node && !nodes[j].in_partition)
+ node->used_from_other_partition = true;
}
}
-
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d854181..92a7e19 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br>
+
+ * gcc.dg/driver/driver.exp: New test.
+ * gcc.dg/driver/empty.c: New file.
+
2020-05-27 Giuliano Belinassi <giuliano.belinassi@usp.br>
* gcc.dg/driver/driver.exp: New test.
diff --git a/gcc/testsuite/gcc.dg/driver/driver.exp b/gcc/testsuite/gcc.dg/driver/driver.exp
index 915cbed..a1b0204 100644
--- a/gcc/testsuite/gcc.dg/driver/driver.exp
+++ b/gcc/testsuite/gcc.dg/driver/driver.exp
@@ -55,17 +55,20 @@ check-for-errors "Asembler Generation" \
check-for-errors "Asembler Generation" \
[gcc_target_compile "$srcdir/$subdir/b.c -S" "b.S" none ""]
+# Empty file is a valid program.
+check-for-errors "Empty Program" \
+ [gcc_target_compile "$srcdir/$subdir/empty.c -c" "empty.o" none ""]
+
# Test object file passthrough
check-for-errors "Object file passthrough" \
[gcc_target_compile "$srcdir/$subdir/foo.c a.o" "a.exe" none ""]
-
# Test compilation when assembler is provided
check-for-errors "Assembler with Macros" \
[gcc_target_compile "a.S -c" "a.o" none ""]
# Clean temporary generated files.
-set temp_files {"a.o" "a.S" "b.o" "b.S"}
+set temp_files {"a.o" "a.S" "b.o" "b.S" "empty.o"}
foreach f $temp_files {
if { [file exists $f] } {
diff --git a/gcc/testsuite/gcc.dg/driver/empty.c b/gcc/testsuite/gcc.dg/driver/empty.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/driver/empty.c