Blame SOURCES/gcc48-rh1312436.patch

001c85
2015-12-02  Pierre-Marie de Rodat  <derodat@adacore.com>
001c85
001c85
	* dwarf2out.c (dwar2out_var_location): Enhance pattern matching to get
001c85
	the SYMBOL_REF they embed.
001c85
	(gen_subprogram_die): Handle such calls.
001c85
001c85
--- gcc/dwarf2out.c	(revision 231184)
001c85
+++ gcc/dwarf2out.c	(revision 231185)
001c85
@@ -18051,18 +18051,23 @@ gen_subprogram_die (tree decl, dw_die_re
001c85
 		    }
001c85
 		  if (mode == VOIDmode || mode == BLKmode)
001c85
 		    continue;
001c85
-		  if (XEXP (XEXP (arg, 0), 0) == pc_rtx)
001c85
+		  /* Get dynamic information about call target only if we
001c85
+		     have no static information: we cannot generate both
001c85
+		     DW_AT_abstract_origin and DW_AT_GNU_call_site_target
001c85
+		     attributes.  */
001c85
+		  if (ca_loc->symbol_ref == NULL_RTX)
001c85
 		    {
001c85
-		      gcc_assert (ca_loc->symbol_ref == NULL_RTX);
001c85
-		      tloc = XEXP (XEXP (arg, 0), 1);
001c85
-		      continue;
001c85
-		    }
001c85
-		  else if (GET_CODE (XEXP (XEXP (arg, 0), 0)) == CLOBBER
001c85
-			   && XEXP (XEXP (XEXP (arg, 0), 0), 0) == pc_rtx)
001c85
-		    {
001c85
-		      gcc_assert (ca_loc->symbol_ref == NULL_RTX);
001c85
-		      tlocc = XEXP (XEXP (arg, 0), 1);
001c85
-		      continue;
001c85
+		      if (XEXP (XEXP (arg, 0), 0) == pc_rtx)
001c85
+			{
001c85
+			  tloc = XEXP (XEXP (arg, 0), 1);
001c85
+			  continue;
001c85
+			}
001c85
+		      else if (GET_CODE (XEXP (XEXP (arg, 0), 0)) == CLOBBER
001c85
+			       && XEXP (XEXP (XEXP (arg, 0), 0), 0) == pc_rtx)
001c85
+			{
001c85
+			  tlocc = XEXP (XEXP (arg, 0), 1);
001c85
+			  continue;
001c85
+			}
001c85
 		    }
001c85
 		  reg = NULL;
001c85
 		  if (REG_P (XEXP (XEXP (arg, 0), 0)))
001c85
@@ -20842,15 +20847,27 @@ dwarf2out_var_location (rtx loc_note)
001c85
       if (!CALL_P (prev))
001c85
 	prev = XVECEXP (PATTERN (prev), 0, 0);
001c85
       ca_loc->tail_call_p = SIBLING_CALL_P (prev);
001c85
+
001c85
+      /* Look for a SYMBOL_REF in the "prev" instruction.  */
001c85
       x = get_call_rtx_from (PATTERN (prev));
001c85
       if (x)
001c85
 	{
001c85
-	  x = XEXP (XEXP (x, 0), 0);
001c85
-	  if (GET_CODE (x) == SYMBOL_REF
001c85
-	      && SYMBOL_REF_DECL (x)
001c85
-	      && TREE_CODE (SYMBOL_REF_DECL (x)) == FUNCTION_DECL)
001c85
-	    ca_loc->symbol_ref = x;
001c85
+	  /* Try to get the call symbol, if any.  */
001c85
+	  if (MEM_P (XEXP (x, 0)))
001c85
+	    x = XEXP (x, 0);
001c85
+	  /* First, look for a memory access to a symbol_ref.  */
001c85
+	  if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
001c85
+	      && SYMBOL_REF_DECL (XEXP (x, 0))
001c85
+	      && TREE_CODE (SYMBOL_REF_DECL (XEXP (x, 0))) == FUNCTION_DECL)
001c85
+	    ca_loc->symbol_ref = XEXP (x, 0);
001c85
+	  /* Otherwise, look at a compile-time known user-level function
001c85
+	     declaration.  */
001c85
+	  else if (MEM_P (x)
001c85
+		   && MEM_EXPR (x)
001c85
+		   && TREE_CODE (MEM_EXPR (x)) == FUNCTION_DECL)
001c85
+	    ca_loc->symbol_ref = XEXP (DECL_RTL (MEM_EXPR (x)), 0);
001c85
 	}
001c85
+
001c85
       ca_loc->block = insn_scope (prev);
001c85
       if (call_arg_locations)
001c85
 	call_arg_loc_last->next = ca_loc;