diff mbox

[pph] Fix ICE in build_int_cst_wide (issue5536086)

Message ID 20120121003025.516D8AE038@tobiano.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo Jan. 21, 2012, 12:30 a.m. UTC
This patch fixes an ICE in build_int_cst_wide.  We were not writing
out TYPE_MODE for types, causing RTL generation to try to emit an
offset using VOIDmode.

This is not the only problem in this test case.  We are also failing
to mark something needed, because with PPH enabled, a whole function
is optimized out.  I'm not quite sure why yet.  I will fix this in a
subsequent patch.


2012-01-20   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
	* pph-in.c (pph_in_machine_mode): New.
	(pph_in_tcc_type): Call it.
	* pph-out.c (pph_out_machine_mode): New.
	(pph_out_tcc_type): Call it.

testsuite/ChangeLog.pph
	* g++.dg/pph/x1namespace-alias2.cc: Remove expected ICE.
	Document assembly difference.


--
This patch is available for review at http://codereview.appspot.com/5536086
diff mbox

Patch

diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index 0b2529f..5ee6458 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -1848,6 +1848,16 @@  pph_in_lang_type (pph_stream *stream)
 }
 
 
+/* Read from STREAM an enum machine_mode value.  */
+
+static enum machine_mode
+pph_in_machine_mode (pph_stream *stream)
+{
+  struct lto_input_block *ib = stream->encoder.r.ib;
+  return streamer_read_enum (ib, machine_mode, NUM_MACHINE_MODES);
+}
+
+
 /* Read from STREAM the body of tcc_type node TYPE.  */
 
 static void
@@ -1857,6 +1867,7 @@  pph_in_tcc_type (pph_stream *stream, tree type)
   TYPE_POINTER_TO (type) = pph_in_tree (stream);
   TYPE_REFERENCE_TO (type) = pph_in_tree (stream);
   TYPE_NEXT_VARIANT (type) = pph_in_tree (stream);
+  SET_TYPE_MODE (type, pph_in_machine_mode (stream));
   /* FIXME pph - Streaming TYPE_CANONICAL generates many type comparison
      failures.  Why?  */
   /* FIXME pph: apparently redundant.  */
diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c
index 6e8eafd..1c055d9 100644
--- a/gcc/cp/pph-out.c
+++ b/gcc/cp/pph-out.c
@@ -1828,6 +1828,15 @@  pph_out_lang_type (pph_stream *stream, tree type)
     pph_out_lang_type_ptrmem (stream, &lt->u.ptrmem);
 }
 
+/* Write machine_mode value MODE to STREAM.  */
+
+static void
+pph_out_machine_mode (pph_stream *stream, enum machine_mode mode)
+{
+  struct output_block *ob = stream->encoder.w.ob;
+  streamer_write_enum (ob->main_stream, machine_mode, NUM_MACHINE_MODES, mode);
+}
+
 
 /* Write to STREAM the body of tcc_type node TYPE.  */
 
@@ -1838,6 +1847,7 @@  pph_out_tcc_type (pph_stream *stream, tree type)
   pph_out_tree (stream, TYPE_POINTER_TO (type));
   pph_out_tree (stream, TYPE_REFERENCE_TO (type));
   pph_out_tree (stream, TYPE_NEXT_VARIANT (type));
+  pph_out_machine_mode (stream, TYPE_MODE (type));
   /* FIXME pph - Streaming TYPE_CANONICAL generates many type comparison
      failures.  Why?  */
   pph_out_tree (stream, TREE_CHAIN (type));
diff --git a/gcc/testsuite/g++.dg/pph/x1namespace-alias2.cc b/gcc/testsuite/g++.dg/pph/x1namespace-alias2.cc
index 9ba4c96..4dbe174 100644
--- a/gcc/testsuite/g++.dg/pph/x1namespace-alias2.cc
+++ b/gcc/testsuite/g++.dg/pph/x1namespace-alias2.cc
@@ -1,5 +1,6 @@ 
-// { dg-xfail-if "ICE build_int_cst_wide - bad merged type" { "*-*-*" } { "-fpph-map=pph.map" } }
-// { dg-bogus "internal compiler error: in build_int_cst_wide, at tree.c" "" { xfail *-*-* } 0 }
+// pph asm xdiff 34830
+// The assembly difference is due to missing code in function f().
+// The PPH version removes the whole return expression.
 #include "x1namespace-alias1.h"
 #include "x1namespace-alias2.h"