Patchwork C++ constructors/destructors can not have address taken.

login
register
mail settings
Submitter Jan Hubicka
Date Aug. 26, 2013, 3:44 p.m.
Message ID <20130826154447.GA6539@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/269914/
State New
Headers show

Comments

Jan Hubicka - Aug. 26, 2013, 3:44 p.m.
Hi,
this patch tesch comdat_can_be_unshared_p_1 about the fact that C++
constructors and destructors can not have address taken that can be used for
equivalence comparsion.  This mean that we can privatize them into the DSO.

Bootstrapped/regtested x86_64-linux, comitted.

	* ipa.c (comdat_can_be_unshared_p_1): C++ constructors and destructors
	can be unshared.

Patch

Index: ipa.c
===================================================================
--- ipa.c	(revision 201995)
+++ ipa.c	(working copy)
@@ -574,9 +574,13 @@  static bool
 comdat_can_be_unshared_p_1 (symtab_node node)
 {
   /* When address is taken, we don't know if equality comparison won't
-     break eventually. Exception are virutal functions and vtables,
-     where this is not possible by language standard.  */
+     break eventually. Exception are virutal functions, C++
+     constructors/destructors and vtables, where this is not possible by
+     language standard.  */
   if (!DECL_VIRTUAL_P (node->symbol.decl)
+      && (TREE_CODE (node->symbol.decl) != FUNCTION_DECL
+	  || (!DECL_CXX_CONSTRUCTOR_P (node->symbol.decl)
+	      && !DECL_CXX_DESTRUCTOR_P (node->symbol.decl)))
       && address_taken_from_non_vtable_p (node))
     return false;