On Thu, 14 Apr 2011, Eric Botcazou wrote: > > I'm working on a fix along this line, it needs some tweaks elsewhere. > > Indeed, here's what I needed to bootstrap on x86-64/Linux. > > > * cfgexpand.c (expand_call_stmt): Rematerialize original function type. > * config/i386/i386.c (ix86_expand_builtin): Use get_callee_fndecl.
I have the following, the gimple_call_chain check is to prevent Ada bootstrap from failing. It would be nice to eventually expand calls from gimple and adjust calls.c to look only at the function type, not the decl ... That get_callee_fndecl strips all conversions might be a bug anyway. I suppose your patch is ok, maybe with simply not wrapping the NOP_EXPR around builtins. Richard. Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c (revision 172429) +++ gcc/cfgexpand.c (working copy) @@ -1841,11 +1841,28 @@ expand_call_stmt (gimple stmt) size_t i; bool builtin_p; tree decl; + tree fn; exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3); - CALL_EXPR_FN (exp) = gimple_call_fn (stmt); + fn = gimple_call_fn (stmt); decl = gimple_call_fndecl (stmt); + /* Restore the ABI relevant type for expansion. + ??? We should have a target hook that compares function signatures + for ABI compatibility. */ + if (TREE_TYPE (TREE_TYPE (fn)) != gimple_call_fntype (stmt) + /* ??? The static_chain target hook needs to be changed to + take a function type instead of a decl. See + calls.c:prepare_call_address. */ + && !gimple_call_chain (stmt) + /* ??? Most builtins cannot be called indirectly. */ + && (!decl || !DECL_BUILT_IN (decl))) + { + fn = build1 (NOP_EXPR, + build_pointer_type (gimple_call_fntype (stmt)), fn); + decl = NULL_TREE; + } + CALL_EXPR_FN (exp) = fn; builtin_p = decl && DECL_BUILT_IN (decl); TREE_TYPE (exp) = gimple_call_return_type (stmt);