This is the mail archive of the 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
>Originator:     Steve Woodford
>Release:        gcc-2.95.3
(Any m68k platform will be affected)
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:
for a very simple test case.
The following patch to gcc-2.95.3's gcc/config/m68k/m68k.c
fixes things.

--- m68k.c      2000/07/26 00:18:31
+++ 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",

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