This is the mail archive of the gcc@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]

Re: Quo vadis, thunk? (Was: Re: [PATCH/RFA] PR target/16665: SH thunk


> Thus, I would consider the fact that G++ presently makes the thunks weak 
> even when the underlying function is not weak to be an odd quirk, if not 
> a bug.  I think that could safely be changed without endangering 
> anything.  It may be that it is the way it is for historical reasons; it 
> could also be that until my recent linkage cleanup, one could not be 
> sure whether the associated function would be COMDAT or not.  In any 
> case, I think you could change it now.

I see that use_thunk has now another call to comdat_linkage, so changing
things beforehand would be no good.
I changed the code in use_thunk to be more thorough in making the thunk
agree with the function.  (If you think all this adjusting of the thunk
can migrate to make_thunk, that is really a separate issue.)

What kind of testing would this patch require?

2004-08-03  J"orn Rennecke <joern.rennecke@superh.com>

	* method.c (use_thunk): Make DECL_ONE_ONLY, DECL_WEAK, DECL_COMDAT
	and DECL_SECTION_NAME of the thunk agree with the thunked-to function.

Index: method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.305
diff -p -r1.305 method.c
*** method.c	29 Jul 2004 17:59:28 -0000	1.305
--- method.c	3 Aug 2004 12:37:52 -0000
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 369,376 ****
    TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function);
    DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
    DECL_VISIBILITY_SPECIFIED (thunk_fndecl) = DECL_VISIBILITY_SPECIFIED (function);
!   if (flag_weak && TREE_PUBLIC (thunk_fndecl))
!     comdat_linkage (thunk_fndecl);
  
    if (flag_syntax_only)
      {
--- 369,380 ----
    TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function);
    DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
    DECL_VISIBILITY_SPECIFIED (thunk_fndecl) = DECL_VISIBILITY_SPECIFIED (function);
!   if (DECL_ONE_ONLY (function))
!     make_decl_one_only (thunk_fndecl);
!   else
!     DECL_ONE_ONLY (thunk_fndecl) = 0;
!   DECL_WEAK (thunk_fndecl) = DECL_WEAK (function);
!   DECL_COMDAT (thunk_fndecl) = DECL_COMDAT (function);
  
    if (flag_syntax_only)
      {
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 386,398 ****
        resolve_unique_section (function, 0, flag_function_sections);
  
        if (DECL_SECTION_NAME (function) != NULL && DECL_ONE_ONLY (function))
! 	{
! 	  resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
! 
! 	  /* Output the thunk into the same section as function.  */
! 	  DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
! 	}
      }
  
    /* The back-end expects DECL_INITIAL to contain a BLOCK, so we
       create one.  */
--- 390,399 ----
        resolve_unique_section (function, 0, flag_function_sections);
  
        if (DECL_SECTION_NAME (function) != NULL && DECL_ONE_ONLY (function))
! 	resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
      }
+   /* Output the thunk into the same section as function.  */
+   DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
  
    /* The back-end expects DECL_INITIAL to contain a BLOCK, so we
       create one.  */


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