From 27814aed3462d6bdce3c653e5e66d5e58cf4a5e7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 14 Mar 2019 14:05:34 +0100 Subject: [PATCH] re PR ipa/89684 (ICE in gsi_for_stmt, at gimple-iterator.c:613) PR ipa/89684 * multiple_target.c (create_dispatcher_calls): Change references_to_redirect from vector of ipa_ref * to vector of ipa_ref. In the node->iterate_referring loop, push *ref rather than ref, call ref->remove_reference () and always pass 0 to iterate_referring. * gcc.target/i386/pr89684.c: New test. From-SVN: r269681 --- gcc/ChangeLog | 6 ++++++ gcc/multiple_target.c | 14 +++++++++----- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.target/i386/pr89684.c | 23 +++++++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr89684.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fb9a555b59a..a4015751479 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2019-03-14 Jakub Jelinek + PR ipa/89684 + * multiple_target.c (create_dispatcher_calls): Change + references_to_redirect from vector of ipa_ref * to vector of ipa_ref. + In the node->iterate_referring loop, push *ref rather than ref, call + ref->remove_reference () and always pass 0 to iterate_referring. + PR rtl-optimization/89679 * expmed.c (expand_mult_const): Don't add a REG_EQUAL note if it would contain a paradoxical SUBREG. diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c index 6126f42d7bf..fd983cc4ad9 100644 --- a/gcc/multiple_target.c +++ b/gcc/multiple_target.c @@ -103,10 +103,16 @@ create_dispatcher_calls (struct cgraph_node *node) inode->resolve_alias (cgraph_node::get (resolver_decl)); auto_vec edges_to_redirect; - auto_vec references_to_redirect; + /* We need to capture the references by value rather than just pointers to them + and remove them right away, as removing them later would invalidate what + some other reference pointers point to. */ + auto_vec references_to_redirect; - for (unsigned i = 0; node->iterate_referring (i, ref); i++) - references_to_redirect.safe_push (ref); + while (node->iterate_referring (0, ref)) + { + references_to_redirect.safe_push (*ref); + ref->remove_reference (); + } /* We need to remember NEXT_CALLER as it could be modified in the loop. */ for (cgraph_edge *e = node->callers; e ; e = e->next_caller) @@ -146,13 +152,11 @@ create_dispatcher_calls (struct cgraph_node *node) } symtab_node *source = ref->referring; - ref->remove_reference (); source->create_reference (inode, IPA_REF_ADDR); } else if (ref->use == IPA_REF_ALIAS) { symtab_node *source = ref->referring; - ref->remove_reference (); source->create_reference (inode, IPA_REF_ALIAS); source->add_to_same_comdat_group (inode); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19c319e0691..a9c52a90b13 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-03-14 Jakub Jelinek + PR ipa/89684 + * gcc.target/i386/pr89684.c: New test. + PR rtl-optimization/89679 * gcc.dg/pr89679.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr89684.c b/gcc/testsuite/gcc.target/i386/pr89684.c new file mode 100644 index 00000000000..85801bfc25f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr89684.c @@ -0,0 +1,23 @@ +/* PR ipa/89684 */ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ + +void bar (int, void (*) (void)); + +__attribute__((target_clones ("default", "avx"))) +void foo (void) +{ + bar (0, foo); + bar (0, foo); +} + +__attribute__((target_clones ("default", "avx", "avx2"))) +void baz (void) +{ + bar (0, foo); + bar (0, foo); + bar (0, foo); + bar (0, foo); + bar (0, foo); + bar (0, foo); +} -- 2.30.2