Blame SOURCES/gcc48-rh1546372.patch

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