diff mbox

Fix PR lto/66394

Message ID 557804F4.9040601@suse.cz
State New
Headers show

Commit Message

Martin Liška June 10, 2015, 9:35 a.m. UTC
Hello.

This patch fixes $SUBJECT, can bootstrap and survive regression tests on x86_64-linux-unknown-pc.

Ready for trunk?
If so, I'm going to prepare backportable patches for 4.9 and 5.0 branches.

Thanks,
Martin
diff mbox

Patch

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

diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 42db4d8..6849f7e 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.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
diff --git a/gcc/testsuite/g++.dg/ipa/pr66394.C b/gcc/testsuite/g++.dg/ipa/pr66394.C
new file mode 100644
index 0000000..a4ceb2e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr66394.C
@@ -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