GCC with patches for OS216
Revision | 374ee317356c39b6ac9d483b3648ffcb6f1d2fd4 (tree) |
---|---|
Time | 2020-06-05 13:00:51 |
Author | Giuliano Belinassi <giuliano.belinassi@usp....> |
Commiter | Giuliano Belinassi |
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.
@@ -1,3 +1,16 @@ | ||
1 | +2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br> | |
2 | + | |
3 | + * cgraph.h (symtab_node): New attribute aux2. | |
4 | + * cgraphunit.c (ipa_passes): Decide not to compile in parallel. | |
5 | + * gcc.c (has_hidden_E): New function. | |
6 | + * (append_split_outputs): Add fPIC and abort when a hidden -E is | |
7 | + provided. | |
8 | + * (execute): Do not call append_split_outputs when -E is provided. | |
9 | + * lto-partition.c: Merge calls to static functions to same | |
10 | + partition. | |
11 | + * (lto_check_usage_from_other_partitions): Update | |
12 | + used_from_other_partitions to nodes other than varpool. | |
13 | + | |
1 | 14 | 2020-06-04 Giuliano Belinassi <giuliano.belinassi@usp.br> |
2 | 15 | |
3 | 16 | * lto-partition.c (class union_find): New class. |
@@ -615,6 +615,7 @@ public: | ||
615 | 615 | struct lto_file_decl_data * lto_file_data; |
616 | 616 | |
617 | 617 | PTR GTY ((skip)) aux; |
618 | + int aux2; | |
618 | 619 | |
619 | 620 | /* Comdat group the symbol is in. Can be private if GGC allowed that. */ |
620 | 621 | tree x_comdat_group; |
@@ -2664,6 +2664,14 @@ ipa_passes (void) | ||
2664 | 2664 | FOR_EACH_SYMBOL (node) |
2665 | 2665 | node->aux = NULL; |
2666 | 2666 | |
2667 | + /* We decided that partitioning is a bad idea. In this case, just | |
2668 | + proceed with the default compilation method. */ | |
2669 | + if (ltrans_partitions.length () <= 1) | |
2670 | + { | |
2671 | + flag_wpa = NULL; | |
2672 | + goto continue_compilation; | |
2673 | + } | |
2674 | + | |
2667 | 2675 | /* Find out statics that need to be promoted |
2668 | 2676 | to globals with hidden visibility because they are accessed from |
2669 | 2677 | multiple partitions. */ |
@@ -3299,6 +3299,18 @@ static const char *get_path_to_ld (void) | ||
3299 | 3299 | return ret; |
3300 | 3300 | } |
3301 | 3301 | |
3302 | +/* Check if a hidden -E was passed as argument to something. */ | |
3303 | + | |
3304 | +static bool has_hidden_E (int argc, const char *argv[]) | |
3305 | +{ | |
3306 | + int i; | |
3307 | + for (i = 0; i < argc; ++i) | |
3308 | + if (!strcmp (argv[i], "-E")) | |
3309 | + return true; | |
3310 | + | |
3311 | + return false; | |
3312 | +} | |
3313 | + | |
3302 | 3314 | /* Append -fsplit-output=<tempfile> to all calls to compilers. Return true |
3303 | 3315 | if a additional call to LD is required to merge the resulting files. */ |
3304 | 3316 |
@@ -3317,16 +3329,21 @@ static void append_split_outputs (extra_arg_storer *storer, | ||
3317 | 3329 | |
3318 | 3330 | if (is_compiler (commands[0].prog)) |
3319 | 3331 | { |
3320 | - const char *extra_argument = fsplit_arg (storer); | |
3321 | - | |
3322 | 3332 | argc = get_number_of_args (commands[0].argv); |
3323 | - argv = storer->create_new (argc + 3); | |
3333 | + argv = storer->create_new (argc + 4); | |
3324 | 3334 | |
3325 | 3335 | memcpy (argv, commands[0].argv, argc * sizeof (const char *)); |
3326 | - argv[argc++] = extra_argument; | |
3336 | + | |
3337 | + if (!has_hidden_E (argc, commands[0].argv)) | |
3338 | + { | |
3339 | + const char *extra_argument = fsplit_arg (storer); | |
3340 | + argv[argc++] = extra_argument; | |
3341 | + } | |
3342 | + | |
3327 | 3343 | if (have_c) |
3328 | - argv[argc++] = "-fPIE"; /* Necessary when -c is provided for some | |
3329 | - reason. */ | |
3344 | + argv[argc++] = "-fPIE"; | |
3345 | + argv[argc++] = "-fPIC"; | |
3346 | + | |
3330 | 3347 | argv[argc] = NULL; |
3331 | 3348 | |
3332 | 3349 | commands[0].argv = argv; |
@@ -3854,7 +3871,7 @@ execute (void) | ||
3854 | 3871 | /* Parse the argbuf into several commands. */ |
3855 | 3872 | commands = parse_argbuf (&argbuf, &n_commands); |
3856 | 3873 | |
3857 | - if (!have_S) | |
3874 | + if (!have_S && !have_E) | |
3858 | 3875 | append_split_outputs (&storer, &additional_ld, &commands, &n_commands); |
3859 | 3876 | |
3860 | 3877 | if (!wrapper_string) |
@@ -4013,6 +4030,9 @@ static const char *fsplit_arg (extra_arg_storer *storer) | ||
4013 | 4030 | gcc_assert (current_infile); |
4014 | 4031 | |
4015 | 4032 | current_infile->temp_additional_asm = tempname; |
4033 | + /* Remove file, once we may not even need it and create it later. */ | |
4034 | + /* FIXME: This is a little hackish. */ | |
4035 | + remove (tempname); | |
4016 | 4036 | |
4017 | 4037 | final = storer->create_string (n); |
4018 | 4038 |
@@ -465,7 +465,7 @@ lto_max_no_alonevap_map (void) | ||
465 | 465 | int *compression; |
466 | 466 | |
467 | 467 | FOR_EACH_SYMBOL (node) |
468 | - node->aux = (void *) n++; | |
468 | + node->aux2 = n++; | |
469 | 469 | |
470 | 470 | union_find disjoint_sets = union_find (n); |
471 | 471 |
@@ -482,9 +482,22 @@ lto_max_no_alonevap_map (void) | ||
482 | 482 | FOR_EACH_FUNCTION (cnode) |
483 | 483 | { |
484 | 484 | struct ipa_ref *ref = NULL; |
485 | + cgraph_edge *e; | |
486 | + | |
485 | 487 | for (i = 0; cnode->iterate_reference (i, ref); i++) |
486 | - if (is_a <varpool_node *> (ref->referred)) | |
487 | - disjoint_sets.unite (int_cast (cnode->aux), int_cast (ref->referred->aux)); | |
488 | + { | |
489 | + symtab_node *node = ref->referred; | |
490 | + if (is_a <varpool_node *> (node)) | |
491 | + disjoint_sets.unite (cnode->aux2, node->aux2); | |
492 | + } | |
493 | + | |
494 | + for (e = cnode->callees; e; e = e->next_callee) | |
495 | + { | |
496 | + cgraph_node *node = e->callee; | |
497 | + if (TREE_STATIC (node->decl)) | |
498 | + disjoint_sets.unite (cnode->aux2, node->aux2); | |
499 | + } | |
500 | + | |
488 | 501 | } |
489 | 502 | |
490 | 503 | /* Allocate a compression vector, where we will map each disjoint set into |
@@ -508,7 +521,7 @@ lto_max_no_alonevap_map (void) | ||
508 | 521 | FOR_EACH_SYMBOL (node) |
509 | 522 | { |
510 | 523 | int root = disjoint_sets.find (i); |
511 | - node->aux = (void *) root; | |
524 | + node->aux2 = root; | |
512 | 525 | if (compression[root] < 0) |
513 | 526 | compression[root] = j++; |
514 | 527 | i++; |
@@ -521,8 +534,8 @@ lto_max_no_alonevap_map (void) | ||
521 | 534 | variable. Complexity: n. */ |
522 | 535 | FOR_EACH_SYMBOL (node) |
523 | 536 | { |
524 | - int p = compression[int_cast (node->aux)]; | |
525 | - node->aux = NULL; | |
537 | + int p = compression[node->aux2]; | |
538 | + node->aux2 = -1; | |
526 | 539 | |
527 | 540 | if (node->get_partitioning_class () != SYMBOL_PARTITION |
528 | 541 | || symbol_partitioned_p (node)) |
@@ -1360,13 +1373,12 @@ lto_check_usage_from_other_partitions (void) | ||
1360 | 1373 | for (i = 0; i < ltrans_partitions.length (); i++) |
1361 | 1374 | { |
1362 | 1375 | vec<lto_encoder_entry> &nodes = (ltrans_partitions[i])->encoder->nodes; |
1363 | - | |
1376 | + | |
1364 | 1377 | for (j = 0; j < nodes.length (); j++) |
1365 | 1378 | { |
1366 | - varpool_node *vnode = dyn_cast<varpool_node *> (nodes[j].node); | |
1367 | - if (vnode && !nodes[j].in_partition) | |
1368 | - vnode->used_from_other_partition = true; | |
1379 | + symtab_node *node = nodes[j].node; | |
1380 | + if (node && !nodes[j].in_partition) | |
1381 | + node->used_from_other_partition = true; | |
1369 | 1382 | } |
1370 | 1383 | } |
1371 | - | |
1372 | 1384 | } |
@@ -1,3 +1,8 @@ | ||
1 | +2020-06-05 Giuliano Belinassi <giuliano.belinassi@usp.br> | |
2 | + | |
3 | + * gcc.dg/driver/driver.exp: New test. | |
4 | + * gcc.dg/driver/empty.c: New file. | |
5 | + | |
1 | 6 | 2020-05-27 Giuliano Belinassi <giuliano.belinassi@usp.br> |
2 | 7 | |
3 | 8 | * gcc.dg/driver/driver.exp: New test. |
@@ -55,17 +55,20 @@ check-for-errors "Asembler Generation" \ | ||
55 | 55 | check-for-errors "Asembler Generation" \ |
56 | 56 | [gcc_target_compile "$srcdir/$subdir/b.c -S" "b.S" none ""] |
57 | 57 | |
58 | +# Empty file is a valid program. | |
59 | +check-for-errors "Empty Program" \ | |
60 | + [gcc_target_compile "$srcdir/$subdir/empty.c -c" "empty.o" none ""] | |
61 | + | |
58 | 62 | # Test object file passthrough |
59 | 63 | check-for-errors "Object file passthrough" \ |
60 | 64 | [gcc_target_compile "$srcdir/$subdir/foo.c a.o" "a.exe" none ""] |
61 | 65 | |
62 | - | |
63 | 66 | # Test compilation when assembler is provided |
64 | 67 | check-for-errors "Assembler with Macros" \ |
65 | 68 | [gcc_target_compile "a.S -c" "a.o" none ""] |
66 | 69 | |
67 | 70 | # Clean temporary generated files. |
68 | -set temp_files {"a.o" "a.S" "b.o" "b.S"} | |
71 | +set temp_files {"a.o" "a.S" "b.o" "b.S" "empty.o"} | |
69 | 72 | |
70 | 73 | foreach f $temp_files { |
71 | 74 | if { [file exists $f] } { |