Hi Richard,
On Thu, Oct 24, 2024 at 06:18:23PM +0100, Richard Sandiford wrote:
> Yury Khrustalev <[email protected]> writes:
> > From: Szabolcs Nagy <[email protected]>
> >
> > Tail calls of indirect_return functions from non-indirect_return
> > functions are disallowed even if BTI is disabled, since the call
> > site may have BTI enabled.
> >
> > Following x86, mismatching attribute on function pointers is not
> > a type error even though this can lead to bugs.
>
> Is that still true? I would have expected the aarch64_comp_type_attributes
> part of the patch to reject mismatches.
To address this, the indirect_return attribute will have affects_type_identity
set to true.
> > Needed for swapcontext within the same function when GCS is enabled.
> >
> > + /* Check if the function is marked to return indirectly. */
> > + rtx call = get_call_rtx_from (insn);
> > + rtx fnaddr = XEXP (call, 0);
> > + tree fndecl = NULL_TREE;
> > + if (GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF)
> > + fndecl = SYMBOL_REF_DECL (XEXP (fnaddr, 0));
> > + if (fndecl == NULL_TREE)
> > + fndecl = MEM_EXPR (fnaddr);
> > + if (!fndecl)
> > + return false;
> > + if (TREE_CODE (TREE_TYPE (fndecl)) != FUNCTION_TYPE
> > + && TREE_CODE (TREE_TYPE (fndecl)) != METHOD_TYPE)
> > + return false;
> > + tree fntype = TREE_TYPE (fndecl);
> > + return lookup_attribute ("indirect_return", TYPE_ATTRIBUTES (fntype));
>
> I think it would be safer/more robust to encode the indirect_return status
> in the call insn "cookie", like we do for some other ABI properties.
> The information would be recorded in CUMULATIVE_ARGS by
> aarch64_init_cumulative_args, then aarch64_function_arg would
> add it to the cookie.
I'll send new implementation based on the call instruction cookie in the next
patch series.
> Thanks,
> Richard
>
Kind regards,
Yury