This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR57330


The following makes sure to preserve the call function type when
redirecting edges.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Ok for the branch?

Thanks,
Richard.

2013-05-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/57330
	* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Properly
	preserve the call stmts fntype.

	* gcc.dg/torture/pr57330.c: New testcase.

Index: gcc/cgraph.c
===================================================================
*** gcc/cgraph.c	(revision 199137)
--- gcc/cgraph.c	(working copy)
*************** cgraph_redirect_edge_call_stmt_to_callee
*** 1068,1073 ****
--- 1068,1074 ----
  	= gimple_call_copy_skip_args (e->call_stmt,
  				      e->callee->clone.combined_args_to_skip);
        gimple_call_set_fndecl (new_stmt, e->callee->symbol.decl);
+       gimple_call_set_fntype (new_stmt, gimple_call_fntype (e->call_stmt));
  
        if (gimple_vdef (new_stmt)
  	  && TREE_CODE (gimple_vdef (new_stmt)) == SSA_NAME)
Index: gcc/testsuite/gcc.dg/torture/pr57330.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr57330.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr57330.c	(working copy)
***************
*** 0 ****
--- 1,11 ----
+ /* { dg-do compile } */
+ 
+ void foo (int a)
+ {}
+ 
+ void *a;
+ void bar ()
+ {
+   void **( *b ) (  ) = (void**(*)()) foo;
+   a = b (0);
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]