https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91988
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The failure is triggered by compile-time(!)
Breakpoint 6, symbol_table::create_edge (this=0x7ffff6810100,
caller=<cgraph_node * 0x7ffff680f708 "main"/3>,
callee=<cgraph_node * 0x7ffff680f870 "fun"/4>, call_stmt=0x7ffff7fefea0,
count=..., indir_unknown_callee=false)
at /space/rguenther/src/svn/gcc-9-branch/gcc/cgraph.c:884
884 edge->inline_failed = CIF_MISMATCHED_ARGUMENTS;
and also
Breakpoint 7, early_inliner (fun=0x7ffff696b210)
at /space/rguenther/src/svn/gcc-9-branch/gcc/ipa-inline.c:2841
2841 edge->inline_failed = CIF_MISMATCHED_ARGUMENTS;
we ultimatively call
types_compatible_p (type1=<record_type 0x7ffff69641f8 A>,
type2=<reference_type 0x7ffff696e000>)
from
static bool
gimple_check_call_args (gimple *stmt, tree fndecl, bool args_count_match)
{
...
if (TREE_VALUE (p) == error_mark_node
|| arg == error_mark_node
|| TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
|| (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg))
&& !fold_convertible_p (TREE_VALUE (p), arg)))
return false;
we're looking at TYPE_ARG_TYPES here because we don't have a PARM_DECL
and as we know TYPE_ARG_TYPES do _not_ reflect by-reference semantics.
But we could take TREE_ADDRESSABLE as a hint.
Index: gcc/cgraph.c
===================================================================
--- gcc/cgraph.c (revision 276396)
+++ gcc/cgraph.c (working copy)
@@ -3728,7 +3728,10 @@ gimple_check_call_args (gimple *stmt, tr
|| arg == error_mark_node
|| TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
|| (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg))
- && !fold_convertible_p (TREE_VALUE (p), arg)))
+ && !fold_convertible_p (TREE_VALUE (p), arg)
+ /* TREE_ADDRESSABLE types are passed by reference. */
+ && !(POINTER_TYPE_P (TREE_TYPE (arg))
+ && TREE_ADDRESSABLE (TREE_VALUE (p)))))
return false;
}
}
fixes that (comparing the pointed-do type is probably too strict here).