Blame SOURCES/gcc34-dwarf2-usefbreg.patch

6fdc0f
2005-08-10  Jakub Jelinek  <jakub@redhat.com>
6fdc0f
6fdc0f
	* dwarf2out.c (concat_loc_descriptor): Add can_use_fbreg argument,
6fdc0f
	pass it down to loc_descriptor.
6fdc0f
	(loc_descriptor): Pass can_use_fbreg to concat_loc_descriptor.
6fdc0f
	(containing_function_has_frame_base): Move earlier in the file.
6fdc0f
	(loc_descriptor_from_tree_1): Use containing_function_has_frame_base
6fdc0f
	instead of always assuming fbreg can't be used.
6fdc0f
6fdc0f
--- gcc/dwarf2out.c.orig	2005-09-22 17:13:19.000000000 -0300
6fdc0f
+++ gcc/dwarf2out.c	2005-11-15 20:26:07.000000000 -0200
6fdc0f
@@ -3755,7 +3755,7 @@
6fdc0f
 static dw_loc_descr_ref based_loc_descr (unsigned, HOST_WIDE_INT, bool);
6fdc0f
 static int is_based_loc (rtx);
6fdc0f
 static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode, bool);
6fdc0f
-static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
6fdc0f
+static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx, bool);
6fdc0f
 static dw_loc_descr_ref loc_descriptor (rtx, bool);
6fdc0f
 static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
6fdc0f
 static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
6fdc0f
@@ -8562,11 +8562,11 @@
6fdc0f
    This is typically a complex variable.  */
6fdc0f
 
6fdc0f
 static dw_loc_descr_ref
6fdc0f
-concat_loc_descriptor (rtx x0, rtx x1)
6fdc0f
+concat_loc_descriptor (rtx x0, rtx x1, bool can_use_fbreg)
6fdc0f
 {
6fdc0f
   dw_loc_descr_ref cc_loc_result = NULL;
6fdc0f
-  dw_loc_descr_ref x0_ref = loc_descriptor (x0, true);
6fdc0f
-  dw_loc_descr_ref x1_ref = loc_descriptor (x1, true);
6fdc0f
+  dw_loc_descr_ref x0_ref = loc_descriptor (x0, can_use_fbreg);
6fdc0f
+  dw_loc_descr_ref x1_ref = loc_descriptor (x1, can_use_fbreg);
6fdc0f
 
6fdc0f
   if (x0_ref == 0 || x1_ref == 0)
6fdc0f
     return 0;
6fdc0f
@@ -8580,6 +8580,29 @@
6fdc0f
   return cc_loc_result;
6fdc0f
 }
6fdc0f
 
6fdc0f
+/* Return true if DECL's containing function has a frame base attribute.
6fdc0f
+   Return false otherwise.  */
6fdc0f
+
6fdc0f
+static bool
6fdc0f
+containing_function_has_frame_base (tree decl)
6fdc0f
+{
6fdc0f
+  tree declcontext = decl_function_context (decl);
6fdc0f
+  dw_die_ref context;
6fdc0f
+  dw_attr_ref attr;
6fdc0f
+
6fdc0f
+  if (!declcontext)
6fdc0f
+    return false;
6fdc0f
+
6fdc0f
+  context = lookup_decl_die (declcontext);
6fdc0f
+  if (!context)
6fdc0f
+    return false;
6fdc0f
+
6fdc0f
+  for (attr = context->die_attr; attr; attr = attr->dw_attr_next)
6fdc0f
+    if (attr->dw_attr == DW_AT_frame_base)
6fdc0f
+      return true;
6fdc0f
+  return false;
6fdc0f
+}
6fdc0f
+
6fdc0f
 /* Output a proper Dwarf location descriptor for a variable or parameter
6fdc0f
    which is either allocated in a register or in a memory location.  For a
6fdc0f
    register, we just generate an OP_REG and the register number.  For a
6fdc0f
@@ -8615,7 +8638,8 @@
6fdc0f
       break;
6fdc0f
 
6fdc0f
     case CONCAT:
6fdc0f
-      loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1));
6fdc0f
+      loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1),
6fdc0f
+					  can_use_fbreg);
6fdc0f
       break;
6fdc0f
 
6fdc0f
     case VAR_LOCATION:
6fdc0f
@@ -8765,6 +8789,7 @@
6fdc0f
 	else
6fdc0f
 	  {
6fdc0f
 	    enum machine_mode mode = GET_MODE (rtl);
6fdc0f
+	    bool can_use_fb = containing_function_has_frame_base (loc);
6fdc0f
 
6fdc0f
 	    if (GET_CODE (rtl) == MEM)
6fdc0f
 	      {
6fdc0f
@@ -8772,7 +8797,7 @@
6fdc0f
 		rtl = XEXP (rtl, 0);
6fdc0f
 	      }
6fdc0f
 
6fdc0f
-	    ret = mem_loc_descriptor (rtl, mode, true);
6fdc0f
+	    ret = mem_loc_descriptor (rtl, mode, can_use_fb);
6fdc0f
 	  }
6fdc0f
       }
6fdc0f
       break;
6fdc0f
@@ -8847,16 +8872,18 @@
6fdc0f
 	/* Get an RTL for this, if something has been emitted.  */
6fdc0f
 	rtx rtl = lookup_constant_def (loc);
6fdc0f
 	enum machine_mode mode;
6fdc0f
+	bool can_use_fb;
6fdc0f
 
6fdc0f
 	if (GET_CODE (rtl) != MEM)
6fdc0f
 	  return 0;
6fdc0f
+	can_use_fb = containing_function_has_frame_base (loc);
6fdc0f
 	mode = GET_MODE (rtl);
6fdc0f
 	rtl = XEXP (rtl, 0);
6fdc0f
 
6fdc0f
 	rtl = (*targetm.delegitimize_address) (rtl);
6fdc0f
 
6fdc0f
 	indirect_p = 1;
6fdc0f
-	ret = mem_loc_descriptor (rtl, mode, true);
6fdc0f
+	ret = mem_loc_descriptor (rtl, mode, can_use_fb);
6fdc0f
 	break;
6fdc0f
       }
6fdc0f