From 9cd5de436cfca51095d63b3a3017df44c95baba6 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Thu, 4 Jun 2015 14:40:33 +0200
Subject: [PATCH] Fix PR lto/66394.
gcc/ChangeLog:
2015-06-10 Martin Liska <mliska@suse.cz>
PR lto/66394
* lto-cgraph.c (compute_ltrans_boundary): Do not stream
DECL_ABSTRACT_ORIGIN of a varpool node if it is not present
in symbol table.
gcc/testsuite/ChangeLog:
2015-06-10 Martin Liska <mliska@suse.cz>
* g++.dg/ipa/pr66394.C: New test.
---
gcc/lto-cgraph.c | 4 +++-
gcc/testsuite/g++.dg/ipa/pr66394.C | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/ipa/pr66394.C
@@ -932,7 +932,9 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
{
varpool_node *origin_node
= varpool_node::get (DECL_ABSTRACT_ORIGIN (vnode->decl));
- lto_set_symtab_encoder_in_partition (encoder, origin_node);
+
+ if (origin_node)
+ lto_set_symtab_encoder_in_partition (encoder, origin_node);
}
}
/* Pickle in also the initializer of all referenced readonly variables
new file mode 100644
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-fmerge-all-constants -flto -fpermissive -std=c++11" } */
+
+template <typename Cvt> void CvtColorLoop(int, int, const Cvt);
+enum { R2Y, G2Y, B2Y };
+struct RGB2Gray {
+ RGB2Gray(int, int, const int *coeffs) {
+ const int coeffs0[]{G2Y, B2Y};
+ coeffs = coeffs0;
+ tab[2] = *coeffs;
+ }
+ int tab[];
+};
+
+void
+cvtColor_bidx() {
+ int src, dst;
+ const int *a = &src;
+ RGB2Gray(0, dst, a);
+ CvtColorLoop(src, dst, 0);
+}
+
--
2.1.4