diff mbox

Fix -fno-dwarf2-cfi-asm bootstrap (PR bootstrap/50010)

Message ID 20110912151306.GF2687@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Sept. 12, 2011, 3:13 p.m. UTC
Hi!

dwarf2cfi.c generates sometimes different .eh_frame with/without
-fvar-tracking-assignments.  The problem is that in add_cfis_to_fde
when adding NOTE_INSN_CFI_LABEL notes there is a scan to find consecutive
NOTE_INSN_CFI notes, but if there are any var-tracking notes in between,
more labels are emitted.  And apparently the assembler doesn't optimize
zero length DW_CFA_advance_loc* ops away.
While only skipping NOTE_INSN_VAR_LOCATION and NOTE_INSN_CALL_ARG_LOCATION
would be enough to fix the comparison failures, I think we can skip any
non-active_insn_p's (except for NOTE_INSN_SWTICH_TEXT_SECTION which we need
to handle earlier in the loop).

Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested
with bootstrap/regtest on i586-linux with -fno-dwarf2-asm-cfi in *C*FLAGS
during bootstrapping (which before this patch failed for me).
Ok for trunk?

2011-09-12  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/50010
	* dwarf2cfi.c (add_cfis_to_fde): Ignore non-active insns in between
	NOTE_INSN_CFI notes, with the exception of
	NOTE_INSN_SWITCH_TEXT_SECTIONS.


	Jakub

Comments

Bernd Schmidt Sept. 12, 2011, 7:16 p.m. UTC | #1
On 09/12/11 17:13, Jakub Jelinek wrote:
> dwarf2cfi.c generates sometimes different .eh_frame with/without
> -fvar-tracking-assignments.  The problem is that in add_cfis_to_fde
> when adding NOTE_INSN_CFI_LABEL notes there is a scan to find consecutive
> NOTE_INSN_CFI notes, but if there are any var-tracking notes in between,
> more labels are emitted.  And apparently the assembler doesn't optimize
> zero length DW_CFA_advance_loc* ops away.
> While only skipping NOTE_INSN_VAR_LOCATION and NOTE_INSN_CALL_ARG_LOCATION
> would be enough to fix the comparison failures, I think we can skip any
> non-active_insn_p's (except for NOTE_INSN_SWTICH_TEXT_SECTION which we need
> to handle earlier in the loop).

> 2011-09-12  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR bootstrap/50010
> 	* dwarf2cfi.c (add_cfis_to_fde): Ignore non-active insns in between
> 	NOTE_INSN_CFI notes, with the exception of
> 	NOTE_INSN_SWITCH_TEXT_SECTIONS.

Ok.


Bernd
diff mbox

Patch

--- gcc/dwarf2cfi.c.jj	2011-08-22 08:17:08.000000000 +0200
+++ gcc/dwarf2cfi.c	2011-09-12 10:32:46.000000000 +0200
@@ -2153,11 +2153,18 @@  add_cfis_to_fde (void)
       if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_CFI)
 	{
 	  bool required = cfi_label_required_p (NOTE_CFI (insn));
-	  while (next && NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_CFI)
-	    {
-	      required |= cfi_label_required_p (NOTE_CFI (next));
+	  while (next)
+	    if (NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_CFI)
+	      {
+		required |= cfi_label_required_p (NOTE_CFI (next));
+		next = NEXT_INSN (next);
+	      }
+	    else if (active_insn_p (next)
+		     || (NOTE_P (next) && (NOTE_KIND (next)
+					   == NOTE_INSN_SWITCH_TEXT_SECTIONS)))
+	      break;
+	    else
 	      next = NEXT_INSN (next);
-	    }
 	  if (required)
 	    {
 	      int num = dwarf2out_cfi_label_num;
@@ -2178,7 +2185,9 @@  add_cfis_to_fde (void)
 
 	  do
 	    {
-	      VEC_safe_push (dw_cfi_ref, gc, fde->dw_fde_cfi, NOTE_CFI (insn));
+	      if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_CFI)
+		VEC_safe_push (dw_cfi_ref, gc, fde->dw_fde_cfi,
+			       NOTE_CFI (insn));
 	      insn = NEXT_INSN (insn);
 	    }
 	  while (insn != next);