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]

Re: Revision 165569 breaks LTO


Hi,
the lto bootstrap problems are caused by my accidental commit of visibility
cleanups.  The patch improves visibility code to use IRONLY hints from the
plugin (as well as fixes few side cases) and this is what breaks libiberty
configure bits since the test for presence of HPUX function gets optimized
away and passes.

I believe the patch is correct as it is, but I am reverting it for now. My
original plan was to test and commit the cleanups alone and then comit the
extra feature of using IRONLY info incrementally. We need to fix libiberty
configure machinery and figure out if there are any linker plugin issues.  I
noticed that linker plugin is behaving bit strnagely when linking binary, so
need to figure out if it is actual linker bug or just my lack of understanding
of dynamic linking WRT main executables.

I apologize for the breakage.
Honza

	* ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p,
	function_and_variable_visibility): Revert accidental commit.
Index: ipa.c
===================================================================
*** ipa.c	(revision 165642)
--- ipa.c	(working copy)
*************** ipa_discover_readonly_nonaddressable_var
*** 593,599 ****
  static bool
  cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program, bool aliased)
  {
-   struct cgraph_node *alias;
    if (!node->local.finalized)
      return false;
    if (!DECL_COMDAT (node->decl)
--- 593,598 ----
*************** cgraph_externally_visible_p (struct cgra
*** 608,630 ****
    /* If linker counts on us, we must preserve the function.  */
    if (cgraph_used_from_object_file_p (node))
      return true;
-   if (DECL_PRESERVE_P (node->decl))
-     return true;
-   if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (node->decl)))
-     return true;
- 
-   /* See if we have linker information about symbol not being used or
-      if we need to make guess based on the declaration.
- 
-      Even if the linker clams the symbol is unused, never bring internal
-      symbols that are declared by user as used or externally visible.
-      This is needed for i.e. references from asm statements.   */
-   for (alias = node->same_body; alias; alias = alias->next)
-     if (alias->resolution != LDPR_PREVAILING_DEF_IRONLY)
-       break;
-   if (!alias && node->resolution == LDPR_PREVAILING_DEF_IRONLY)
-     return false;
- 
    /* When doing link time optimizations, hidden symbols become local.  */
    if (in_lto_p
        && (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
--- 607,612 ----
*************** cgraph_externally_visible_p (struct cgra
*** 656,725 ****
  	      return true;
  	}
      }
! 
!   if (MAIN_NAME_P (DECL_NAME (node->decl)))
!     return true;
! 
!   return false;
! }
! 
! /* Return true when variable VNODE should be considered externally visible.  */
! 
! static bool
! varpool_externally_visible_p (struct varpool_node *vnode, bool aliased)
! {
!   struct varpool_node *alias;
!   if (!DECL_COMDAT (vnode->decl) && !TREE_PUBLIC (vnode->decl))
!     return false;
! 
!   /* Do not even try to be smart about aliased nodes.  Until we properly
!      represent everything by same body alias, these are just evil.  */
!   if (aliased)
!     return true;
! 
!   /* If linker counts on us, we must preserve the function.  */
!   if (varpool_used_from_object_file_p (vnode))
!     return true;
! 
!   if (DECL_PRESERVE_P (vnode->decl))
!     return true;
!   if (lookup_attribute ("externally_visible",
! 			DECL_ATTRIBUTES (vnode->decl)))
!     return true;
! 
!   /* See if we have linker information about symbol not being used or
!      if we need to make guess based on the declaration.
! 
!      Even if the linker clams the symbol is unused, never bring internal
!      symbols that are declared by user as used or externally visible.
!      This is needed for i.e. references from asm statements.   */
!   if (varpool_used_from_object_file_p (vnode))
      return true;
!   for (alias = vnode->extra_name; alias; alias = alias->next)
!     if (alias->resolution != LDPR_PREVAILING_DEF_IRONLY)
!       break;
!   if (!alias && vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
!     return false;
! 
!   /* When doing link time optimizations, hidden symbols become local.  */
!   if (in_lto_p
!       && (DECL_VISIBILITY (vnode->decl) == VISIBILITY_HIDDEN
! 	  || DECL_VISIBILITY (vnode->decl) == VISIBILITY_INTERNAL)
!       /* Be sure that node is defined in IR file, not in other object
! 	 file.  In that case we don't set used_from_other_object_file.  */
!       && vnode->finalized)
!     ;
!   else if (!flag_whole_program)
      return true;
! 
!   /* Do not attempt to privatize COMDATS by default.
!      This would break linking with C++ libraries sharing
!      inline definitions.
! 
!      FIXME: We can do so for readonly vars with no address taken and
!      possibly also for vtables since no direct pointer comparsion is done.
!      It might be interesting to do so to reduce linking overhead.  */
!   if (DECL_COMDAT (vnode->decl) || DECL_WEAK (vnode->decl))
      return true;
    return false;
  }
--- 638,648 ----
  	      return true;
  	}
      }
!   if (DECL_PRESERVE_P (node->decl))
      return true;
!   if (MAIN_NAME_P (DECL_NAME (node->decl)))
      return true;
!   if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (node->decl)))
      return true;
    return false;
  }
*************** function_and_variable_visibility (bool w
*** 875,883 ****
        if (!vnode->finalized)
          continue;
        if (vnode->needed
! 	  && varpool_externally_visible_p
! 	      (vnode, 
! 	       pointer_set_contains (aliased_vnodes, vnode)))
  	vnode->externally_visible = true;
        else
          vnode->externally_visible = false;
--- 798,824 ----
        if (!vnode->finalized)
          continue;
        if (vnode->needed
! 	  && (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl))
! 	  && (((!whole_program
! 	        /* We can privatize comdat readonly variables whose address is
! 		   not taken, but doing so is not going to bring us
! 		   optimization oppurtunities until we start reordering
! 		   datastructures.  */
! 		|| DECL_COMDAT (vnode->decl)
! 		|| DECL_WEAK (vnode->decl))
! 	       /* When doing linktime optimizations, all hidden symbols will
! 		  become local.  */
! 	       && (!in_lto_p
! 		   || (DECL_VISIBILITY (vnode->decl) != VISIBILITY_HIDDEN
! 		       && DECL_VISIBILITY (vnode->decl) != VISIBILITY_INTERNAL)
! 		   /* We can get prevailing decision in other object file.
! 		      In this case we do not sed used_from_object_file.  */
! 		   || !vnode->finalized))
! 	      || DECL_PRESERVE_P (vnode->decl)
!               || varpool_used_from_object_file_p (vnode)
! 	      || pointer_set_contains (aliased_vnodes, vnode)
! 	      || lookup_attribute ("externally_visible",
! 				   DECL_ATTRIBUTES (vnode->decl))))
  	vnode->externally_visible = true;
        else
          vnode->externally_visible = false;


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