Hi,

bug 85655 happens because intersect_with_plats encounters a BOTTOM
lattice and does not check for it.  On closer inspection, the real check
that should be performed is is_single_const, so this patch adds it.

It has passed bootstrap and testing, LTO bootstrap is underway.  OK for
trunk if it passes?  OK for gcc-7 and gcc-6 branches after testing thee
too?

Thanks,

Martin


2018-05-10  Martin Jambor  <mjam...@suse.cz>

        PR ipa/85655
        * ipa-cp.c (intersect_with_plats): Check that the lattice contains
        single const.

testsuite/
        * g++.dg/lto/pr85655_0.C: New test.
---
 gcc/ipa-cp.c                         |  4 +++-
 gcc/testsuite/g++.dg/lto/pr85655_0.C | 42 ++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/lto/pr85655_0.C

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 4f28a55b862..e868b9c2623 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -4127,7 +4127,9 @@ intersect_with_plats (struct ipcp_param_lattices *plats,
          if (aglat->offset - offset == item->offset)
            {
              gcc_checking_assert (item->value);
-             if (values_equal_for_ipcp_p (item->value, aglat->values->value))
+             if (aglat->is_single_const ()
+                 && values_equal_for_ipcp_p (item->value,
+                                             aglat->values->value))
                found = true;
              break;
            }
diff --git a/gcc/testsuite/g++.dg/lto/pr85655_0.C 
b/gcc/testsuite/g++.dg/lto/pr85655_0.C
new file mode 100644
index 00000000000..d3bbd8f4036
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr85655_0.C
@@ -0,0 +1,42 @@
+// { dg-lto-do link }
+// { dg-require-effective-target shared }
+// { dg-require-effective-target fpic }
+// { dg-lto-options {{-O2 -fPIC -shared -flto}} }
+
+int a;
+void b(...);
+void c(int);
+enum { d, e, f, g, h, i, j, k };
+class l {
+public:
+  int ac;
+  bool m;
+  l(char *);
+  int n();
+};
+struct o {
+  int ad;
+  o(int p = 0) : ad(p) {}
+};
+class C : public l {
+public:
+  char q;
+  C(o) : l(&q) { m |= ac & a ?: 9; }
+};
+class r : C {
+public:
+  char s;
+  r(o p, char) : C(p) {
+    if (n()) {
+      b(a, s, "");
+      c(5);
+    }
+  }
+};
+class t : C {
+public:
+  t(int) : C(d) {}
+};
+r ag('b', 0), ah(o(), 0), ai(e, 0), aj(f, 0), ak(g, 0), al(h, 0), am(k, 0),
+    an(i, 0), ao(j, 0);
+t ap(0);
-- 
2.16.3

Reply via email to