Have libgcc builtins honour DWARF2_FRAME_REG_OUT

Geoffrey Keating gkeating@apple.com
Wed Mar 8 00:02:00 GMT 2006


After my previous patch

2006-02-21  Geoffrey Keating  <geoffk@apple.com>

	* config/i386/darwin.h (DWARF2_FRAME_REG_OUT): New.

libgcc broke.  The symptom was 'install a libgcc built with DWARF on
by default and then Mail.app crashes on open with an unhelpful
backtrace'.

I think this was the problem.  At least, with this patch the built
libgcc is almost identical whether or not DBX_REGISTER_NUMBER and
DWARF2_FRAME_REG_OUT test write_symbols.  'Almost' because
expand_builtin_init_dwarf_reg_sizes gives the flag register a size
when built with DWARF with this change.

Bootstrapped & tested on x86-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-dwarf-4466819.patch===================
2006-03-07  Geoffrey Keating  <geoffk@apple.com>

	* dwarf2out.c (DWARF2_FRAME_REG_OUT): Move up in file.
	(expand_builtin_dwarf_sp_column): Call DWARF2_FRAME_REG_OUT.
	(expand_builtin_init_dwarf_reg_sizes): Likewise.

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 111700)
+++ dwarf2out.c	(working copy)
@@ -99,6 +99,13 @@
 # endif
 #endif
 
+/* Map register numbers held in the call frame info that gcc has
+   collected using DWARF_FRAME_REGNUM to those that should be output in
+   .debug_frame and .eh_frame.  */
+#ifndef DWARF2_FRAME_REG_OUT
+#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) (REGNO)
+#endif
+
 /* Decide whether we want to emit frame unwind information for the current
    translation unit.  */
 
@@ -404,7 +411,8 @@
 rtx
 expand_builtin_dwarf_sp_column (void)
 {
-  return GEN_INT (DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM));
+  int dwarf_regnum = DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM);
+  return GEN_INT (DWARF2_FRAME_REG_OUT (dwarf_regnum, 1));
 }
 
 /* Return a pointer to a copy of the section string name S with all
@@ -437,28 +445,32 @@
   bool wrote_return_column = false;
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-    if (DWARF_FRAME_REGNUM (i) < DWARF_FRAME_REGISTERS)
-      {
-	HOST_WIDE_INT offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
-	enum machine_mode save_mode = reg_raw_mode[i];
-	HOST_WIDE_INT size;
+    {
+      int rnum = DWARF2_FRAME_REG_OUT (DWARF_FRAME_REGNUM (i), 1);
+      
+      if (rnum < DWARF_FRAME_REGISTERS)
+	{
+	  HOST_WIDE_INT offset = rnum * GET_MODE_SIZE (mode);
+	  enum machine_mode save_mode = reg_raw_mode[i];
+	  HOST_WIDE_INT size;
+	  
+	  if (HARD_REGNO_CALL_PART_CLOBBERED (i, save_mode))
+	    save_mode = choose_hard_reg_mode (i, 1, true);
+	  if (DWARF_FRAME_REGNUM (i) == DWARF_FRAME_RETURN_COLUMN)
+	    {
+	      if (save_mode == VOIDmode)
+		continue;
+	      wrote_return_column = true;
+	    }
+	  size = GET_MODE_SIZE (save_mode);
+	  if (offset < 0)
+	    continue;
+	  
+	  emit_move_insn (adjust_address (mem, mode, offset),
+			  gen_int_mode (size, mode));
+	}
+    }
 
-	if (HARD_REGNO_CALL_PART_CLOBBERED (i, save_mode))
-	  save_mode = choose_hard_reg_mode (i, 1, true);
-	if (DWARF_FRAME_REGNUM (i) == DWARF_FRAME_RETURN_COLUMN)
-	  {
-	    if (save_mode == VOIDmode)
-	      continue;
-	    wrote_return_column = true;
-	  }
-	size = GET_MODE_SIZE (save_mode);
-	if (offset < 0)
-	  continue;
-
-	emit_move_insn (adjust_address (mem, mode, offset),
-			gen_int_mode (size, mode));
-      }
-
 #ifdef DWARF_ALT_FRAME_RETURN_COLUMN
   gcc_assert (wrote_return_column);
   i = DWARF_ALT_FRAME_RETURN_COLUMN;
@@ -2011,13 +2023,6 @@
     }
 }
 
-/* Map register numbers held in the call frame info that gcc has
-   collected using DWARF_FRAME_REGNUM to those that should be output in
-   .debug_frame and .eh_frame.  */
-#ifndef DWARF2_FRAME_REG_OUT
-#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) (REGNO)
-#endif
-
 /* Output a Call Frame Information opcode and its operand(s).  */
 
 static void
============================================================



More information about the Gcc-patches mailing list