On Wed, Feb 04, 2015 at 12:27:35AM +1030, Alan Modra wrote:
> +static bool
> +chain_already_loaded (rtx_insn *last)
> +{
> + if (last != NULL)
> + {
> + rtx patt = PATTERN (last);
> +
> + if (GET_CODE (patt) == SET)
> + {
> + rtx lhs = XEXP (patt, 0);
> +
> + if (REG_P (lhs) && REGNO (lhs) == STATIC_CHAIN_REGNUM)
> + return true;
> + }
> + }
> + /* This function is only called when we are about to emit a call,
> + and we know that the static chain is set just before a call, so
> + there is no need to look at previous insns. */
> + return false;
> +}
> +
> /* Expand code to perform a call under the AIX or ELFv2 ABI. */
>
> void
> @@ -33002,7 +33092,9 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx fla
> originally direct, the 3rd word has not been written since no
> trampoline has been built, so we ought not to load it, lest we
> override a static chain value. */
> - if (!direct_call_p && TARGET_POINTERS_TO_NESTED_FUNCTIONS)
> + if (!direct_call_p
> + && TARGET_POINTERS_TO_NESTED_FUNCTIONS
> + && !chain_already_loaded (crtl->emit.sequence_stack->last))
Shouldn't that be !chain_already_loaded (get_last_insn_anywhere ()) ?
Jakub