PATCH: better diagnostic on inline failure

Nathan Sidwell nathan@acm.org
Sun Feb 28 18:15:00 GMT 1999


Nathan Sidwell wrote:
>stuff
Oh, what a bozo brain. It's callER not callEE. Here's an amended patcj (against
the 19990208 snapshot) with sensible object names. Sorry.

I've checked it against the g++ testsuite.

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
egcs/gcc/ChangeLog:
Tue Feb  9 09:29:26 GMT 1999  Nathan Sidwell  <nathan@acm.org>

	* tree.h (DECL_FIRST_CALLER): New macro.
	(tree_decl) Add first_caller member.
	* c-decl.c (duplicate_decls): Preserve DECL_FIRST_CALLER from
	old decl.
	(start_function): Check DECL_FIRST_CALLER, and issue inline failure
	warning if set.
	* calls.c (expand_call): Set DECL_FIRST_CALLER, if failed to
	inline because no definition.

egcs/gcc/cp/ChangeLog:
Tue Feb  9 09:29:26 GMT 1999  Nathan Sidwell  <nathan@acm.org>

	* decl.c (duplicate_decls): Preserve DECL_FIRST_CALLER from old
	decl.
	(start_function): Check DECL_FIRST_CALLER, and issue inline
	failure warning if set.

Index: egcs/gcc/tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tree.h,v
retrieving revision 1.66
diff -c -3 -p -r1.66 tree.h
*** tree.h	1999/02/07 20:20:36	1.66
--- tree.h	1999/02/09 10:15:02
*************** struct tree_type
*** 1100,1105 ****
--- 1100,1107 ----
  #define DECL_SET_FUNCTION_CODE(NODE,VAL) (DECL_CHECK (NODE)->decl.frame_size.f = (VAL))
  /* For a FIELD_DECL, holds the size of the member as an integer.  */
  #define DECL_FIELD_SIZE(NODE) (DECL_CHECK (NODE)->decl.saved_insns.i)
+ /* For a FUNCTION_DECL, holds the first caller */
+ #define DECL_FIRST_CALLER(NODE) (DECL_CHECK (NODE)->decl.first_caller)
  
  /* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways.
     Before the struct containing the FUNCTION_DECL is laid out,
*************** struct tree_decl
*** 1353,1358 ****
--- 1355,1363 ----
    int pointer_alias_set;
    /* Points to a structure whose details depend on the language in use.  */
    struct lang_decl *lang_specific;
+   /* For FUNCTION_DECLs points to decl of first function which calls this
+    * one. Used to help in diagnostics of inline failures */
+   tree first_caller;
  };
  
  /* Define the overall contents of a tree node.
Index: egcs/gcc/calls.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/calls.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 calls.c
*** calls.c	1999/01/27 01:41:50	1.42
--- calls.c	1999/02/09 10:15:04
*************** expand_call (exp, target, ignore)
*** 977,983 ****
  		  && optimize > 0)
  		{
  		  warning_with_decl (fndecl, "can't inline call to `%s'");
! 		  warning ("called from here");
  		}
  	      mark_addressable (fndecl);
  	    }
--- 977,985 ----
  		  && optimize > 0)
  		{
  		  warning_with_decl (fndecl, "can't inline call to `%s'");
! 		  warning ("called from here before definition");
!                   if (! DECL_FIRST_CALLER (fndecl))
!                     DECL_FIRST_CALLER (fndecl) = current_function_decl;
  		}
  	      mark_addressable (fndecl);
  	    }
Index: egcs/gcc/c-decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-decl.c,v
retrieving revision 1.59
diff -c -3 -p -r1.59 c-decl.c
*** c-decl.c	1999/01/31 17:46:15	1.59
--- c-decl.c	1999/02/09 10:15:09
*************** duplicate_decls (newdecl, olddecl, diffe
*** 2116,2129 ****
      }
  
    /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
!      But preserve OLDDECL's DECL_UID.  */
    {
      register unsigned olddecl_uid = DECL_UID (olddecl);
  
      bcopy ((char *) newdecl + sizeof (struct tree_common),
  	   (char *) olddecl + sizeof (struct tree_common),
  	   sizeof (struct tree_decl) - sizeof (struct tree_common));
      DECL_UID (olddecl) = olddecl_uid;
    }
  
    /* NEWDECL contains the merged attribute lists.
--- 2116,2131 ----
      }
  
    /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
!      But preserve OLDDECL's DECL_UID and DECL_FIRST_CALLER.  */
    {
      register unsigned olddecl_uid = DECL_UID (olddecl);
+     tree olddecl_first_caller = DECL_FIRST_CALLER (olddecl);
  
      bcopy ((char *) newdecl + sizeof (struct tree_common),
  	   (char *) olddecl + sizeof (struct tree_common),
  	   sizeof (struct tree_decl) - sizeof (struct tree_common));
      DECL_UID (olddecl) = olddecl_uid;
+     DECL_FIRST_CALLER (olddecl) = olddecl_first_caller;
    }
  
    /* NEWDECL contains the merged attribute lists.
*************** start_function (declspecs, declarator, p
*** 6409,6414 ****
--- 6411,6417 ----
    tree decl1, old_decl;
    tree restype;
    int old_immediate_size_expand = immediate_size_expand;
+   tree first_caller;
  
    current_function_returns_value = 0;  /* Assume, until we see it does.  */
    current_function_returns_null = 0;
*************** start_function (declspecs, declarator, p
*** 6592,6597 ****
--- 6595,6607 ----
       use the old decl.  */
  
    current_function_decl = pushdecl (decl1);
+ 
+   first_caller = DECL_FIRST_CALLER (current_function_decl);
+   if (first_caller)
+     {
+       warning ("already failed to inline, first called");
+       warning_with_decl (first_caller, "within `%s' defined here");
+     }
  
    pushlevel (0);
    declare_parm_level (1);
Index: egcs/gcc/cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.306
diff -c -3 -p -r1.306 decl.c
*** decl.c	1999/02/05 02:42:48	1.306
--- decl.c	1999/02/09 10:15:18
*************** duplicate_decls (newdecl, olddecl)
*** 2858,2863 ****
--- 2858,2864 ----
  {
    extern struct obstack permanent_obstack;
    unsigned olddecl_uid = DECL_UID (olddecl);
+   tree olddecl_first_caller = DECL_FIRST_CALLER (olddecl);
    int olddecl_friend = 0, types_match = 0;
    int new_defines_function = 0;
  
*************** duplicate_decls (newdecl, olddecl)
*** 3507,3512 ****
--- 3508,3514 ----
      }
  
    DECL_UID (olddecl) = olddecl_uid;
+   DECL_FIRST_CALLER (olddecl) = olddecl_first_caller;
    if (olddecl_friend)
      DECL_FRIEND_P (olddecl) = 1;
  
*************** start_function (declspecs, declarator, a
*** 12824,12829 ****
--- 12826,12832 ----
    extern int have_extern_spec;
    extern int used_extern_spec;
    int doing_friend = 0;
+   tree first_caller;
  
    /* Sanity check.  */
    my_friendly_assert (TREE_CODE (TREE_VALUE (void_list_node)) == VOID_TYPE, 160);
*************** start_function (declspecs, declarator, a
*** 13054,13059 ****
--- 13057,13069 ----
      }
  
    current_function_decl = decl1;
+ 
+   first_caller = DECL_FIRST_CALLER (current_function_decl);
+   if (first_caller)
+     {
+       warning ("already failed to inline, first called");
+       warning_with_decl (first_caller, "within `%s' defined here");
+     }
  
    if (DECL_INTERFACE_KNOWN (decl1))
      {


More information about the Gcc-patches mailing list