From 5560d026a64962d45a9f17b3a2928e1f0922a0f5 Mon Sep 17 00:00:00 2001 From: Chung-Lin Tang Date: Thu, 15 Sep 2016 09:46:36 +0000 Subject: [PATCH] re PR fortran/72743 (ICE in get_constraint_for_ssa_var, at tree-ssa-structalias.c:2958) 2016-09-15 Chung-Lin Tang PR fortran/72743 * ipa-icf.c (set_alias_uids): New function. (sem_variable::merge): Use set_alias_uids to set DECL_PT_UID of all the merged variable's referring aliases. testsuite/ * gfortran.dg/goacc/pr72743.f90: New test. From-SVN: r240155 --- gcc/ChangeLog | 7 +++++++ gcc/ipa-icf.c | 22 ++++++++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/goacc/pr72743.f90 | 15 ++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/pr72743.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c74a2caec2..22c5ffdd628 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-09-15 Chung-Lin Tang + + PR fortran/72743 + * ipa-icf.c (set_alias_uids): New function. + (sem_variable::merge): Use set_alias_uids to set DECL_PT_UID of + all the merged variable's referring aliases. + 2016-09-15 Richard Biener PR tree-optimization/77514 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index f29d929cf67..798d833971e 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -2133,6 +2133,23 @@ sem_variable::get_hash (void) return m_hash; } +/* Set all points-to UIDs of aliases pointing to node N as UID. */ + +static void +set_alias_uids (symtab_node *n, int uid) +{ + ipa_ref *ref; + FOR_EACH_ALIAS (n, ref) + { + if (dump_file) + fprintf (dump_file, " Setting points-to UID of [%s] as %d\n", + xstrdup_for_dump (ref->referring->asm_name ()), uid); + + SET_DECL_PT_UID (ref->referring->decl, uid); + set_alias_uids (ref->referring, uid); + } +} + /* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can be applied. */ @@ -2258,12 +2275,11 @@ sem_variable::merge (sem_item *alias_item) varpool_node::create_alias (alias_var->decl, decl); alias->resolve_alias (original); - if (DECL_PT_UID_SET_P (original->decl)) - SET_DECL_PT_UID (alias->decl, DECL_PT_UID (original->decl)); if (dump_file) - fprintf (dump_file, "Unified; Variable alias has been created.\n\n"); + fprintf (dump_file, "Unified; Variable alias has been created.\n"); + set_alias_uids (original, DECL_UID (original->decl)); return true; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 906cefbbee7..95ac8706873 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-09-15 Chung-Lin Tang + + PR fortran/72743 + * gfortran.dg/goacc/pr72743.f90: New test. + 2016-09-15 Richard Biener * gcc.dg/fold-reassoc-2.c: Fix dump scan. diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72743.f90 b/gcc/testsuite/gfortran.dg/goacc/pr72743.f90 new file mode 100644 index 00000000000..a29714bd43c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr72743.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-additional-options "-O2" } + +program p + integer, parameter :: n = 8 + integer :: i, z(n) + z = [(i, i=1,n)] + print *, z +end +subroutine s + integer, parameter :: n = 8 + integer :: i, z(n) + z = [(i, i=1,n)] + print *, z +end -- 2.30.2