patches/gcc/3.4.4/71_all_sh-pr16665-fix.patch
changeset 1 eeea35fbf182
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gcc/3.4.4/71_all_sh-pr16665-fix.patch	Sat Feb 24 11:00:05 2007 +0000
     1.3 @@ -0,0 +1,43 @@
     1.4 +--- gcc/gcc/config/sh/sh.c
     1.5 ++++ gcc/gcc/config/sh/sh.c
     1.6 +@@ -9106,6 +9106,15 @@ sh_output_mi_thunk (FILE *file, tree thu
     1.7 +     }
     1.8 +   this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
     1.9 + 
    1.10 ++  /* In PIC case, we set PIC register to compute the target address.  We
    1.11 ++     can use a scratch register to save and restore the original value  
    1.12 ++     except for SHcompact.  For SHcompact, use stack.  */
    1.13 ++  if (flag_pic && TARGET_SHCOMPACT)
    1.14 ++    {
    1.15 ++      push (PIC_OFFSET_TABLE_REGNUM);
    1.16 ++      emit_insn (gen_GOTaddr2picreg ());
    1.17 ++    }
    1.18 ++
    1.19 +   /* For SHcompact, we only have r0 for a scratch register: r1 is the
    1.20 +      static chain pointer (even if you can't have nested virtual functions
    1.21 +      right now, someone might implement them sometime), and the rest of the
    1.22 +@@ -9188,8 +9197,24 @@ sh_output_mi_thunk (FILE *file, tree thu
    1.23 +       assemble_external (function);
    1.24 +       TREE_USED (function) = 1;
    1.25 +     }
    1.26 ++  /* We can use scratch1 to save and restore the original value of
    1.27 ++     PIC register except for SHcompact.  */
    1.28 ++  if (flag_pic && ! TARGET_SHCOMPACT)
    1.29 ++    {
    1.30 ++      emit_move_insn (scratch1,
    1.31 ++		      gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
    1.32 ++      emit_insn (gen_GOTaddr2picreg ());
    1.33 ++    }
    1.34 +   funexp = XEXP (DECL_RTL (function), 0);
    1.35 +   emit_move_insn (scratch2, funexp);
    1.36 ++  if (flag_pic)
    1.37 ++    {
    1.38 ++      if (! TARGET_SHCOMPACT)
    1.39 ++	emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
    1.40 ++			scratch1);
    1.41 ++      else
    1.42 ++	pop (PIC_OFFSET_TABLE_REGNUM);
    1.43 ++    }
    1.44 +   funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
    1.45 +   sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
    1.46 +   SIBLING_CALL_P (sibcall) = 1;