This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, mips] Fix compiler abort with -mips32r2 -mips16 -msynci
- From: "Steve Ellcey " <sellcey at mips dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 17 Jul 2012 14:05:19 -0700
- Subject: [Patch, mips] Fix compiler abort with -mips32r2 -mips16 -msynci
While working on my favorite mips option (-msynci) I noticed an odd thing.
If I compile with '-mips32 -mips16 -msynci' I got a warning about synci not
being supported but if I compiled with '-mips32r2 -mips16 -msynci' I did not
get a warning, even though -mips16 mode does not support synci. Furthermore
if I compiled a program that called __builtin___clear_cache with '-mips32r2
-mips16 -msynci', the compiler would abort.
In mips.h we have:
/* ISA includes synci, jr.hb and jalr.hb. */
#define ISA_HAS_SYNCI ((ISA_MIPS32R2 \
|| ISA_MIPS64R2) \
&& !TARGET_MIPS16)
What I found was that in mips_option_override, where we check this macro
to generate the warning we have this code at the front of the function:
/* Process flags as though we were generating non-MIPS16 code. */
mips_base_mips16 = TARGET_MIPS16;
target_flags &= ~MASK_MIPS16;
Then later, we check ISA_HAS_SYNCI, but at that point TARGET_MIPS16 is
always false because of the above lines.
I looked at changing ISA_HAS_SYNCI to use target_flag_explicit but that
seems like the wrong thing to do for the use of ISA_HAS_SYNCI in mips.md.
Then I modified the if statement in mips_option_override but that resulted
in the use of 'mips32r2 -mips16 -msynci' giving an odd warning message:
warning: the âmips32r2â architecture does not support the synci instruction
But of course mips32r2 does support synci, it is -mips16 that does not. So I
added a new if statement with an explicit check against mips_base_mips16 to
give a better warning.
OK to checkin?
Steve Ellcey
sellcey@mips.com
2012-07-17 Steve Ellcey <sellcey@mips.com>
* config/mips/mips.c (mips_option_override): Fix check for -mips16
-msynci combination of flags.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 7356ce5..889cfb5 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -16212,6 +16212,14 @@ mips_option_override (void)
target_flags &= ~MASK_SYNCI;
}
+ /* ISA_HAS_SYNCI checks TARGET_MIPS16 but that was turned off at the
+ beginning of this function so we need to check mips_base_mips16. */
+ if (TARGET_SYNCI && mips_base_mips16)
+ {
+ warning (0, "the \'mips16\' ASE does not support the synci instruction");
+ target_flags &= ~MASK_SYNCI;
+ }
+
/* Only optimize PIC indirect calls if they are actually required. */
if (!TARGET_USE_GOT || !TARGET_EXPLICIT_RELOCS)
target_flags &= ~MASK_RELAX_PIC_CALLS;