Blame SOURCES/gcc48-rh1546372.patch

802f23
	* cif-code.def: Add NEVER_EXECUTED.
802f23
	* ipa-inline-analysis.c (reset_inline_summary,
802f23
	compute_inline_parameters, estimate_calls_size_and_time,
802f23
	inline_update_overall_summary): Track number of calls.
802f23
	(never_executed_edge_p): New predicate.
802f23
	* ipa-inline.c (want_inline_self_recursive_call_p): do not inline
802f23
	recursively for calls that are not going to be executed.
802f23
	(inline_small_functions): Do not inline never exeucted edge if callee
802f23
	has too many calls.
802f23
	* ipa-inline.h (inline_summary): Add num calls.
802f23
	(never_executed_edge_p): New.
802f23
802f23
--- gcc/cif-code.def	(revision 257016)
802f23
+++ gcc/cif-code.def	(working copy)
802f23
@@ -103,3 +103,6 @@ DEFCIFCODE(TARGET_OPTION_MISMATCH, N_("t
802f23
 
802f23
 /* We can't inline because of mismatched optimization levels.  */
802f23
 DEFCIFCODE(OPTIMIZATION_MISMATCH, N_("optimization level attribute mismatch"))
802f23
+
802f23
+/* We know that the call will be optimized out.  */
802f23
+DEFCIFCODE(NEVER_EXECUTED, N_("never executed"))
802f23
--- gcc/ipa-inline-analysis.c	(revision 257016)
802f23
+++ gcc/ipa-inline-analysis.c	(working copy)
802f23
@@ -990,6 +990,7 @@ reset_inline_summary (struct cgraph_node
802f23
   info->stack_frame_offset = 0;
802f23
   info->size = 0;
802f23
   info->time = 0;
802f23
+  info->num_calls = 0;
802f23
   info->growth = 0;
802f23
   info->scc_no = 0;
802f23
   if (info->loop_iterations)
802f23
@@ -2704,6 +2705,7 @@ compute_inline_parameters (struct cgraph
802f23
   /* Inlining characteristics are maintained by the cgraph_mark_inline.  */
802f23
   info->time = info->self_time;
802f23
   info->size = info->self_size;
802f23
+  info->num_calls = 0;
802f23
   info->stack_frame_offset = 0;
802f23
   info->estimated_stack_size = info->estimated_self_stack_size;
802f23
 #ifdef ENABLE_CHECKING
802f23
@@ -2816,7 +2818,7 @@ estimate_edge_size_and_time (struct cgra
802f23
 
802f23
 static void
802f23
 estimate_calls_size_and_time (struct cgraph_node *node, int *size, int *time,
802f23
-			      inline_hints *hints,
802f23
+			      inline_hints *hints, int *num,
802f23
 			      clause_t possible_truths,
802f23
 			      vec<tree> known_vals,
802f23
 			      vec<tree> known_binfos,
802f23
@@ -2826,6 +2828,7 @@ estimate_calls_size_and_time (struct cgr
802f23
   for (e = node->callees; e; e = e->next_callee)
802f23
     {
802f23
       struct inline_edge_summary *es = inline_edge_summary (e);
802f23
+      (*num)++;
802f23
       if (!es->predicate
802f23
 	  || evaluate_predicate (es->predicate, possible_truths))
802f23
 	{
802f23
@@ -2838,7 +2841,7 @@ estimate_calls_size_and_time (struct cgr
802f23
 					   known_aggs, hints);
802f23
 	    }
802f23
 	  else
802f23
-	    estimate_calls_size_and_time (e->callee, size, time, hints,
802f23
+	    estimate_calls_size_and_time (e->callee, size, time, hints, num,
802f23
 					  possible_truths,
802f23
 					  known_vals, known_binfos,
802f23
 					  known_aggs);
802f23
@@ -2846,6 +2849,7 @@ estimate_calls_size_and_time (struct cgr
802f23
     }
802f23
   for (e = node->indirect_calls; e; e = e->next_callee)
802f23
     {
802f23
+      (*num)++;
802f23
       struct inline_edge_summary *es = inline_edge_summary (e);
802f23
       if (!es->predicate
802f23
 	  || evaluate_predicate (es->predicate, possible_truths))
802f23
@@ -2936,7 +2940,8 @@ estimate_node_size_and_time (struct cgra
802f23
   if (DECL_DECLARED_INLINE_P (node->symbol.decl))
802f23
     hints |= INLINE_HINT_declared_inline;
802f23
 
802f23
-  estimate_calls_size_and_time (node, &size, &time, &hints, possible_truths,
802f23
+  int num = 0;
802f23
+  estimate_calls_size_and_time (node, &size, &time, &hints, &num, possible_truths,
802f23
 				known_vals, known_binfos, known_aggs);
802f23
   gcc_checking_assert (size >= 0);
802f23
   gcc_checking_assert (time >= 0);
802f23
@@ -3369,13 +3374,14 @@ inline_update_overall_summary (struct cg
802f23
 
802f23
   info->size = 0;
802f23
   info->time = 0;
802f23
+  info->num_calls = 0;
802f23
   for (i = 0; vec_safe_iterate (info->entry, i, &e); i++)
802f23
     {
802f23
       info->size += e->size, info->time += e->time;
802f23
       if (info->time > MAX_TIME * INLINE_TIME_SCALE)
802f23
 	info->time = MAX_TIME * INLINE_TIME_SCALE;
802f23
     }
802f23
-  estimate_calls_size_and_time (node, &info->size, &info->time, NULL,
802f23
+  estimate_calls_size_and_time (node, &info->size, &info->time, NULL, &info->num_calls,
802f23
 				~(clause_t) (1 << predicate_false_condition),
802f23
 				vNULL, vNULL, vNULL);
802f23
   info->time = (info->time + INLINE_TIME_SCALE / 2) / INLINE_TIME_SCALE;
802f23
@@ -3528,6 +3534,14 @@ do_estimate_edge_hints (struct cgraph_ed
802f23
   return hints;
802f23
 }
802f23
 
802f23
+/* Return true if edge is never executed.  */
802f23
+bool
802f23
+never_executed_edge_p (struct cgraph_edge *e)
802f23
+{
802f23
+ struct inline_edge_summary *es = inline_edge_summary (e);
802f23
+ return es->predicate && false_predicate_p (es->predicate);
802f23
+}
802f23
+
802f23
 
802f23
 /* Estimate self time of the function NODE after inlining EDGE.  */
802f23
 
802f23
--- gcc/ipa-inline.c	(revision 257016)
802f23
+++ gcc/ipa-inline.c	(working copy)
802f23
@@ -656,6 +656,11 @@ want_inline_self_recursive_call_p (struc
802f23
       reason = "--param max-inline-recursive-depth exceeded.";
802f23
       want_inline = false;
802f23
     }
802f23
+  else if (never_executed_edge_p (edge))
802f23
+    {
802f23
+      reason = "edge is never executed.";
802f23
+      want_inline = false;
802f23
+    }
802f23
 
802f23
   if (outer_node->global.inlined_to)
802f23
     caller_freq = outer_node->callers->frequency;
802f23
@@ -1597,6 +1602,14 @@ inline_small_functions (void)
802f23
 		outer_node = where, depth++;
802f23
 	      where = where->callers->caller;
802f23
 	    }
802f23
+	  if (never_executed_edge_p (edge)
802f23
+	      && inline_summary (edge->callee)->num_calls > 30)
802f23
+	    {
802f23
+	      if (dump_file)
802f23
+	        fprintf (dump_file, "Never executed edge\n");
802f23
+	      edge->inline_failed = CIF_NEVER_EXECUTED;
802f23
+	      continue;
802f23
+	    }
802f23
 	  if (outer_node
802f23
 	      && !want_inline_self_recursive_call_p (edge, outer_node,
802f23
 						     true, depth))
802f23
--- gcc/ipa-inline.h	(revision 257016)
802f23
+++ gcc/ipa-inline.h	(working copy)
802f23
@@ -132,6 +132,7 @@ struct GTY(()) inline_summary
802f23
   /* Estimated size of the function after inlining.  */
802f23
   int time;
802f23
   int size;
802f23
+  int num_calls;
802f23
 
802f23
   /* Conditional size/time information.  The summaries are being
802f23
      merged during inlining.  */
802f23
@@ -226,6 +227,7 @@ inline_hints do_estimate_edge_hints (str
802f23
 void initialize_growth_caches (void);
802f23
 void free_growth_caches (void);
802f23
 void compute_inline_parameters (struct cgraph_node *, bool);
802f23
+bool never_executed_edge_p (struct cgraph_edge *);
802f23
 
802f23
 /* In ipa-inline-transform.c  */
802f23
 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge_p> *, int *, bool);
802f23