Blame SOURCES/gcc48-rh1546372.patch

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