diff mbox

Avoid use of DECL_REPLACEABLE in tree-inline

Message ID 20100907212853.GF12341@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Sept. 7, 2010, 9:28 p.m. UTC
Hi,
this patch removes tree-inline from testing DECL_REPLACEABLE.  We should not do
that early, since DECL_REPLACEABLE might become false as the effect of
-fwhole-program or LTO later during compilatoin and we do not want to prevent
inlining of such functions.

Instead inliner now tests availability itself to prevent inlining.

Bootstrapped/regtested x86_64-linux, comitted.
Honza

	* tree-inline.c (tree_inlinable_function_p): Do not test DECL_REPLACEABLE_P.
	* ipa-inline.c (cgraph_default_inline_p, update_caller_keys, update_callee_keys,
	cgraph_decide_inlining): Test function availability.
	* cif-code.def (OVERWRITABLE): New code.

Comments

Steven Bosscher Sept. 7, 2010, 9:35 p.m. UTC | #1
On Tue, Sep 7, 2010 at 11:28 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this patch removes tree-inline from testing DECL_REPLACEABLE.  We should not do
> that early, since DECL_REPLACEABLE might become false as the effect of
> -fwhole-program or LTO later during compilatoin and we do not want to prevent
> inlining of such functions.
>
> Instead inliner now tests availability itself to prevent inlining.

Is this safe for all users of local.inlinable? There's one test of
local.inlinable in ipa-split.c, for example.

Ciao!
Steven
Jan Hubicka Sept. 7, 2010, 9:49 p.m. UTC | #2
> On Tue, Sep 7, 2010 at 11:28 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > Hi,
> > this patch removes tree-inline from testing DECL_REPLACEABLE.  We should not do
> > that early, since DECL_REPLACEABLE might become false as the effect of
> > -fwhole-program or LTO later during compilatoin and we do not want to prevent
> > inlining of such functions.
> >
> > Instead inliner now tests availability itself to prevent inlining.
> 
> Is this safe for all users of local.inlinable? There's one test of
> local.inlinable in ipa-split.c, for example.

Yes, it is safe to split overwritable function as when the function get overwritten
the split parts become unreachable...

Honza
diff mbox

Patch

Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 163947)
+++ tree-inline.c	(working copy)
@@ -3197,12 +3197,6 @@  tree_inlinable_function_p (tree fn)
       inlinable = false;
     }
 
-  /* Don't auto-inline anything that might not be bound within
-     this unit of translation.  */
-  else if (!DECL_DECLARED_INLINE_P (fn)
-	   && DECL_REPLACEABLE_P (fn))
-    inlinable = false;
-
   else if (!function_attribute_inlinable_p (fn))
     {
       if (do_warning)
Index: ipa-inline.c
===================================================================
--- ipa-inline.c	(revision 163947)
+++ ipa-inline.c	(working copy)
@@ -480,13 +480,19 @@  cgraph_default_inline_p (struct cgraph_n
 	*reason = CIF_FUNCTION_NOT_INLINE_CANDIDATE;
       return false;
     }
-
   if (!n->analyzed)
     {
       if (reason)
 	*reason = CIF_BODY_NOT_AVAILABLE;
       return false;
     }
+  if (cgraph_function_body_availability (n) <= AVAIL_OVERWRITABLE)
+    {
+      if (reason)
+	*reason = CIF_OVERWRITABLE;
+      return false;
+    }
+
 
   if (DECL_DECLARED_INLINE_P (decl))
     {
@@ -697,6 +703,7 @@  update_caller_keys (fibheap_t heap, stru
   cgraph_inline_failed_t failed_reason;
 
   if (!node->local.inlinable
+      || cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE
       || node->global.inlined_to)
     return;
   if (!bitmap_set_bit (updated_nodes, node->uid))
@@ -749,6 +756,7 @@  update_callee_keys (fibheap_t heap, stru
       {
 	if (e->inline_failed
 	    && e->callee->local.inlinable
+	    && cgraph_function_body_availability (e->callee) >= AVAIL_AVAILABLE
 	    && !bitmap_bit_p (updated_nodes, e->callee->uid))
 	  {
 	    node->global.estimated_growth = INT_MIN;
@@ -1499,6 +1507,7 @@  cgraph_decide_inlining (void)
 	      && !node->callers->next_caller
 	      && cgraph_will_be_removed_from_program_if_no_direct_calls (node)
 	      && node->local.inlinable
+	      && cgraph_function_body_availability (node) >= AVAIL_AVAILABLE
 	      && node->callers->inline_failed
 	      && node->callers->caller != node
 	      && node->callers->caller->global.inlined_to != node
Index: cif-code.def
===================================================================
--- cif-code.def	(revision 163947)
+++ cif-code.def	(working copy)
@@ -88,3 +88,5 @@  DEFCIFCODE(ORIGINALLY_INDIRECT_CALL,
 /* Ths edge represents an indirect edge with a yet-undetermined callee .  */
 DEFCIFCODE(INDIRECT_UNKNOWN_CALL,
 	   N_("indirect function call with a yet undetermined callee"))
+
+DEFCIFCODE(OVERWRITABLE, N_("function body can be overwriten at linktime"))