This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Miscompilation with -fschedule-insns2 on mips-sgi-irix6.2
- To: Swen Thuemmler <swen at uni-paderborn dot de>
- Subject: Re: Miscompilation with -fschedule-insns2 on mips-sgi-irix6.2
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Thu, 04 Dec 1997 16:43:50 -0800
- cc: egcs-bugs at cygnus dot com
while compiling ncurses4.1 on mips-sgi-irix6.2 with egcs-2.90.11, I found
a strange problem: tic got a segmentation fault in a function in
libncurses, but only when it was dynamically linked to libncurses.
This is because of problems with the GP register. The caller's GP value is
being restored from the stack too soon. This will only fail when a calling
into a shared library, since otherwise the caller/callee values for the GP
register are the same.
This problem was fixed by this patch. Unfortunately, it accidentally got left
out of the egcs-1.0 sources.
Incidentally, the -fPIC option doesn't do anything for the irix6 port.
Code is always PIC.
Tue Nov 4 16:55:11 1997 Jim Wilson <wilson@cygnus.com>
* mips.c (mips_expand_epilogue): Emit blockage insn before call to
save_restore_insns if no FP and GP will be restored.
Index: mips.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/config/mips/mips.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -p -r1.6 -r1.7
*** mips.c 1997/11/02 21:18:46 1.6
--- mips.c 1997/11/05 00:55:50 1.7
*************** mips_expand_epilogue ()
*** 5591,5596 ****
--- 5591,5603 ----
else
emit_insn (gen_movsi (stack_pointer_rtx, frame_pointer_rtx));
}
+ /* The GP/PIC register is implicitly used by all SYMBOL_REFs, so if we
+ are going to restore it, then we must emit a blockage insn to
+ prevent the scheduler from moving the restore out of the epilogue. */
+ else if (TARGET_ABICALLS && mips_abi != ABI_32
+ && (current_frame_info.mask
+ & (1L << (PIC_OFFSET_TABLE_REGNUM - GP_REG_FIRST))))
+ emit_insn (gen_blockage ());
save_restore_insns (FALSE, tmp_rtx, tsize, (FILE *)0);