===================================================================
@@ -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);