public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/43732]  New: -ffixed-reg and register globals broken for MIPS
@ 2010-04-12 16:43 lance604 at gmail dot com
  2010-04-12 18:18 ` [Bug c/43732] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: lance604 at gmail dot com @ 2010-04-12 16:43 UTC (permalink / raw)
  To: gcc-bugs

With gcc 4.4.3 and 4.3.4 and MIPS target, code is incorrectly generated to
save/restore registers specified as "fixed" via the "-ffixed-reg" command-line
option to gcc. This also applies to register globals (which should be treated
as "fixed".)

Test code (test.c):

    register int foo asm ("$23");

    void test(void)
    {
          foo = 0;
    }

Compiler invocation:

    mips-unknown-linux-gnu-gcc -ffixed-s7 -O2 -c test.c

Disassembly of above code build with gcc 4.2.2 (correct):

    4.2.2/test.o:     file format elf32-tradbigmips

    Disassembly of section .text:

    00000000 <test>:
       0:   03e00008        jr      ra
       4:   0000b821        move    s7,zero
            ...

Disassembly with gcc 4.4.3 (incorrectly saves/restores s7, optimizes away
assignment to register global):
    4.4.3/test.o:     file format elf32-tradbigmips

    Disassembly of section .text:

    00000000 <test>:
       0:   27bdfff8        addiu   sp,sp,-8
       4:   afb70004        sw      s7,4(sp)
       8:   8fb70004        lw      s7,4(sp)
       c:   03e00008        jr      ra
      10:   27bd0008        addiu   sp,sp,8
            ...

Patch that appears to fix this issue:
diff -Naur gcc-4.4.3.base/gcc/config/mips/mips.c
gcc-4.4.3/gcc/config/mips/mips.c
--- gcc-4.4.3.base/gcc/config/mips/mips.c       2010-04-09 14:10:00.235609702
-0400
+++ gcc-4.4.3/gcc/config/mips/mips.c    2010-04-09 14:12:28.520998582 -0400
@@ -8495,7 +8495,7 @@
      property here.  */
   return (regno == GLOBAL_POINTER_REGNUM
          ? TARGET_CALL_SAVED_GP
-         : !call_really_used_regs[regno]);
+         : !call_really_used_regs[regno] && !fixed_regs[regno]);
 }

 /* Return true if the function body might clobber register REGNO.


Disassembled output with above patch applied:
    4.4.3fix/test.o:     file format elf32-tradbigmips

    Disassembly of section .text:

    00000000 <test>:
       0:   03e00008        jr      ra
       4:   0000b821        move    s7,zero
            ...


-- 
           Summary: -ffixed-reg and register globals broken for MIPS
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lance604 at gmail dot com
 GCC build triplet: x86_64-build_pc-linux-gnu
  GCC host triplet: x86_64-build_pc-linux-gnu
GCC target triplet: mips-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43732


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/43732] -ffixed-reg and register globals broken for MIPS
  2010-04-12 16:43 [Bug c/43732] New: -ffixed-reg and register globals broken for MIPS lance604 at gmail dot com
@ 2010-04-12 18:18 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-12 18:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2010-04-12 18:18 -------


*** This bug has been marked as a duplicate of 43700 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43732


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-12 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-12 16:43 [Bug c/43732] New: -ffixed-reg and register globals broken for MIPS lance604 at gmail dot com
2010-04-12 18:18 ` [Bug c/43732] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).