This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[m68k] -fomit-frame-pointer frame info broken


The m68k dwarf2 frame debug/unwind info generated with -fomit-frame-pointer is 
incorrect. m68k-elf uses dwarf2 unwinding for c++ exceptions, so it's fairly 
important to get this right.

There are two bugs in m68k_output_function_prologue

- If the function doesn't have a stack frame at all, dwarf2out_def_cfa is not 
called, so we get whatever the previous function used.
- cfa_offset was off by 4 bytes. Looks like we're still adding space for the 
frame pointer even though it's not being saved.

The attached patch fixes these.

There are other unrelated problems with -fomit-frame-pointer unwind info.  
I'll address the other problems in a subsequent patch.

Tested with cross to m68k-elf.
Ok? 

Paul

2005-12-16  Paul Brook  <paul@codesourcery.com>

	* config/m68k/m68k.md (m68k_output_function_prologue): Always call
	dwarf2out_def_cfa. Only add space for frame pointer to cfa_offset
	when frame_pointer_needed. 
Index: gcc/config/m68k/m68k.c
===================================================================
--- gcc/config/m68k/m68k.c	(revision 108242)
+++ gcc/config/m68k/m68k.c	(working copy)
@@ -557,16 +557,6 @@
 	asm_fprintf (stream, "\tlink" ASM_DOTW " %s,%I0\n"
 			     "\tadd" ASM_DOT "l %I%wd,%Rsp\n",
 		     M68K_REGNAME(FRAME_POINTER_REGNUM), -fsize_with_regs);
-
-      if (dwarf2out_do_frame ())
-	{
-	  char *l;
-          l = (char *) dwarf2out_cfi_label ();
-	  cfa_offset += 4;
-	  dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, -cfa_offset);
-	  dwarf2out_def_cfa (l, FRAME_POINTER_REGNUM, cfa_offset);
-	  cfa_offset += current_frame.size;
-	}
     }
   else if (fsize_with_regs) /* !frame_pointer_needed */
     {
@@ -600,13 +590,26 @@
 	}
       else /* fsize_with_regs >= 0x8000 */
 	asm_fprintf (stream, "\tadd" ASM_DOT "l %I%wd,%Rsp\n", -fsize_with_regs);
+    } /* !frame_pointer_needed && fsize_with_regs*/
 
-      if (dwarf2out_do_frame ())
+
+  if (dwarf2out_do_frame ())
+    {
+      if (frame_pointer_needed)
 	{
-	  cfa_offset += current_frame.size + 4;
+	  char *l;
+          l = (char *) dwarf2out_cfi_label ();
+	  cfa_offset += 4;
+	  dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, -cfa_offset);
+	  dwarf2out_def_cfa (l, FRAME_POINTER_REGNUM, cfa_offset);
+	  cfa_offset += current_frame.size;
+	}
+      else
+	{
+	  cfa_offset += current_frame.size;
 	  dwarf2out_def_cfa ("", STACK_POINTER_REGNUM, cfa_offset);
 	}
-    } /* !frame_pointer_needed */
+    }
 
   if (current_frame.fpu_mask)
     {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]