diff --git a/external/gpl3/gcc/dist/gcc/config/mips/mips.c b/external/gpl3/gcc/dist/gcc/config/mips/mips.c index fd9e4b39c59a..22092825e139 100644 --- a/external/gpl3/gcc/dist/gcc/config/mips/mips.c +++ b/external/gpl3/gcc/dist/gcc/config/mips/mips.c @@ -6522,6 +6522,15 @@ mips_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED) && const_call_insn_operand (XEXP (DECL_RTL (decl), 0), VOIDmode)) return false; + /* Sibling calls should not prevent lazy binding. Lazy-binding stubs + require $gp to be valid on entry, so sibcalls can only use stubs + if $gp is call-clobbered. */ + if (decl + && TARGET_CALL_SAVED_GP + && !TARGET_ABICALLS_PIC0 + && !targetm.binds_local_p (decl)) + return false; + /* Otherwise OK. */ return true; }