From patchwork Fri Jun 26 10:20:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 488704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6C3B11402AE for ; Fri, 26 Jun 2015 20:22:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=habk5B2C; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=mFmt43Cg6Hd4DN19 ymyZAs5uJiIspOzrC0pC5ndg/Hp8NkrmG6dheiaomNx6q5rH55gj7lgCYVAxSQhI nnx9DMvczBxu0cgtWtbbKvIa0KjT5Xz+imqaDPpnGAbOyg54Dxhy7w1/MCIvtlT3 LYeQX5nMja7azuotv8G234eC5Yc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=XbPu8fMhC0pEoDESjGLRdx Lo5FU=; b=habk5B2C8dYzNAq11XkEFcTG0whx37dro2yptqCnGHRZlIsD/mbXSf EGE9SYP33Ae++TXEwuM1zEIUm8gUS1YnQrXZxGorvNkzEK+AFHX4+irybWHQLnsU lfod8Gzzm81Ct+14lwJ8T5ojPHQraDNprNxR/yMXH74+tLwhi2FfY= Received: (qmail 69617 invoked by alias); 26 Jun 2015 10:22:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 69603 invoked by uid 89); 26 Jun 2015 10:22:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 26 Jun 2015 10:22:02 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D31492854918 for ; Fri, 26 Jun 2015 12:21:59 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BdMP4DPMqRxp for ; Fri, 26 Jun 2015 12:21:59 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id A9E0A2854909 for ; Fri, 26 Jun 2015 12:21:59 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Defer compilation of global variables Date: Fri, 26 Jun 2015 12:20:45 +0200 Message-ID: <1619090.iXzhA1XJDm@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 In gigi we defer the generation of debug info for global types, so we need to arrange to emit (again) the debug info for global variables after that, otherwise the debug info can be incorrect. 2015-06-26 Eric Botcazou * gcc-interface/gigi.h (note_types_used_by_globals): Delete. (gnat_write_global_declarations): New prototype. * gcc-interface/utils.c (type_decls): Rename back to... (global_decls): ...this. (gnat_pushdecls): Revert previous change. (create_var_decl): Do not output global variables. (note_types_used_by_globals): Rename back to... (gnat_write_global_declarations): ...this. Output variables on the global_decls vector. * gcc-interface/misc.c (gnat_parse_file): Adjust to above renaming. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 225002) +++ gcc-interface/utils.c (working copy) @@ -218,8 +218,8 @@ static GTY((deletable)) struct gnat_bind /* The context to be used for global declarations. */ static GTY(()) tree global_context; -/* An array of global type declarations. */ -static GTY(()) vec *type_decls; +/* An array of global declarations. */ +static GTY(()) vec *global_decls; /* An array of builtin function declarations. */ static GTY(()) vec *builtin_decls; @@ -753,10 +753,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_n vec_safe_push (builtin_decls, decl); } else if (global_bindings_p ()) - { - if (TREE_CODE (decl) == TYPE_DECL) - vec_safe_push (type_decls, decl); - } + vec_safe_push (global_decls, decl); else { DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block); @@ -2439,19 +2436,13 @@ create_var_decl (tree name, tree asm_nam /* Add this decl to the current binding level. */ gnat_pushdecl (var_decl, gnat_node); - if (TREE_CODE (var_decl) == VAR_DECL) + if (TREE_CODE (var_decl) == VAR_DECL && asm_name) { - if (asm_name) - { - /* Let the target mangle the name if this isn't a verbatim asm. */ - if (*IDENTIFIER_POINTER (asm_name) != '*') - asm_name = targetm.mangle_decl_assembler_name (var_decl, asm_name); - - SET_DECL_ASSEMBLER_NAME (var_decl, asm_name); - } + /* Let the target mangle the name if this isn't a verbatim asm. */ + if (*IDENTIFIER_POINTER (asm_name) != '*') + asm_name = targetm.mangle_decl_assembler_name (var_decl, asm_name); - if (global_bindings_p ()) - rest_of_decl_compilation (var_decl, true, 0); + SET_DECL_ASSEMBLER_NAME (var_decl, asm_name); } return var_decl; @@ -5200,13 +5191,12 @@ smaller_form_type_p (tree type, tree ori return tree_int_cst_lt (size, osize) != 0; } -/* Keep track of types used at the global level and emit debug info - for all global types. */ +/* Perform final processing on global declarations. */ static GTY (()) tree dummy_global; void -note_types_used_by_globals (void) +gnat_write_global_declarations (void) { unsigned int i; tree iter; @@ -5235,13 +5225,20 @@ note_types_used_by_globals (void) } } - /* Output debug information for all global type declarations. This ensures - that global types whose compilation cannot been finalized earlier, e.g. - pointers to Taft amendment types, have their compilation finalized in - the right context. */ - FOR_EACH_VEC_SAFE_ELT (type_decls, i, iter) - if (!DECL_IGNORED_P (iter)) + /* Output debug information for all global type declarations first. This + ensures that global types whose compilation hasn't been finalized yet, + for example pointers to Taft amendment types, have their compilation + finalized in the right context. */ + FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter) + if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter)) debug_hooks->type_decl (iter, false); + + /* Then output the global variables. We need to do that after the debug + information is emitted above so that "forward" type declarations are + properly merged with their definition in the debug information. */ + FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter) + if (TREE_CODE (iter) == VAR_DECL) + rest_of_decl_compilation (iter, true, 0); } /* ************************************************************************ Index: gcc-interface/gigi.h =================================================================== --- gcc-interface/gigi.h (revision 225002) +++ gcc-interface/gigi.h (working copy) @@ -531,9 +531,8 @@ extern tree gnat_type_for_size (unsigned an unsigned type; otherwise a signed type is returned. */ extern tree gnat_type_for_mode (machine_mode mode, int unsignedp); -/* Keep track of types used at the global level and emit debug info - for all global types. */ -extern void note_types_used_by_globals (void); +/* Perform final processing on global declarations. */ +extern void gnat_write_global_declarations (void); /* Return the unsigned version of a TYPE_NODE, a scalar type. */ extern tree gnat_unsigned_type (tree type_node); Index: gcc-interface/misc.c =================================================================== --- gcc-interface/misc.c (revision 224993) +++ gcc-interface/misc.c (working copy) @@ -113,7 +113,8 @@ gnat_parse_file (void) /* Call the front end. */ _ada_gnat1drv (); - note_types_used_by_globals (); + /* Write the global declarations. */ + gnat_write_global_declarations (); } /* Return language mask for option processing. */