From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13924 invoked by alias); 27 Aug 2015 13:36:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13821 invoked by uid 89); 27 Aug 2015 13:36:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 27 Aug 2015 13:36:21 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 00292AE08; Thu, 27 Aug 2015 13:36:17 +0000 (UTC) Date: Thu, 27 Aug 2015 13:37:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [PATCH][C++] Avoid PCH dependent mangling Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2015-08/txt/msg01699.txt.bz2 With the passes.c hunk in the patch below we FAIL assembly comparison of g++.dg/pch/system-[12].C because with PCH we have computed DECL_ASSEMBLER_NAME and thus appended DW_AT_linkage_name early during PCH generation while without PCH we compute it lazily and end up appending DW_AT_specification earlier. Thus we have swapped dwarf attribute order and assembly comparison fails. Clearly this kind of "IL" changes dependent on whether we are writing a PCH file is going to cause differences down the food chain. (there is another case in instantiate_decl calling add_pending_template dependent on pch_file) Now a simple solution is to simply not do that (mangle decls). Another would be to always mangle decls where we now do so conditional on PCH. Another soulution is to declare we don't care about assembly differences with/without using PCH and remove assembly comparison from the testsuite harness. Bootstrapped on x86_64-unknown-linux-gnu, testing + gdb testing in progress. Ok for trunk (with note_decl_for_pch completely removed)? The passes.c hunk is needed because we otherwise miss to properly create the early DIEs for those kind of globals (we'll be left with a declaration DIE from the type DIE creation and miss the definition part). Thanks, Richard. 2015-08-27 Richard Biener * passes.c (rest_of_decl_compilation): Also call early_global_decl on global definitions in type context. cp/ * semantics.c (note_decl_for_pch): Do not mangle the decl. Index: gcc/passes.c =================================================================== --- gcc/passes.c (revision 227258) +++ gcc/passes.c (working copy) @@ -318,7 +318,15 @@ rest_of_decl_compilation (tree decl, && !decl_function_context (decl) && !current_function_decl && DECL_SOURCE_LOCATION (decl) != BUILTINS_LOCATION - && !decl_type_context (decl) + && (!decl_type_context (decl) + /* If we created a varpool node for the decl make sure to + call early_global_decl. Otherwise we miss changes + introduced by member definitions like + struct A { static int staticdatamember; }; + int A::staticdatamember; + and thus have incomplete early debug. */ + || (TREE_CODE (decl) == VAR_DECL + && TREE_STATIC (decl) && !DECL_EXTERNAL (decl))) /* Avoid confusing the debug information machinery when there are errors. */ && !seen_error ()) Index: gcc/cp/semantics.c =================================================================== --- gcc/cp/semantics.c (revision 227258) +++ gcc/cp/semantics.c (working copy) @@ -2962,15 +2962,21 @@ finish_member_declaration (tree decl) translation units which include the PCH file. */ void -note_decl_for_pch (tree decl) +note_decl_for_pch (tree) { gcc_assert (pch_file); + /* ??? This changes debug info with/without PCH as DW_AT_linkage_name + attributes are added at different times (early when with PCH + or late, via pending assembler names, when without PCH). + See g++.dg/pch/system-[12].C. */ +#if 0 /* There's a good chance that we'll have to mangle names at some point, even if only for emission in debugging information. */ if (VAR_OR_FUNCTION_DECL_P (decl) && !processing_template_decl) mangle_decl (decl); +#endif } /* Finish processing a complete template declaration. The PARMS are