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]

[PATCH, DWARF] re-init dw_frame_pointer_regnum between functions


Hello,

ARM and Thumb modes use different hard_frame_pointer_regnum ABIs. The
problem is that dwarf2cfi.c:dw_frame_pointer_regnum cache is initialized
only once per file, when creating the CIE. 
While testing the ARM attribute target to switch modes between
functions, I got a few assertion with -g, because this value gets
inconsistent with the respective FDEs that have different
hard_frame_pointer_rtx...

The snippet from dwarf2cfi.c illustrates the potential issue with the
mismatch between hard_frame_pointer_rtx and a badly set CFA register :

 if (dest == hard_frame_pointer_rtx)
   ...
          cur_cfa->reg = dw_frame_pointer_regnum;
  ...

I'm not aware of other targets giving the possibility to change the
frame_pointer_regnum ABI in a file, so the issue will only be show up
with the ARM target attribute. However I'd like very much your feedback
on this change, before I can send the remaining ARM parts.

Tested manually for arm-none-eabi with gdb, unwinding and frame access
seem OK when mixing modes.
x86 bootstrapped and regressions tests are running.

Many thanks,

Christian





2014-09-23  Christian Bruel  <christian.bruel@st.com>

	* execute_dwarf2_frame (dw_frame_pointer_regnum): Reinitialize for each function.

Index: dwarf2cfi.c
===================================================================
--- dwarf2cfi.c	(revision 216146)
+++ dwarf2cfi.c	(working copy)
@@ -2860,7 +2860,6 @@
   dw_trace_info cie_trace;
 
   dw_stack_pointer_regnum = DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM);
-  dw_frame_pointer_regnum = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM);
 
   memset (&cie_trace, 0, sizeof (cie_trace));
   cur_trace = &cie_trace;
@@ -2913,6 +2912,9 @@
 static unsigned int
 execute_dwarf2_frame (void)
 {
+  /* Different HARD_FRAME_POINTER_REGNUM might coexist in the same file.  */
+  dw_frame_pointer_regnum = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM);
+
   /* The first time we're called, compute the incoming frame state.  */
   if (cie_cfi_vec == NULL)
     create_cie_data ();

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