public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: PATCH Re: c++/4122: undefined reference to `non-virtual thunk to  ...'
@ 2001-12-21 16:56 Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2001-12-21 16:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4122; it has been noted by GNATS.

From: Jason Merrill <jason@redhat.com>
To: law@redhat.com
Cc: Robert Boehne <rboehne@ricardo-us.com>, gcc-gnats@gcc.gnu.org,
   juergen@monocerus.demon.co.uk, boehme@informatik.hu-berlin.de,
   loewis@informatik.hu-berlin.de, gcc-bugs@gcc.gnu.org, michael@ritzert.de,
   gcc-patches@gcc.gnu.org
Subject: Re: PATCH Re: c++/4122: undefined reference to `non-virtual thunk
 to  ...'
Date: Sat, 22 Dec 2001 00:47:15 +0000

 >>>>> "law" == law  <law@redhat.com> writes:
 
 > FWIW, I tried this on my testcases locally and it didn't make any noticable
 > difference (sid & ecosconfig).
 
 Yep, this was for a target-independent problem, not the HPUX-specific ones.
 
 > I'll try to get you testcases for both these issues today.
 
 Thanks.
 
 Jason


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH Re: c++/4122: undefined reference to `non-virtual thunk to  ...'
@ 2001-12-22  9:56 law
  0 siblings, 0 replies; 4+ messages in thread
From: law @ 2001-12-22  9:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4122; it has been noted by GNATS.

From: law@redhat.com
To: Jason Merrill <jason@redhat.com>
Cc: Robert Boehne <rboehne@ricardo-us.com>, gcc-gnats@gcc.gnu.org,
        juergen@monocerus.demon.co.uk, boehme@informatik.hu-berlin.de,
        loewis@informatik.hu-berlin.de, gcc-bugs@gcc.gnu.org,
        michael@ritzert.de, gcc-patches@gcc.gnu.org
Subject: Re: PATCH Re: c++/4122: undefined reference to `non-virtual thunk to 
 ...'
Date: Sat, 22 Dec 2001 10:47:59 -0700

   > Yep, this was for a target-independent problem, not the HPUX-specific ones.
   > 
   > > I'll try to get you testcases for both these issues today.
 OK.  Here's a testcase for the missing .import statements.
 
 Compile the attached testcase with -O2 for hppa2.0-hp-hpux1.00 (you can 
 probably
 build a cross-cc1plus for this instead of messing with a native compiler).  
 Note
 this is with the 2002r1 branch from Red Hat's internal repository.  I have
 not tried it in the mainline sources.
 
 If you look at the assembly output, you'll find something like this:
 
         .word P%_ZTv0_n28_N18CdlUserVisibleBodyD0Ev
 
 The problem is we need to explicitly import _ZTv0_n28_N18CdlUserVisibleBodyD0Ev
 since it's defined in a different compilation unit.  Usually the lack of an
 import is related to a missing assemble_external call.
 
 jeff
 
 
 
 
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH Re: c++/4122: undefined reference to `non-virtual thunk to  ...'
@ 2001-12-21 13:06 law
  0 siblings, 0 replies; 4+ messages in thread
From: law @ 2001-12-21 13:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4122; it has been noted by GNATS.

From: law@redhat.com
To: Jason Merrill <jason@redhat.com>
Cc: Robert Boehne <rboehne@ricardo-us.com>, gcc-gnats@gcc.gnu.org,
        juergen@monocerus.demon.co.uk, boehme@informatik.hu-berlin.de,
        loewis@informatik.hu-berlin.de, gcc-bugs@gcc.gnu.org,
        michael@ritzert.de, gcc-patches@gcc.gnu.org
Subject: Re: PATCH Re: c++/4122: undefined reference to `non-virtual thunk to 
 ...'
Date: Fri, 21 Dec 2001 13:54:59 -0700

 > Thanks for the testcase; please give this a try.  The problem was that we
 > had calculated the -4 offset for a lost primary, the primary base was
 > regained in the constructor vtable, and so the calculated offset was
 > wrong.
 > 
 > 2001-12-21  Jason Merrill  <jason@redhat.com>
 > 
 > 	* class.c (update_vtable_entry_for_fn): Set delta to zero for a
 > 	lost primary.
 > 
 > 	* class.c (build_vtbl_initializer): Check for a lost primary
 > 	before calculating the vtable entry to throw away.
 Thanks.  
 
 FWIW, I tried this on my testcases locally and it didn't make any noticable
 difference (sid & ecosconfig).
 
 There's still two distinct issues.
 
   1. Some thunks are being defined with local scope
 
   2. We are not calling assemble_external when we reference certain thunks.
 
 I'll try to get you testcases for both these issues today.
 jeff
 
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* PATCH Re: c++/4122: undefined reference to `non-virtual thunk to ...'
@ 2001-12-21 10:56 Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2001-12-21 10:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4122; it has been noted by GNATS.

From: Jason Merrill <jason@redhat.com>
To: Robert Boehne <rboehne@ricardo-us.com>
Cc: gcc-gnats@gcc.gnu.org, juergen@monocerus.demon.co.uk,
   boehme@informatik.hu-berlin.de, loewis@informatik.hu-berlin.de,
   gcc-bugs@gcc.gnu.org, michael@ritzert.de, gcc-patches@gcc.gnu.org
Subject: PATCH Re: c++/4122: undefined reference to `non-virtual thunk to
 ...'
Date: Fri, 21 Dec 2001 18:42:09 +0000

 --=-=-=
 
 Thanks for the testcase; please give this a try.  The problem was that we
 had calculated the -4 offset for a lost primary, the primary base was
 regained in the constructor vtable, and so the calculated offset was
 wrong.
 
 2001-12-21  Jason Merrill  <jason@redhat.com>
 
 	* class.c (update_vtable_entry_for_fn): Set delta to zero for a
 	lost primary.
 
 	* class.c (build_vtbl_initializer): Check for a lost primary
 	before calculating the vtable entry to throw away.
 
 
 --=-=-=
 Content-Type: text/x-patch
 Content-Disposition: inline
 
 *** class.c.~1~	Tue Dec 18 15:17:39 2001
 --- class.c	Fri Dec 21 17:55:14 2001
 *************** update_vtable_entry_for_fn (t, binfo, fn
 *** 2494,2499 ****
 --- 2494,2500 ----
     tree delta;
     tree virtual_base;
     tree first_defn;
 +   bool lost = false;
   
     /* Find the nearest primary base (possibly binfo itself) which defines
        this function; this is the class the caller will convert to when
 *************** update_vtable_entry_for_fn (t, binfo, fn
 *** 2502,2507 ****
 --- 2503,2512 ----
       {
         if (look_for_overrides_here (BINFO_TYPE (b), fn))
   	break;
 + 
 +       /* The nearest definition is from a lost primary.  */
 +       if (BINFO_LOST_PRIMARY_P (b))
 + 	lost = true;
       }
     first_defn = b;
   
 *************** update_vtable_entry_for_fn (t, binfo, fn
 *** 2514,2522 ****
        the final overrider, and not to an intermediate virtual base.  */
     virtual_base = NULL_TREE;
   
 !   /* We will convert to an intermediate virtual base first, and then
        use the vcall offset located there to finish the conversion.  */
 !   while (b)
       {
         /* If we find the final overrider, then we can stop
   	 walking.  */
 --- 2519,2527 ----
        the final overrider, and not to an intermediate virtual base.  */
     virtual_base = NULL_TREE;
   
 !   /* See if we can convert to an intermediate virtual base first, and then
        use the vcall offset located there to finish the conversion.  */
 !   for (; b; b = BINFO_INHERITANCE_CHAIN (b))
       {
         /* If we find the final overrider, then we can stop
   	 walking.  */
 *************** update_vtable_entry_for_fn (t, binfo, fn
 *** 2529,2536 ****
   	 declaring base (first_defn) and the final overrider.  */
         if (!virtual_base && TREE_VIA_VIRTUAL (b))
   	virtual_base = b;
 - 
 -       b = BINFO_INHERITANCE_CHAIN (b);
       }
   
     /* Compute the constant adjustment to the `this' pointer.  The
 --- 2534,2539 ----
 *************** update_vtable_entry_for_fn (t, binfo, fn
 *** 2542,2547 ****
 --- 2545,2556 ----
          the nearest virtual base.  */
       delta = size_diffop (BINFO_OFFSET (virtual_base),
   			 BINFO_OFFSET (first_defn));
 +   else if (lost)
 +     /* If the nearest definition is in a lost primary, we don't need an
 +        entry in our vtable.  Except possibly in a constructor vtable,
 +        if we happen to get our primary back.  In that case, the offset
 +        will be zero, as it will be a primary base.  */
 +     delta = size_zero_node;
     else
       {
         /* The `this' pointer needs to be adjusted from pointing to
 *************** build_vtbl_initializer (binfo, orig_binf
 *** 7502,7563 ****
         tree vcall_index;
         tree fn;
         tree pfn;
 !       tree init;
         
 -       /* Pull the offset for `this', and the function to call, out of
 - 	 the list.  */
 -       delta = BV_DELTA (v);
 - 
 -       if (BV_USE_VCALL_INDEX_P (v))
 - 	{
 - 	  vcall_index = BV_VCALL_INDEX (v);
 - 	  my_friendly_assert (vcall_index != NULL_TREE, 20000621);
 - 	}
 -       else
 -         vcall_index = NULL_TREE;
 - 
         fn = BV_FN (v);
 -       my_friendly_assert (TREE_CODE (delta) == INTEGER_CST, 19990727);
 -       my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 19990727);
 - 
 -       /* You can't call an abstract virtual function; it's abstract.
 - 	 So, we replace these functions with __pure_virtual.  */
 -       if (DECL_PURE_VIRTUAL_P (fn))
 - 	fn = abort_fndecl;
 - 
 -       /* Take the address of the function, considering it to be of an
 - 	 appropriate generic type.  */
 -       pfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, fn);
 -       /* The address of a function can't change.  */
 -       TREE_CONSTANT (pfn) = 1;
 - 
 -       /* Enter it in the vtable.  */
 -       init = build_vtable_entry (delta, vcall_index, pfn);
   
         /* If the only definition of this function signature along our
   	 primary base chain is from a lost primary, this vtable slot will
   	 never be used, so just zero it out.  This is important to avoid
   	 requiring extra thunks which cannot be generated with the function.
   
 ! 	 We could also handle this in update_vtable_entry_for_fn; doing it
 ! 	 here means we zero out unused slots in ctor vtables as well,
 ! 	 rather than filling them with erroneous values (though harmless,
 ! 	 apart from relocation costs).  */
 !       if (fn != abort_fndecl)
 ! 	for (b = binfo; ; b = get_primary_binfo (b))
 ! 	  {
 ! 	    /* We found a defn before a lost primary; go ahead as normal.  */
 ! 	    if (look_for_overrides_here (BINFO_TYPE (b), fn))
   	      break;
   
 ! 	    /* The nearest definition is from a lost primary; clear the
 ! 	       slot.  */
 ! 	    if (BINFO_LOST_PRIMARY_P (b))
 ! 	      {
 ! 		init = size_zero_node;
 ! 		break;
 ! 	      }
 ! 	  }
   
         /* And add it to the chain of initializers.  */
         if (TARGET_VTABLE_USES_DESCRIPTORS)
 --- 7511,7576 ----
         tree vcall_index;
         tree fn;
         tree pfn;
 !       tree init = NULL_TREE;
         
         fn = BV_FN (v);
   
         /* If the only definition of this function signature along our
   	 primary base chain is from a lost primary, this vtable slot will
   	 never be used, so just zero it out.  This is important to avoid
   	 requiring extra thunks which cannot be generated with the function.
   
 ! 	 We first check this in update_vtable_entry_for_fn, so we handle
 ! 	 restored primary bases properly; we also need to do it here so we
 ! 	 zero out unused slots in ctor vtables, rather than filling themff
 ! 	 with erroneous values (though harmless, apart from relocation
 ! 	 costs).  */
 !       for (b = binfo; ; b = get_primary_binfo (b))
 ! 	{
 ! 	  /* We found a defn before a lost primary; go ahead as normal.  */
 ! 	  if (look_for_overrides_here (BINFO_TYPE (b), fn))
 ! 	    break;
 ! 
 ! 	  /* The nearest definition is from a lost primary; clear the
 ! 	     slot.  */
 ! 	  if (BINFO_LOST_PRIMARY_P (b))
 ! 	    {
 ! 	      init = size_zero_node;
   	      break;
 + 	    }
 + 	}
   
 !       if (! init)
 ! 	{
 ! 	  /* Pull the offset for `this', and the function to call, out of
 ! 	     the list.  */
 ! 	  delta = BV_DELTA (v);
 ! 
 ! 	  if (BV_USE_VCALL_INDEX_P (v))
 ! 	    {
 ! 	      vcall_index = BV_VCALL_INDEX (v);
 ! 	      my_friendly_assert (vcall_index != NULL_TREE, 20000621);
 ! 	    }
 ! 	  else
 ! 	    vcall_index = NULL_TREE;
 ! 
 ! 	  my_friendly_assert (TREE_CODE (delta) == INTEGER_CST, 19990727);
 ! 	  my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 19990727);
 ! 
 ! 	  /* You can't call an abstract virtual function; it's abstract.
 ! 	     So, we replace these functions with __pure_virtual.  */
 ! 	  if (DECL_PURE_VIRTUAL_P (fn))
 ! 	    fn = abort_fndecl;
 ! 
 ! 	  /* Take the address of the function, considering it to be of an
 ! 	     appropriate generic type.  */
 ! 	  pfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, fn);
 ! 	  /* The address of a function can't change.  */
 ! 	  TREE_CONSTANT (pfn) = 1;
 ! 
 ! 	  /* Enter it in the vtable.  */
 ! 	  init = build_vtable_entry (delta, vcall_index, pfn);
 ! 	}
   
         /* And add it to the chain of initializers.  */
         if (TARGET_VTABLE_USES_DESCRIPTORS)
 
 --=-=-=--


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-12-22 17:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-21 16:56 PATCH Re: c++/4122: undefined reference to `non-virtual thunk to ...' Jason Merrill
  -- strict thread matches above, loose matches on Subject: below --
2001-12-22  9:56 law
2001-12-21 13:06 law
2001-12-21 10:56 Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).