I guess I should mention why I fixed it. I am implementing some calling convention stuff on RISC-V, and that fndecl will be passed into TARGET_FUNCTION_VALUE. However, we need fndecl to determine which calling convention is being used.
Of course, I could add a check to filter out cases when fn_decl_or_type is NULL, but I found that it can actually be obtained correctly, and this is the place to fix it. On Thu, Aug 14, 2025 at 5:30 PM Kito Cheng <kito.ch...@sifive.com> wrote: > > Call with funciton pointer might not able to get the fndecl, but fntype > so use gimple_call_fntype instead of gimple_call_fndecl. > > aggregate_value_p can handle fndecl and fntype right (and even CALL_EXPR), so > I > think this change is safe. > > gcc/ChangeLog: > > * tree-nrv.cc (pass_return_slot::execute): Use > gimple_call_fntype instead of gimple_call_fndecl. > --- > gcc/tree-nrv.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/tree-nrv.cc b/gcc/tree-nrv.cc > index 3be97afb319..9b514b7e70b 100644 > --- a/gcc/tree-nrv.cc > +++ b/gcc/tree-nrv.cc > @@ -385,7 +385,7 @@ pass_return_slot::execute (function *fun) > undesirable warnings with some backends. */ > && !gimple_call_internal_p (stmt) > && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)), > - gimple_call_fndecl (stmt))) > + gimple_call_fntype (stmt))) > { > /* Check if the location being assigned to is > clobbered by the call. */ > -- > 2.34.1 >