From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6AED23851C0B; Mon, 24 Aug 2020 11:51:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AED23851C0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598269891; bh=ZGU4BAZsRCdNIKYrNerbCrRiRYh0GNwLEBlJ7nryfyM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h1IoMu7tOt183nlzbtHjSnjgDiF2SAZYA6u4REzTPohWrRMTAIjqo7gWh+40L3WpI OoPTvL+zLnmoX9f52c2HU2oiiQDZ47E84SvvIpuEnteO5TbBNSkerQaE2wihiNcbS0 jnJCHDy0oXUsymYItZbjxpGAHOsXZirxJbDaYpqg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/96690] [10/11 Regression] ICE in write_type since r10-6087 Date: Mon, 24 Aug 2020 11:51:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 11:51:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96690 --- Comment #5 from Richard Biener --- Forcing the mangling via generating garbage RTL early doesn't work since the /* ??? The C++ FE emits debug information for using decls, so putting gcc_unreachable here falls over. See PR31899. For now be conservative. */ else if (!symtab->global_info_ready && VAR_OR_FUNCTION_DECL_P (*tp)) return *tp; check in reference_to_unused triggers during the early debug pass over template params and thus no RTL is generated from there. But the late pass looks phishy: else if (TREE_CODE (*tp) =3D=3D FUNCTION_DECL && (!DECL_EXTERNAL (*tp) || DECL_DECLARED_INLINE_P (*tp))) { /* The call graph machinery must have finished analyzing, optimizing and gimplifying the CU by now. So if *TP has no call graph node associated to it, it means *TP will not be emitted. */ if (!cgraph_node::get (*tp)) return *tp; but 'foo' is DECL_EXTERNAL and TREE_PUBLIC. The following works on this testcase though: diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 9deca031fc2..29e011a296d 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19756,7 +19785,7 @@ reference_to_unused (tree * tp, int * walk_subtrees, /* ??? The C++ FE emits debug information for using decls, so putting gcc_unreachable here falls over. See PR31899. For now be conservative. */ - else if (!symtab->global_info_ready && VAR_OR_FUNCTION_DECL_P (*tp)) + else if (!symtab->global_info_ready && VAR_P (*tp)) return *tp; else if (VAR_P (*tp)) { @@ -19771,7 +19800,7 @@ reference_to_unused (tree * tp, int * walk_subtrees, optimizing and gimplifying the CU by now. So if *TP has no call graph node associated to it, it means *TP will not be emitted. */ - if (!cgraph_node::get (*tp)) + if (!symtab->global_info_ready || !cgraph_node::get (*tp)) return *tp; } else if (TREE_CODE (*tp) =3D=3D STRING_CST && !TREE_ASM_WRITTEN (*tp)) @@ -20295,12 +20324,11 @@ tree_add_const_value_attribute (dw_die_ref die, t= ree t) return true; } } - if (! early_dwarf) - { - rtl =3D rtl_for_decl_init (init, type); - if (rtl) - return add_const_value_attribute (die, rtl); - } + /* Generate the RTL even if early_dwarf to force mangling of all refered= to + symbols. */ + rtl =3D rtl_for_decl_init (init, type); + if (rtl && !early_dwarf) + return add_const_value_attribute (die, rtl); /* If the host and target are sane, try harder. */ if (CHAR_BIT =3D=3D 8 && BITS_PER_UNIT =3D=3D 8 && initializer_constant_valid_p (init, type))=