patches/gcc/3.4.6/710-all_sh-pr16665-fix.patch
changeset 402 197e1b49586e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gcc/3.4.6/710-all_sh-pr16665-fix.patch	Sun Sep 23 17:08:09 2007 +0000
     1.3 @@ -0,0 +1,44 @@
     1.4 +diff -durN gcc-3.4.6.orig/gcc/config/sh/sh.c gcc-3.4.6/gcc/config/sh/sh.c
     1.5 +--- gcc-3.4.6.orig/gcc/config/sh/sh.c	2004-09-03 08:51:30.000000000 +0200
     1.6 ++++ gcc-3.4.6/gcc/config/sh/sh.c	2007-08-15 23:01:48.000000000 +0200
     1.7 +@@ -9107,6 +9107,15 @@
     1.8 +     }
     1.9 +   this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
    1.10 + 
    1.11 ++  /* In PIC case, we set PIC register to compute the target address.  We
    1.12 ++     can use a scratch register to save and restore the original value  
    1.13 ++     except for SHcompact.  For SHcompact, use stack.  */
    1.14 ++  if (flag_pic && TARGET_SHCOMPACT)
    1.15 ++    {
    1.16 ++      push (PIC_OFFSET_TABLE_REGNUM);
    1.17 ++      emit_insn (gen_GOTaddr2picreg ());
    1.18 ++    }
    1.19 ++
    1.20 +   /* For SHcompact, we only have r0 for a scratch register: r1 is the
    1.21 +      static chain pointer (even if you can't have nested virtual functions
    1.22 +      right now, someone might implement them sometime), and the rest of the
    1.23 +@@ -9189,8 +9198,24 @@
    1.24 +       assemble_external (function);
    1.25 +       TREE_USED (function) = 1;
    1.26 +     }
    1.27 ++  /* We can use scratch1 to save and restore the original value of
    1.28 ++     PIC register except for SHcompact.  */
    1.29 ++  if (flag_pic && ! TARGET_SHCOMPACT)
    1.30 ++    {
    1.31 ++      emit_move_insn (scratch1,
    1.32 ++		      gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
    1.33 ++      emit_insn (gen_GOTaddr2picreg ());
    1.34 ++    }
    1.35 +   funexp = XEXP (DECL_RTL (function), 0);
    1.36 +   emit_move_insn (scratch2, funexp);
    1.37 ++  if (flag_pic)
    1.38 ++    {
    1.39 ++      if (! TARGET_SHCOMPACT)
    1.40 ++	emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
    1.41 ++			scratch1);
    1.42 ++      else
    1.43 ++	pop (PIC_OFFSET_TABLE_REGNUM);
    1.44 ++    }
    1.45 +   funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
    1.46 +   sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
    1.47 +   SIBLING_CALL_P (sibcall) = 1;