From: Jan Hubicka Date: Thu, 15 Jun 2017 18:42:10 +0000 (+0000) Subject: re PR lto/69866 (lto1: internal compiler error: in add_symbol_to_partition_1, at... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d1eed638ed170a22a3feb9515b82b125fd203727;p=gcc.git re PR lto/69866 (lto1: internal compiler error: in add_symbol_to_partition_1, at lto/lto-partition.c:158) 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. From-SVN: r249224 --- 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 + Thomas Preud'homme + + PR lto/69866 + * lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions + that resolved externally. + 2017-05-23 Jan Hubicka * 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 (node)) != NULL) + cnode->reset (); + else + { + node->analyzed = node->definition = false; + node->remove_all_references (); + } + } + } if (!(cnode = dyn_cast (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 + + PR lto/69866 + * gcc.dg/lto/pr69866_0.c: New test. + * gcc.dg/lto/pr69866_1.c: Likewise. + 2017-06-15 Jozef Lawrynowicz 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; +}