1 --- gcc/gcc/config/sh/sh.c
2 +++ gcc/gcc/config/sh/sh.c
3 @@ -9106,6 +9106,15 @@ sh_output_mi_thunk (FILE *file, tree thu
5 this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
7 + /* In PIC case, we set PIC register to compute the target address. We
8 + can use a scratch register to save and restore the original value
9 + except for SHcompact. For SHcompact, use stack. */
10 + if (flag_pic && TARGET_SHCOMPACT)
12 + push (PIC_OFFSET_TABLE_REGNUM);
13 + emit_insn (gen_GOTaddr2picreg ());
16 /* For SHcompact, we only have r0 for a scratch register: r1 is the
17 static chain pointer (even if you can't have nested virtual functions
18 right now, someone might implement them sometime), and the rest of the
19 @@ -9188,8 +9197,24 @@ sh_output_mi_thunk (FILE *file, tree thu
20 assemble_external (function);
21 TREE_USED (function) = 1;
23 + /* We can use scratch1 to save and restore the original value of
24 + PIC register except for SHcompact. */
25 + if (flag_pic && ! TARGET_SHCOMPACT)
27 + emit_move_insn (scratch1,
28 + gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
29 + emit_insn (gen_GOTaddr2picreg ());
31 funexp = XEXP (DECL_RTL (function), 0);
32 emit_move_insn (scratch2, funexp);
35 + if (! TARGET_SHCOMPACT)
36 + emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
39 + pop (PIC_OFFSET_TABLE_REGNUM);
41 funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
42 sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
43 SIBLING_CALL_P (sibcall) = 1;