re PR tree-optimization/56310 (ICE: in decide_about_value, at ipa-cp.c:3310 with...
authorMartin Jambor <mjambor@suse.cz>
Thu, 21 Feb 2013 16:08:51 +0000 (17:08 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 21 Feb 2013 16:08:51 +0000 (17:08 +0100)
2013-02-21  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/56310
* ipa-cp.c (agg_replacements_to_vector): New parameter index, copy
only matching indices and non-negative final offsets.
(intersect_aggregates_with_edge): Pass src_idx to
agg_replacements_to_vector.  Pass src_idx insstead of index to
intersect_with_agg_replacements.

testsuite/
* g++.dg/ipa/pr56310.C: New test.

From-SVN: r196207

gcc/ChangeLog
gcc/ipa-cp.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/pr56310.C [new file with mode: 0644]

index a688247..27e8428 100644 (file)
@@ -1,5 +1,14 @@
 2013-02-21  Martin Jambor  <mjambor@suse.cz>
 
+       PR tree-optimization/56310
+       * ipa-cp.c (agg_replacements_to_vector): New parameter index, copy
+       only matching indices and non-negative final offsets.
+       (intersect_aggregates_with_edge): Pass src_idx to
+       agg_replacements_to_vector.  Pass src_idx insstead of index to
+       intersect_with_agg_replacements.
+
+2013-02-21  Martin Jambor  <mjambor@suse.cz>
+
        * ipa-cp.c (good_cloning_opportunity_p): Dump the real threshold
        instead of hard-wired defaults.
 
index 45c1093..9a67f3c 100644 (file)
@@ -2807,12 +2807,15 @@ intersect_with_plats (struct ipcp_param_lattices *plats,
    vector result while subtracting OFFSET from the individual value offsets.  */
 
 static vec<ipa_agg_jf_item_t>
-agg_replacements_to_vector (struct cgraph_node *node, HOST_WIDE_INT offset)
+agg_replacements_to_vector (struct cgraph_node *node, int index,
+                           HOST_WIDE_INT offset)
 {
   struct ipa_agg_replacement_value *av;
   vec<ipa_agg_jf_item_t> res = vNULL;
 
   for (av = ipa_get_agg_replacements_for_node (node); av; av = av->next)
+    if (av->index == index
+       && (av->offset - offset) >= 0)
     {
       struct ipa_agg_jf_item item;
       gcc_checking_assert (av->value);
@@ -2892,7 +2895,7 @@ intersect_aggregates_with_edge (struct cgraph_edge *cs, int index,
          if (agg_pass_through_permissible_p (orig_plats, jfunc))
            {
              if (!inter.exists ())
-               inter = agg_replacements_to_vector (cs->caller, 0);
+               inter = agg_replacements_to_vector (cs->caller, src_idx, 0);
              else
                intersect_with_agg_replacements (cs->caller, src_idx,
                                                 &inter, 0);
@@ -2925,9 +2928,9 @@ intersect_aggregates_with_edge (struct cgraph_edge *cs, int index,
       if (caller_info->ipcp_orig_node)
        {
          if (!inter.exists ())
-           inter = agg_replacements_to_vector (cs->caller, delta);
+           inter = agg_replacements_to_vector (cs->caller, src_idx, delta);
          else
-           intersect_with_agg_replacements (cs->caller, index, &inter,
+           intersect_with_agg_replacements (cs->caller, src_idx, &inter,
                                             delta);
        }
       else
index 90df864..8f0ec27 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-21  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/56310
+       * g++.dg/ipa/pr56310.C: New test.
+
 2013-02-21  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/56385
diff --git a/gcc/testsuite/g++.dg/ipa/pr56310.C b/gcc/testsuite/g++.dg/ipa/pr56310.C
new file mode 100644 (file)
index 0000000..af6979c
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fipa-cp -std=gnu++0x -fno-early-inlining -fipa-cp-clone --param=ipa-cp-eval-threshold=1" } */
+
+void bar (void *, void *);
+
+struct C
+{
+  constexpr C ():p (0)
+  {
+  }
+  void *get ()
+  {
+    return p;
+  }
+  void *p;
+};
+
+struct B:C
+{
+};
+
+struct A
+{
+  void f (B * x, B * y)
+  {
+    bar (x->get (), y->get ());
+  }
+};
+
+void
+foo ()
+{
+  A a;
+  B b;
+  a.f (&b, &b);
+}