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]

Fix unnecessary _sf dwarf opcodes


I noticed while examining some cross-compiler output,
which wasn't relying on assembler unwind opcodes, that
we were emitting the signed variants of DW_CFA_offset
and so forth.

Fixed thus.


r~
--- ChangeLog	(revision 148420)
+++ ChangeLog	(revision 148422)
@@ -1,3 +1,11 @@
+2009-06-11  Richard Henderson  <rth@redhat.com>
+
+	* dwarf2out.c (def_cfa_1): Likewise for DW_CFA_cfa_offset.
+
+	* dwarf2out.c (need_data_align_sf_opcode): New.
+	(div_data_align): Move earlier.
+	(def_cfa_1, reg_save): Use it.
+
 2009-06-11  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* config/i386/i386.c (OPTION_MASK_ISA_CRC32_SET): New.
--- dwarf2out.c	(revision 148420)
+++ dwarf2out.c	(revision 148422)
@@ -522,6 +522,25 @@ init_return_column_size (enum machine_mo
   emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
 }
 
+/* Divide OFF by DWARF_CIE_DATA_ALIGNMENT, asserting no remainder.  */
+
+static inline HOST_WIDE_INT
+div_data_align (HOST_WIDE_INT off)
+{
+  HOST_WIDE_INT r = off / DWARF_CIE_DATA_ALIGNMENT;
+  gcc_assert (r * DWARF_CIE_DATA_ALIGNMENT == off);
+  return r;
+}
+
+/* Return true if we need a signed version of a given opcode
+   (e.g. DW_CFA_offset_extended_sf vs DW_CFA_offset_extended).  */
+
+static inline bool
+need_data_align_sf_opcode (HOST_WIDE_INT off)
+{
+  return DWARF_CIE_DATA_ALIGNMENT < 0 ? off > 0 : off < 0;
+}
+
 /* Generate code to initialize the register size table.  */
 
 void
@@ -973,7 +992,7 @@ def_cfa_1 (const char *label, dw_cfa_loc
 	 the CFA register did not change but the offset did.  The data 
 	 factoring for DW_CFA_def_cfa_offset_sf happens in output_cfi, or
 	 in the assembler via the .cfi_def_cfa_offset directive.  */
-      if (loc.offset < 0)
+      if (need_data_align_sf_opcode (loc.offset))
 	cfi->dw_cfi_opc = DW_CFA_def_cfa_offset_sf;
       else
 	cfi->dw_cfi_opc = DW_CFA_def_cfa_offset;
@@ -1000,7 +1019,7 @@ def_cfa_1 (const char *label, dw_cfa_loc
 	 the specified offset.  The data factoring for DW_CFA_def_cfa_sf
 	 happens in output_cfi, or in the assembler via the .cfi_def_cfa
 	 directive.  */
-      if (loc.offset < 0)
+      if (need_data_align_sf_opcode (loc.offset))
 	cfi->dw_cfi_opc = DW_CFA_def_cfa_sf;
       else
 	cfi->dw_cfi_opc = DW_CFA_def_cfa;
@@ -1048,7 +1067,7 @@ reg_save (const char *label, unsigned in
     }
   else if (sreg == INVALID_REGNUM)
     {
-      if (offset < 0)
+      if (need_data_align_sf_opcode (offset))
 	cfi->dw_cfi_opc = DW_CFA_offset_extended_sf;
       else if (reg & ~0x3f)
 	cfi->dw_cfi_opc = DW_CFA_offset_extended;
@@ -2926,16 +2945,6 @@ switch_to_eh_frame_section (void)
     }
 }
 
-/* Divide OFF by DWARF_CIE_DATA_ALIGNMENT, asserting no remainder.  */
-
-static HOST_WIDE_INT
-div_data_align (HOST_WIDE_INT off)
-{
-  HOST_WIDE_INT r = off / DWARF_CIE_DATA_ALIGNMENT;
-  gcc_assert (r * DWARF_CIE_DATA_ALIGNMENT == off);
-  return r;
-}
-
 /* Output a Call Frame Information opcode and its operand(s).  */
 
 static void

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