> This is the "real" fix for PR46076 that I wanted to persue.  Make
> function pointer type conversions useless as to more aggressively
> be able to turn indirect into direct calls.  This requires that we
> preserve the original type signature of the called function as
> presented by the frontend.  The patch does that by adding a fntype
> field to every call stmt in GIMPLE and extract this information
> during gimplification.

The patch is incomplete though: the type is preserved at the GIMPLE level but 
is dropped at the RTL level, so you can get call convention mismatches.  The
attached patch is needed to cure the 3 ACATS failures on x86:

FAIL:   c431001
FAIL:   c731001
FAIL:   ca11c02

I think the GIMPLE->Tree->RTL interface would need to be audited here.


        * cfgexpand.c (expand_call_stmt): Rematerialize original function type.


-- 
Eric Botcazou
Index: cfgexpand.c
===================================================================
--- cfgexpand.c	(revision 172371)
+++ cfgexpand.c	(working copy)
@@ -1844,7 +1844,10 @@ expand_call_stmt (gimple stmt)
 
   exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
 
-  CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
+  CALL_EXPR_FN (exp)
+    = fold_build1 (NOP_EXPR, build_pointer_type (gimple_call_fntype (stmt)),
+			     gimple_call_fn (stmt));
+
   decl = gimple_call_fndecl (stmt);
   builtin_p = decl && DECL_BUILT_IN (decl);
 

Reply via email to