From patchwork Fri Jan 12 08:33:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 859578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-470937-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SMyLs/U0"; dkim-atps=neutral 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 3zHwyT1FTsz9sBW for ; Fri, 12 Jan 2018 19:34:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=MqJtGwboU4pMc3X05+OzWSkvrt9688XU9ungdMKH5H90rwHeKx JfAdFDqfL2/wabx6nBd5l6aZyGQv/v6FQFZh3mrHYmZiJx96rbQaliJ1d8RpRdn9 6SY2DACmiCRjqLgib2E5yjGHOvjzsx0kqRAMuKQcNaI5dfvMPW9sI2egM= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=+gtFkOMupgNzXJ7mMSJu6Ikxpm4=; b=SMyLs/U0w3fxQIoYbz5V F4RYrEk2RNg68RjLgET0Iw0fOw/8xJXy1s92vqmgIGMuH18ZNSB2DNuR67PGnp06 ICPIjwy9cA1eho0fzb+URgtBQWKWGQkvmGgifOwYbjO9m84gzmtqSgna7G02h4xS IpIizWYU5SOArTM0vQemV+I= Received: (qmail 83346 invoked by alias); 12 Jan 2018 08:33:58 -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 81863 invoked by uid 89); 12 Jan 2018 08:33:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=shed, held 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 ESMTP; Fri, 12 Jan 2018 08:33:55 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 404A2ACD5; Fri, 12 Jan 2018 08:33:53 +0000 (UTC) Date: Fri, 12 Jan 2018 09:33:52 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] Trivial free-lang-data adjustments for early LTO debug Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 It's now no longer necessary to preserve type related stuff for debug reasons so the following forgos with streaming TYPE_DECLs in TYPE_FIELDS, TYPE_DECLs for TYPE_NAME (where not necessary) and also BINFOs when not needed for devirtualization. I noticed the unpatched code if (TYPE_BINFO (type)) { free_lang_data_in_binfo (TYPE_BINFO (type)); /* We need to preserve link to bases and virtual table for all polymorphic types to make devirtualization machinery working. Debug output cares only about bases, but output also virtual table pointers so merging of -fdevirtualize and -fno-devirtualize units is easier. */ if ((!BINFO_VTABLE (TYPE_BINFO (type)) || !flag_devirtualize) && ((!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)) && !BINFO_VTABLE (TYPE_BINFO (type))) || debug_info_level != DINFO_LEVEL_NONE)) TYPE_BINFO (type) = NULL; } where the condition && ((!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)) && !BINFO_VTABLE (TYPE_BINFO (type))) || debug_info_level != DINFO_LEVEL_NONE)) makes no sense to me -- it implies that when -g is enabled we'll clear TYPE_BINFO but not with -g0 unless (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)) && !BINFO_VTABLE (TYPE_BINFO (type)). I concluded this second condition is basically dead code (and at most prevented BINFO related debug for LTO), so I dropped it as well as the comment talking about the merging of -fdevirtualize vs. -fno-devirtualize. If I'd just remove the debug_info_level condition we'd end up with if (!BINFO_VTABLE (TYPE_BINFO (type)) && !BINFO_N_BASE_BINFOS (TYPE_BINFO (type))) TYPE_BINFO (type) = NULL; which is not -fdevirtualize conditional anymore. Honza - can you shed light on the original intent? LTO bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Thanks, Richard. 2018-01-11 Richard Biener * tree.c (free_lang_data_in_type): Always unlink TYPE_DECLs from TYPE_FIELDS. Free TYPE_BINFO if not used by devirtualization. Reset type names to their identifier if their TYPE_DECL doesn't have linkage (and thus is used for ODR and devirt). (save_debug_info_for_decl): Remove. (save_debug_info_for_type): Likewise. (add_tree_to_fld_list): Adjust. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 256562) +++ gcc/tree.c (working copy) @@ -5127,15 +5127,10 @@ free_lang_data_in_type (tree type) TREE_PURPOSE (p) = NULL; else if (RECORD_OR_UNION_TYPE_P (type)) { - /* Remove members that are not FIELD_DECLs (and maybe - TYPE_DECLs) from the field list of an aggregate. These occur - in C++. */ + /* Remove members that are not FIELD_DECLs from the field list + of an aggregate. These occur in C++. */ for (tree *prev = &TYPE_FIELDS (type), member; (member = *prev);) - if (TREE_CODE (member) == FIELD_DECL - || (TREE_CODE (member) == TYPE_DECL - && !DECL_IGNORED_P (member) - && debug_info_level > DINFO_LEVEL_TERSE - && !is_redundant_typedef (member))) + if (TREE_CODE (member) == FIELD_DECL) prev = &DECL_CHAIN (member); else *prev = DECL_CHAIN (member); @@ -5149,15 +5144,9 @@ free_lang_data_in_type (tree type) { free_lang_data_in_binfo (TYPE_BINFO (type)); /* We need to preserve link to bases and virtual table for all - polymorphic types to make devirtualization machinery working. - Debug output cares only about bases, but output also - virtual table pointers so merging of -fdevirtualize and - -fno-devirtualize units is easier. */ - if ((!BINFO_VTABLE (TYPE_BINFO (type)) - || !flag_devirtualize) - && ((!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)) - && !BINFO_VTABLE (TYPE_BINFO (type))) - || debug_info_level != DINFO_LEVEL_NONE)) + polymorphic types to make devirtualization machinery working. */ + if (!BINFO_VTABLE (TYPE_BINFO (type)) + || !flag_devirtualize) TYPE_BINFO (type) = NULL; } } @@ -5185,6 +5174,11 @@ free_lang_data_in_type (tree type) while (ctx && TREE_CODE (ctx) == BLOCK); TYPE_CONTEXT (type) = ctx; } + + /* Drop TYPE_DECLs in TYPE_NAME in favor of the identifier in the + TYPE_DECL if the type doesn't have linkage. */ + if (! type_with_linkage_p (type)) + TYPE_NAME (type) = TYPE_IDENTIFIER (type); } @@ -5407,34 +5401,6 @@ struct free_lang_data_d }; -/* Save all language fields needed to generate proper debug information - for DECL. This saves most fields cleared out by free_lang_data_in_decl. */ - -static void -save_debug_info_for_decl (tree t) -{ - /*struct saved_debug_info_d *sdi;*/ - - gcc_assert (debug_info_level > DINFO_LEVEL_TERSE && t && DECL_P (t)); - - /* FIXME. Partial implementation for saving debug info removed. */ -} - - -/* Save all language fields needed to generate proper debug information - for TYPE. This saves most fields cleared out by free_lang_data_in_type. */ - -static void -save_debug_info_for_type (tree t) -{ - /*struct saved_debug_info_d *sdi;*/ - - gcc_assert (debug_info_level > DINFO_LEVEL_TERSE && t && TYPE_P (t)); - - /* FIXME. Partial implementation for saving debug info removed. */ -} - - /* Add type or decl T to one of the list of tree nodes that need their language data removed. The lists are held inside FLD. */ @@ -5442,17 +5408,9 @@ static void add_tree_to_fld_list (tree t, struct free_lang_data_d *fld) { if (DECL_P (t)) - { - fld->decls.safe_push (t); - if (debug_info_level > DINFO_LEVEL_TERSE) - save_debug_info_for_decl (t); - } + fld->decls.safe_push (t); else if (TYPE_P (t)) - { - fld->types.safe_push (t); - if (debug_info_level > DINFO_LEVEL_TERSE) - save_debug_info_for_type (t); - } + fld->types.safe_push (t); else gcc_unreachable (); }