Hi,

This patch fixes an internal compiler error when micromips/nomicromips
attributes are used.

The problem here was that the cached boolean attributes for the current
target did not agree with the uncached attributes throwing an assertion error.

It appears that saving and restoring the state for micromips was missing,
just like there is for mips16. OK to apply?

Regards,
Robert

gcc/
        * config/mips/mips.c (micromips_globals): New variable.
        (mips_set_compression_mode): Save and reinitialize target-dependent
        state for microMIPS.

gcc/testsuite
        * gcc.target/mips/umips-attr.c: New test.
---
 gcc/config/mips/mips.c                     | 10 ++++++++++
 gcc/testsuite/gcc.target/mips/umips-attr.c | 13 +++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/mips/umips-attr.c

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index bf69850..959a672 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -676,6 +676,9 @@ const char *mips_hi_relocs[NUM_SYMBOL_TYPES];
 /* Target state for MIPS16.  */
 struct target_globals *mips16_globals;
 
+/* Target state for MICROMIPS.  */
+struct target_globals *micromips_globals;
+
 /* Cached value of can_issue_more. This is cached in mips_variable_issue hook
    and returned from mips_sched_reorder2.  */
 static int cached_can_issue_more;
@@ -17182,6 +17185,13 @@ mips_set_compression_mode (unsigned int 
compression_mode)
       else
        restore_target_globals (mips16_globals);
     }
+  else if (compression_mode & MASK_MICROMIPS)
+    {
+      if (!micromips_globals)
+       micromips_globals = save_target_globals_default_opts ();
+      else
+       restore_target_globals (micromips_globals);
+    }
   else
     restore_target_globals (&default_target_globals);
 
diff --git a/gcc/testsuite/gcc.target/mips/umips-attr.c 
b/gcc/testsuite/gcc.target/mips/umips-attr.c
new file mode 100644
index 0000000..f8c4517
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/umips-attr.c
@@ -0,0 +1,13 @@
+/* { dg-options "(-mmicromips)" } */
+
+int MICROMIPS
+foo (int a)
+{
+  return a;
+}
+
+int NOMICROMIPS
+foo2 (int a)
+{
+  return a;
+}
-- 
2.2.2


Reply via email to