diff mbox

[MIPS},[Committed] Fix gcc.dg/pch.exp failures for microMIPS multilibs

Message ID fc2b48283a244b06885687905d1f302f@SVR-ORW-MBX-04.mgc.mentorg.com
State New
Headers show

Commit Message

Moore, Catherine Oct. 14, 2016, 2:23 p.m. UTC
I've committed this patch to fix failures in  g++.dg/pch.exp and gcc.dg/pch.exp tests when compiling with -mmicromips.  Invalid data was being read from the precompiled-header causing a segfault while trying to switch compression context.
This patch fixes that segfault by initializing micromips_globals to zero prior to writing the PCH file.  

Thanks,
Catherine

2016-10-13  Catherine Moore  <clm@codesourcery.com>

	* gcc/config/mips/mips.c (mips_prepare_pch_save): Initialize
	micromips_globals to zero.
diff mbox

Patch

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 43174b4..ebec68e 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -20856,28 +20856,30 @@  mips_shift_truncation_mask (machine_mode mode)
 static void
 mips_prepare_pch_save (void)
 {
-  /* We are called in a context where the current MIPS16 vs. non-MIPS16
-     setting should be irrelevant.  The question then is: which setting
-     makes most sense at load time?
+  /* We are called in a context where the current compression vs.
+     non-compression setting should be irrelevant.  The question then is:
+     which setting makes most sense at load time?

-     The PCH is loaded before the first token is read.  We should never
-     have switched into MIPS16 mode by that point, and thus should not
-     have populated mips16_globals.  Nor can we load the entire contents
-     of mips16_globals from the PCH file, because mips16_globals contains
-     a combination of GGC and non-GGC data.
+     The PCH is loaded before the first token is read.  We should never have
+     switched into a compression mode by that point, and thus should not have
+     populated mips16_globals or micromips_globals.  Nor can we load the
+     entire contents of mips16_globals or micromips_globals from the PCH file,
+     because they contain a combination of GGC and non-GGC data.

      There is therefore no point in trying save the GGC part of
-     mips16_globals to the PCH file, or to preserve MIPS16ness across
-     the PCH save and load.  The loading compiler would not have access
-     to the non-GGC parts of mips16_globals (either from the PCH file,
-     or from a copy that the loading compiler generated itself) and would
-     have to call target_reinit anyway.
-
-     It therefore seems best to switch back to non-MIPS16 mode at
-     save time, and to ensure that mips16_globals remains null after
-     a PCH load.  */
+     mips16_globals/micromips_globals to the PCH file, or to preserve a
+     compression setting across the PCH save and load.  The loading compiler
+     would not have access to the non-GGC parts of mips16_globals or
+     micromips_globals (either from the PCH file, or from a copy that the
+     loading compiler generated itself) and would have to call target_reinit
+     anyway.
+
+     It therefore seems best to switch back to non-MIPS16 mode and
+     non-microMIPS mode to save time, and to ensure that mips16_globals and
+     micromips_globals remain null after a PCH load.  */
   mips_set_compression_mode (0);
   mips16_globals = 0;
+  micromips_globals = 0;
 }
 ^L
 /* Generate or test for an insn that supports a constant permutation.  */