From patchwork Wed Jun 26 11:08:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1122682 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-503789-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vkrvTsr1"; 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 45YgJ861GHz9sLt for ; Wed, 26 Jun 2019 21:08:40 +1000 (AEST) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=lwCXVjC86c70H+qQV4RgO9Bie0c9/5AeTHxGqLbjtGMZYH141D6N4 NW07Rwd/a3P6o0Oro9E8NQmGq51uV29BjVQVE6YYE/janoD4Uiyp+Bbn2AX668jg leKig+7sVMad/ax/1wGHScJeWc9R0rRvl2ZOkA2jB6VaqfKsS6BMfk= 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:subject:message-id:mime-version:content-type; s= default; bh=hD4ZPnZ1vZio3QzMzIg76Kyeb9c=; b=vkrvTsr1fJp3K+1TLONC jlhquEvZzNJEeApJCY4xbvleWeGaR3+mGTpjsskw2pC2Ol8iJeb4vdrur9ndbLf/ qneidEtQSgG8yvTsJL1Uz86/GvcMhNaFtnXon7JSwBzhSchpxBi4edRWKXuiBs3Q mhDqn5ZCx6bD2hnUGUMfp/I= Received: (qmail 24951 invoked by alias); 26 Jun 2019 11:08:33 -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 24938 invoked by uid 89); 26 Jun 2019 11:08:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:lto-str, UD:lto-streamer-out.c, streaming, sk:ltostr X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Jun 2019 11:08:31 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 309EFAD78 for ; Wed, 26 Jun 2019 11:08:29 +0000 (UTC) Date: Wed, 26 Jun 2019 13:08:29 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Kill lto_bitmap_alloc/free Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This removes another global obstack and adjusts the single user, fixing inconsitent freeing on the way. Bootstrapped/tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-06-26 Richard Biener * lto-streamer.h (lto_bitmap_alloc): Remove. (lto_bitmap_free): Likewise. * lto-streamer.c (lto_bitmap_alloc): Remove. (lto_bitmap_free): Likewise. (lto_obstack): Likewise. (lto_obstack_initialized): Likewise. * lto-streamer-out.c (lto_output): Use own obstack for local bitmap, free it consistently. Index: gcc/lto-streamer.c =================================================================== --- gcc/lto-streamer.c (revision 272636) +++ gcc/lto-streamer.c (working copy) @@ -35,11 +35,6 @@ along with GCC; see the file COPYING3. /* Statistics gathered during LTO, WPA and LTRANS. */ struct lto_stats_d lto_stats; -/* LTO uses bitmaps with different life-times. So use a separate - obstack for all LTO bitmaps. */ -static bitmap_obstack lto_obstack; -static bool lto_obstack_initialized; - const char *section_name_prefix = LTO_SECTION_NAME_PREFIX; /* Set when streaming LTO for offloading compiler. */ bool lto_stream_offload_p; @@ -113,28 +108,6 @@ lto_tag_name (enum LTO_tags tag) } -/* Allocate a bitmap from heap. Initializes the LTO obstack if necessary. */ - -bitmap -lto_bitmap_alloc (void) -{ - if (!lto_obstack_initialized) - { - bitmap_obstack_initialize (<o_obstack); - lto_obstack_initialized = true; - } - return BITMAP_ALLOC (<o_obstack); -} - -/* Free bitmap B. */ - -void -lto_bitmap_free (bitmap b) -{ - BITMAP_FREE (b); -} - - /* Get a section name for a particular type or name. The NAME field is only used if SECTION_TYPE is LTO_section_function_body. For all others it is ignored. The callee of this function is responsible Index: gcc/lto-streamer.h =================================================================== --- gcc/lto-streamer.h (revision 272636) +++ gcc/lto-streamer.h (working copy) @@ -822,8 +822,6 @@ extern void lto_append_block (struct lto extern bool lto_stream_offload_p; extern const char *lto_tag_name (enum LTO_tags); -extern bitmap lto_bitmap_alloc (void); -extern void lto_bitmap_free (bitmap); extern char *lto_get_section_name (int, const char *, struct lto_file_decl_data *); extern void print_lto_report (const char *); extern void lto_streamer_init (void); Index: gcc/lto-streamer-out.c =================================================================== --- gcc/lto-streamer-out.c (revision 272636) +++ gcc/lto-streamer-out.c (working copy) @@ -2397,13 +2397,17 @@ lto_output (void) { struct lto_out_decl_state *decl_state; bitmap output = NULL; + bitmap_obstack output_obstack; int i, n_nodes; lto_symtab_encoder_t encoder = lto_get_out_decl_state ()->symtab_node_encoder; prune_offload_funcs (); if (flag_checking) - output = lto_bitmap_alloc (); + { + bitmap_obstack_initialize (&output_obstack); + output = BITMAP_ALLOC (&output_obstack); + } /* Initialize the streamer. */ lto_streamer_init (); @@ -2419,10 +2423,7 @@ lto_output (void) && !node->alias) { if (flag_checking) - { - gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl))); - bitmap_set_bit (output, DECL_UID (node->decl)); - } + gcc_assert (bitmap_set_bit (output, DECL_UID (node->decl))); decl_state = lto_new_out_decl_state (); lto_push_out_decl_state (decl_state); if (gimple_has_body_p (node->decl) @@ -2452,10 +2453,7 @@ lto_output (void) { timevar_push (TV_IPA_LTO_CTORS_OUT); if (flag_checking) - { - gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl))); - bitmap_set_bit (output, DECL_UID (node->decl)); - } + gcc_assert (bitmap_set_bit (output, DECL_UID (node->decl))); decl_state = lto_new_out_decl_state (); lto_push_out_decl_state (decl_state); if (DECL_INITIAL (node->decl) != error_mark_node @@ -2480,9 +2478,11 @@ lto_output (void) output_offload_tables (); -#if CHECKING_P - lto_bitmap_free (output); -#endif + if (flag_checking) + { + BITMAP_FREE (output); + bitmap_obstack_release (&output_obstack); + } } /* Write each node in encoded by ENCODER to OB, as well as those reachable