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] Avoid useless DW_CFA_advance_loc* after DW_CFA_remember_state


On Thu, Jun 04, 2009 at 12:11:30PM +0200, Jakub Jelinek wrote:
> OT, for all architectures IMHO dwarf2out.c should move .cfi_remember_state
> note from NOTE_INSN_EPILOGUE_BEG down to the first insn in the epilogue
> that actually has any CFI emitted, that way we'll get rid of an unnecessary
> DW_CFA_advance_loc*.  Of course DW_CFA_remember_state has to be the first
> op emitted after that instruction in that case.

Here is a patch that implements it, ok for trunk?

2009-06-08  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (emit_cfa_remember): New variable.
	(add_fde_cfi): If emit_cfa_remember, recurse to add
	DW_CFA_remember_state first.
	(dwarf2out_begin_epilogue): Don't add_fde_cfi DW_CFA_remember_state,
	instead just set emit_cfa_remember.

--- gcc/dwarf2out.c.jj	2009-06-08 09:41:46.000000000 +0200
+++ gcc/dwarf2out.c	2009-06-08 09:57:52.000000000 +0200
@@ -717,13 +717,29 @@ dwarf2out_cfi_label (bool force)
   return label;
 }
 
+/* True if remember_state should be emitted before following CFI directive.  */
+static bool emit_cfa_remember;
+
 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
    or to the CIE if LABEL is NULL.  */
 
 static void
 add_fde_cfi (const char *label, dw_cfi_ref cfi)
 {
-  dw_cfi_ref *list_head = &cie_cfi_head;
+  dw_cfi_ref *list_head;
+
+  if (emit_cfa_remember)
+    {
+      dw_cfi_ref cfi_remember;
+
+      /* Emit the state save.  */
+      emit_cfa_remember = false;
+      cfi_remember = new_cfi (); 
+      cfi_remember->dw_cfi_opc = DW_CFA_remember_state;
+      add_fde_cfi (label, cfi_remember);
+    }
+
+  list_head = &cie_cfi_head;
 
   if (dwarf2out_do_cfi_asm ())
     {
@@ -2755,10 +2771,7 @@ dwarf2out_begin_epilogue (rtx insn)
     }
   emit_note_before (NOTE_INSN_CFA_RESTORE_STATE, i);
 
-  /* Emit the state save.  */
-  cfi = new_cfi (); 
-  cfi->dw_cfi_opc = DW_CFA_remember_state;
-  add_fde_cfi (dwarf2out_cfi_label (false), cfi);
+  emit_cfa_remember = true;
 
   /* And emulate the state save.  */
   gcc_assert (!cfa_remember.in_use);

	Jakub


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