]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR ipa/89684
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Mar 2019 13:05:34 +0000 (13:05 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Mar 2019 13:05:34 +0000 (13:05 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269681 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/multiple_target.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr89684.c [new file with mode: 0644]

index fb9a555b59aa7dfc5ba8b54a6211c1110ef3eb0e..a4015751479c0d4d9b5c8206f60560d3913a22a6 100644 (file)
@@ -1,5 +1,11 @@
 2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
index 6126f42d7bf1294d95e06555a4e17988c290e02c..fd983cc4ad93858f179e860647119357e36a7757 100644 (file)
@@ -103,10 +103,16 @@ create_dispatcher_calls (struct cgraph_node *node)
     inode->resolve_alias (cgraph_node::get (resolver_decl));
 
   auto_vec<cgraph_edge *> edges_to_redirect;
-  auto_vec<ipa_ref *> 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<ipa_ref> 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);
            }
index 19c319e06918d6f27e16aab405cd0265d5bebab2..a9c52a90b138b4ff2c27b01a86713b90ec1560e9 100644 (file)
@@ -1,5 +1,8 @@
 2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..85801bf
--- /dev/null
@@ -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);
+}