diff mbox

[RFC] Make called function type explicit, make function pointer type conversions useless

Message ID 201104141151.28243.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou April 14, 2011, 9:51 a.m. UTC
> 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.

Comments

Richard Biener April 14, 2011, 10:15 a.m. UTC | #1
On Thu, 14 Apr 2011, Eric Botcazou wrote:

> > 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.

Bah, and I grepped for all gimple_call_fn\ ( occurances specifically
looking for this one, didn't find it and wondered about it ...
I should have looked closer.  This should btw be the only place that
needs adjustments.

The patch is ok, obviously.

Thanks,
Richard.
Richard Biener April 14, 2011, 1:40 p.m. UTC | #2
On Thu, 14 Apr 2011, Eric Botcazou wrote:

> > 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.

I'm working on a fix along this line, it needs some tweaks elsewhere.

Richard.
diff mbox

Patch

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