Control: forcemerge -1 872438

Hi,

Just a brief update on this bug. Unfortunately there is still no "good" fix.

As I have written in a few places now, the bug occurs on mips64el where
a "small" variable gets spilled to the stack. It is possible that GCC
writes the variable to the stack using a small instruction (like sw for
a 32-bit store) and then reloads it as a 64-bit integer (using ld). This
means that the upper bits of the loaded value will contain garbage
causing chaos later when the value is used.

The bug is almost certainly in the LRA part of the compiler which
handles spilling values to the stack. One possible temporary workaround
(originally suggested by Adrian Bunk) would be to disable LRA on
mips64el. I have tested the attached patch which does seem to work. The
disadvantage of this is that non-LRA hasn't really been tested on MIPS
for ages so it might introduce some other bugs. Given the scale of this
issue it might be worth it?

This bug is very closely related to an earlier GCC bootstrap failure on
mips64el: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78660
In comment 17 Matthew sent a patch and applying it also fixes this bug.
However, he tells me it has some other issues and isn't suitable to be
applied (which is presumably why it was reverted).

James
commit 21398b7c319ed013741a9b249cb2315a098b6753
Author: James Cowgill <james...@cowgill.org.uk>
Date:   Tue Aug 22 11:33:47 2017 +0100

    Disable LRA on mips as a workaround

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 563f74b74f0..c89067cf89c 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -19738,7 +19738,7 @@ mips_option_override (void)
   else if (ISA_MIPS1 && !TARGET_FLOAT32)
     error ("%<-march=%s%> requires %<-mfp32%>", mips_arch_info->name);
   else if (TARGET_FLOATXX && !mips_lra_flag)
-    error ("%<-mfpxx%> requires %<-mlra%>");
+    mips_lra_flag = 1;
 
   /* End of code shared with GAS.  */
 
diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt
index ced243218e3..cf7795c63e4 100644
--- a/gcc/config/mips/mips.opt
+++ b/gcc/config/mips/mips.opt
@@ -385,7 +385,7 @@ Target Report Mask(SYNCI)
 Use synci instruction to invalidate i-cache.
 
 mlra
-Target Report Var(mips_lra_flag) Init(1) Save
+Target Report Var(mips_lra_flag) Init(0) Save
 Use LRA instead of reload.
 
 mlxc1-sxc1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to