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 <ja...@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. --- 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); Jakub