On Tue, Apr 05, 2022 at 11:28:53AM +0200, Richard Biener wrote: > > In GIMPLE, we call: > > && gimple_builtin_call_types_compatible_p (stmt, fndecl) > > but that is insufficient, that verifies whether the arguments passed to > > GIMPLE_CALL match the fndecl argument types. But that fndecl may very well > > be the user declaration, so doesn't have to match exactly the builtin > > as predeclared by builtins.def etc. (though, there is the cotcha that say > > for FILE * we just use void * etc.). So e.g. in tree-ssa-strlen.cc > > we use additional: > > tree callee = gimple_call_fndecl (stmt); > > tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (callee)); > > if (decl > > && decl != callee > > && !gimple_builtin_call_types_compatible_p (stmt, decl)) > > return false; > > Yeah, I think we should use that (and only that) function decl > in get_call_combined_fn and gimple_call_combined_fn until the > frontend stops slapping wrong BUILT_IN_* on random decls.
So, as a preparation step, this patch adjusts gimple_call_builtin_p and gimple_call_combined_fn so that they check argument types against the builtin_decl_explicit TYPE_ARG_TYPES rather than against the actual used fndecl. Bootstrapped/regtested on powerpc64le-linux, ok for trunk? Will work on generic tree_builtin_call_types_compatible_p next. Jakub