diff mbox

[RFA,C++] Symbol table 12/many: Remove cxx_analyze_expr hook

Message ID 20120420200835.GE20081@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka April 20, 2012, 8:08 p.m. UTC
Hi,
cxx_callgraph_analyze_expr contains logic that should be obsolette now.
PTRMEM_CST/BASELINK should be obsoletted by gimplification and VAR_DECL handling
seems weird from very start and I think it is remainder from time we was not
outputting function local vars from varpool but they needed a function decl.

Moreover cxx_callgraph_analyze_expr won't work with LTO.

Bootstrapped/regtested x86_64-linux, OK?

Honza

	* decl2.c (cxx_callgraph_analyze_expr): Remove.
	* cp-objcp-common.h (LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR): Remove.
	* cp-tree.h (cxx_callgraph_analyze_expr): Remove.

Comments

Jason Merrill April 21, 2012, 12:43 p.m. UTC | #1
OK.

Jason
Jan Hubicka April 21, 2012, 1:11 p.m. UTC | #2
Jason,
thank you.  My goal is to get rid of places where C++ FE is forcing symbols to be output unconditoinally.
I think the remaining cases are those where mark_decl_referenced is called.

My understnading is that those are
 1) COMDAT symbols that must be output because they are keyed, but for weird
    ABI reasons they have COMDAT linkage even if normal public linkage would
    suit better.

    This is code in maybe_make_one_only and the following call of mark_needed:
              if (!CLASSTYPE_KEY_METHOD (class_type)
                  || DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (class_type))
                  || targetm.cxx.class_data_always_comdat ())
                { 
                  /* The ABI requires COMDAT linkage.  Normally, we
                     only emit COMDAT things when they are needed;
                     make sure that we realize that this entity is
                     indeed needed.  */
                  comdat_p = true;
                  mark_needed (decl);
 2) symbols marked as needed by the repository (rest of mark_needed calls).

I would like to make those cases less restrictive. 

When doing LTO, we can still privatize and/or optimize out those symbols.  This is
the case where the symbols have hidden linkage and linker plugin tells us that there
are no external uses.

I am not sure about symbols exported form the DSO when linker plugin does not mark them
as used, I think they need to stay.

Consequentely I would like to add a new flag, comdat_keyed_by_abi, that force
comdat to stay unless the above exception holds (and verify that only comdats
are getting this flag).  Does this make sense?

It is couple thousdand symbols building Mozilla, being able to optimize them
may make things to smoother + this flag is a lot more descriptive than the
fallback mechanizm disabling any sort of optimization on the symbol.
(mark_decl_referenced has same the effect as used attribute, that is IPA code
assumes it has no chance to track its behaviour at all).

Honza
diff mbox

Patch

Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 186627)
+++ cp/decl2.c	(working copy)
@@ -3436,44 +3431,6 @@  generate_ctor_and_dtor_functions_for_pri
   return 0;
 }
 
-/* Called via LANGHOOK_CALLGRAPH_ANALYZE_EXPR.  It is supposed to mark
-   decls referenced from front-end specific constructs; it will be called
-   only for language-specific tree nodes.
-
-   Here we must deal with member pointers.  */
-
-tree
-cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED)
-{
-  tree t = *tp;
-
-  switch (TREE_CODE (t))
-    {
-    case PTRMEM_CST:
-      if (TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
-	cgraph_mark_address_taken_node (
-			      cgraph_get_create_node (PTRMEM_CST_MEMBER (t)));
-      break;
-    case BASELINK:
-      if (TREE_CODE (BASELINK_FUNCTIONS (t)) == FUNCTION_DECL)
-	cgraph_mark_address_taken_node (
-			      cgraph_get_create_node (BASELINK_FUNCTIONS (t)));
-      break;
-    case VAR_DECL:
-      if (DECL_CONTEXT (t)
-	  && flag_use_repository
-	  && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
-	/* If we need a static variable in a function, then we
-	   need the containing function.  */
-	mark_decl_referenced (DECL_CONTEXT (t));
-      break;
-    default:
-      break;
-    }
-
-  return NULL;
-}
-
 /* Java requires that we be able to reference a local address for a
    method, and not be confused by PLT entries.  If hidden aliases are
    supported, collect and return all the functions for which we should
Index: cp/cp-objcp-common.h
===================================================================
--- cp/cp-objcp-common.h	(revision 186623)
+++ cp/cp-objcp-common.h	(working copy)
@@ -110,9 +110,6 @@  extern void cp_common_init_ts (void);
 #undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
 #define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals
 
-#undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
-#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
-
 #undef LANG_HOOKS_MAKE_TYPE
 #define LANG_HOOKS_MAKE_TYPE cxx_make_type
 #undef LANG_HOOKS_TYPE_FOR_MODE
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 186623)
+++ cp/cp-tree.h	(working copy)
@@ -5136,7 +5136,6 @@  extern tree cp_build_parm_decl			(tree, 
 extern tree get_guard				(tree);
 extern tree get_guard_cond			(tree);
 extern tree set_guard				(tree);
-extern tree cxx_callgraph_analyze_expr		(tree *, int *);
 extern void mark_needed				(tree);
 extern bool decl_needed_p			(tree);
 extern void note_vague_linkage_fn		(tree);