diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-06-15 18:42:10 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-06-15 18:42:10 +0000 |
commit | 8388d80a5e86797b3c0822baf6d41c02fa8b41dd (patch) | |
tree | a753e9e9d5423fbd3ccff9f0c5190c796dd8e3c2 | |
parent | 9363d72dbb84ed29a4bc100d478d0f77afb67f3b (diff) | |
download | gcc-8388d80a5e86797b3c0822baf6d41c02fa8b41dd.tar.gz |
PR lto/69866
* lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions
that resolved externally.
* gcc.dg/lto/pr69866_0.c: New test.
* gcc.dg/lto/pr69866_1.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249224 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/lto/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/lto/lto-partition.c | 2 | ||||
-rw-r--r-- | gcc/lto/lto-symtab.c | 36 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr69866_0.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/lto/pr69866_1.c | 6 |
6 files changed, 69 insertions, 1 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index e63f2037191..58601c54b46 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,10 @@ +2017-06-15 Jan Hubicka <hubicka@ucw.cz> + Thomas Preud'homme <thomas.preudhomme@arm.com> + + PR lto/69866 + * lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions + that resolved externally. + 2017-05-23 Jan Hubicka <hubicka@ucw.cz> * lto.c (do_whole_program_analysis): Replace inline_free_summary diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 3600ab23bd9..620deac090b 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -132,7 +132,7 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node) /* Be sure that we never try to duplicate partitioned symbol or add external symbol. */ - gcc_assert (c != SYMBOL_EXTERNAL + gcc_assert ((c != SYMBOL_EXTERNAL || node->alias) && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node))); part->symbols++; diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c index 9fd94861c6d..019677eaf95 100644 --- a/gcc/lto/lto-symtab.c +++ b/gcc/lto/lto-symtab.c @@ -952,6 +952,42 @@ lto_symtab_merge_symbols (void) if (tgt) node->resolve_alias (tgt, true); } + /* If the symbol was preempted outside IR, see if we want to get rid + of the definition. */ + if (node->analyzed + && !DECL_EXTERNAL (node->decl) + && (node->resolution == LDPR_PREEMPTED_REG + || node->resolution == LDPR_RESOLVED_IR + || node->resolution == LDPR_RESOLVED_EXEC + || node->resolution == LDPR_RESOLVED_DYN)) + { + DECL_EXTERNAL (node->decl) = 1; + /* If alias to local symbol was preempted by external definition, + we know it is not pointing to the local symbol. Remove it. */ + if (node->alias + && !node->weakref + && !node->transparent_alias + && node->get_alias_target ()->binds_to_current_def_p ()) + { + node->alias = false; + node->remove_all_references (); + node->definition = false; + node->analyzed = false; + node->cpp_implicit_alias = false; + } + else if (!node->alias + && node->definition + && node->get_availability () <= AVAIL_INTERPOSABLE) + { + if ((cnode = dyn_cast <cgraph_node *> (node)) != NULL) + cnode->reset (); + else + { + node->analyzed = node->definition = false; + node->remove_all_references (); + } + } + } if (!(cnode = dyn_cast <cgraph_node *> (node)) || !cnode->clone_of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3677d15c453..a79f533992e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-06-15 Thomas Preud'homme <thomas.preudhomme@arm.com> + + PR lto/69866 + * gcc.dg/lto/pr69866_0.c: New test. + * gcc.dg/lto/pr69866_1.c: Likewise. + 2017-06-15 Jozef Lawrynowicz <jozef.l@somniumtech.com> PR target/78818 diff --git a/gcc/testsuite/gcc.dg/lto/pr69866_0.c b/gcc/testsuite/gcc.dg/lto/pr69866_0.c new file mode 100644 index 00000000000..f49ef8d4c1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr69866_0.c @@ -0,0 +1,13 @@ +/* { dg-lto-do link } */ + +int _umh(int i) +{ + return i+1; +} + +int weaks(int i) __attribute__((weak, alias("_umh"))); + +int main() +{ + return weaks(10); +} diff --git a/gcc/testsuite/gcc.dg/lto/pr69866_1.c b/gcc/testsuite/gcc.dg/lto/pr69866_1.c new file mode 100644 index 00000000000..3a14f850eef --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr69866_1.c @@ -0,0 +1,6 @@ +/* { dg-options { -fno-lto } } */ + +int weaks(int i) +{ + return i+1; +} |