[PATCH] Verify that call graph contains no misrepresened calls to thunks

Martin Jambor mjambor@suse.cz
Wed Dec 29 02:55:00 GMT 2010


Hi,

it seems I have forgotten to post the patch below.  It basically
verifies that there is no direct call to a thunk in the IL but it is
done as a part of the call graph verifier because problems and
miscompilations arise only when there is a call graph edge for the
call which inevitably does not represent it correctly and IPA passes
can come to wrong conclusions if they ever use it.

I've checked that the patch catches the calls to thunks we had in the
IL in the recent associated (fixed) PRs.  I have also bootstrapped and
tested it on x86_64-linux this week and did make check-c++ on i686
too.

Does this seem to be a good idea in general?  Is the patch OK to be
committed as it is?

Thanks,

Martin


2010-12-20  Martin Jambor  <mjambor@suse.cz>

	* cgraphunit.c (verify_cgraph_node): Verify there is no direct call to
	a thunk.

Index: icln/gcc/cgraphunit.c
===================================================================
--- icln.orig/gcc/cgraphunit.c	2010-12-27 16:46:51.000000000 +0100
+++ icln/gcc/cgraphunit.c	2010-12-28 12:02:49.000000000 +0100
@@ -647,6 +647,8 @@ verify_cgraph_node (struct cgraph_node *
 			  }
 			if (!e->indirect_unknown_callee)
 			  {
+			    struct cgraph_node *n;
+
 			    if (e->callee->same_body_alias)
 			      {
 				error ("edge points to same body alias:");
@@ -667,6 +669,15 @@ verify_cgraph_node (struct cgraph_node *
 				debug_tree (decl);
 				error_found = true;
 			      }
+			    else if (decl
+				     && (n = cgraph_get_node_or_alias (decl))
+				     && (n->same_body_alias
+					 && n->thunk.thunk_p))
+			      {
+				error ("a call to thunk improperly represented "
+				       "in the call graph:");
+				debug_gimple_stmt (stmt);
+			      }
 			  }
 			else if (decl)
 			  {



More information about the Gcc-patches mailing list