This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

target/5126: m68k pic optimisation bug



>Number:         5126
>Category:       target
>Synopsis:       m68k pic optimisation bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 15 12:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Steve Woodford
>Release:        gcc-2.95.3
>Organization:
>Environment:
NetBSD/mvme68k
(Any m68k platform will be affected)
>Description:
When generating PIC code for m68k, under certain circumstances,
gcc will load %a5 with the GOT address even if the reference
to global data in the function has been optimised away.

Unfortunately, in this case, %a5 is not saved in the function
prologue to non-pic callers which use %a5 will lose.

This bug has been reported before, but as far as I can tell,
there is no open PR and no apparent fix in gcc-current. See:

http://gcc.gnu.org/ml/gcc-bugs/1999-11n/msg00673.html.
>How-To-Repeat:
See http://gcc.gnu.org/ml/gcc-bugs/1999-11n/msg00673.html
for a very simple test case.
>Fix:
The following patch to gcc-2.95.3's gcc/config/m68k/m68k.c
fixes things.

--- m68k.c      2000/07/26 00:18:31     1.1.1.1
+++ m68k.c      2001/12/15 17:19:16
@@ -462,7 +462,8 @@
                                  -cfa_store_offset + n_regs++ * 4);
        }
     }
-  if (flag_pic && current_function_uses_pic_offset_table)
+  if (flag_pic && current_function_uses_pic_offset_table &&
+      regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
     {
 #ifdef MOTOROLA
       asm_fprintf (stream, "\t%Olea (%Rpc, %U_GLOBAL_OFFSET_TABLE_@GOTPC), %s\n",
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]