Hi! gen_subprogram_die is often called more than once for the same decl (e.g. the first time through force_decl_die etc.), but it always unconditionally calls add_calling_convention_attribute which thus may add the attributes several times.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Alternatively, we could avoid the add_calling_convention_attribute call in gen_subprogram_die if subr_die == orig_die, i.e. if we have already processed the decl once, hopefully the calling conventions would be the same in all cases. 2014-02-12 Jakub Jelinek <ja...@redhat.com> PR debug/60152 * dwarf2out.c (add_calling_convention_attribute): Don't add DW_AT_main_subprogram or DW_AT_calling_convention attributes if they are already present. --- gcc/dwarf2out.c.jj 2014-01-30 20:31:19.000000000 +0100 +++ gcc/dwarf2out.c 2014-02-12 18:26:41.098486306 +0100 @@ -16873,13 +16873,15 @@ add_calling_convention_attribute (dw_die rely on the old way, which we thus keep. */ value = DW_CC_program; - if (dwarf_version >= 4 || !dwarf_strict) + if ((dwarf_version >= 4 || !dwarf_strict) + && !get_AT (subr_die, DW_AT_main_subprogram)) add_AT_flag (subr_die, DW_AT_main_subprogram, 1); } /* Only add the attribute if the backend requests it, and is not DW_CC_normal. */ - if (value && (value != DW_CC_normal)) + if (value && value != DW_CC_normal + && !get_AT (subr_die, DW_AT_calling_convention)) add_AT_unsigned (subr_die, DW_AT_calling_convention, value); } Jakub