From patchwork Mon Jun 1 17:15:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1301837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bMJT3QQ9z9sVZ for ; Tue, 2 Jun 2020 03:15:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF69C386F46B; Mon, 1 Jun 2020 17:15:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 530CF3851C0B for ; Mon, 1 Jun 2020 17:15:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 530CF3851C0B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 2AEBC280953; Mon, 1 Jun 2020 19:15:45 +0200 (CEST) Date: Mon, 1 Jun 2020 19:15:45 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Cleanup global decl stream reference streaming, part 2 Message-ID: <20200601171545.GA68692@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-23.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch removes unnecesary ref tags and replaces them by one tag for all references to the global stream. lto-bootstrapped/regtested x86_64-linux, comitted. Honza gcc/ChangeLog: 2020-06-01 Jan Hubicka * lto-streamer.h (enum LTO_tags): Remove LTO_field_decl_ref, LTO_function_decl_ref, LTO_label_decl_ref, LTO_namespace_decl_ref, LTO_result_decl_ref, LTO_type_decl_ref, LTO_type_ref, LTO_const_decl_ref, LTO_imported_decl_ref, LTO_translation_unit_decl_ref, LTO_global_decl_ref and LTO_namelist_decl_ref; add LTO_global_stream_ref. * lto-streamer-in.c (lto_input_tree_ref): Simplify. (lto_input_scc): Update. (lto_input_tree_1): Update. * lto-streamer-out.c (lto_indexable_tree_ref): Simlify. * lto-streamer.c (lto_tag_name): Update. diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index d77b4f5e9ff..5eaba7d16d4 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -316,34 +316,17 @@ lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in, unsigned HOST_WIDE_INT ix_u; tree result = NULL_TREE; - lto_tag_check_range (tag, LTO_field_decl_ref, LTO_namelist_decl_ref); - - switch (tag) + if (tag == LTO_ssa_name_ref) { - case LTO_ssa_name_ref: ix_u = streamer_read_uhwi (ib); result = (*SSANAMES (fn))[ix_u]; - break; - - case LTO_type_ref: - case LTO_field_decl_ref: - case LTO_function_decl_ref: - case LTO_type_decl_ref: - case LTO_namespace_decl_ref: - case LTO_global_decl_ref: - case LTO_result_decl_ref: - case LTO_const_decl_ref: - case LTO_imported_decl_ref: - case LTO_label_decl_ref: - case LTO_translation_unit_decl_ref: - case LTO_namelist_decl_ref: + } + else + { + gcc_checking_assert (tag == LTO_global_stream_ref); ix_u = streamer_read_uhwi (ib); result = (*data_in->file_data->current_decl_state ->streams[LTO_DECL_STREAM])[ix_u]; - break; - - default: - gcc_unreachable (); } gcc_assert (result); @@ -1485,7 +1468,7 @@ lto_input_scc (class lto_input_block *ib, class data_in *data_in, { enum LTO_tags tag = streamer_read_record_start (ib); if (tag == LTO_null - || (tag >= LTO_field_decl_ref && tag <= LTO_global_decl_ref) + || tag == LTO_global_stream_ref || tag == LTO_tree_pickle_reference || tag == LTO_integer_cst || tag == LTO_tree_scc @@ -1549,7 +1532,7 @@ lto_input_tree_1 (class lto_input_block *ib, class data_in *data_in, if (tag == LTO_null) result = NULL_TREE; - else if (tag >= LTO_field_decl_ref && tag <= LTO_namelist_decl_ref) + else if (tag == LTO_global_stream_ref || tag == LTO_ssa_name_ref) { /* If TAG is a reference to an indexable tree, the next value in IB is the index into the table where we expect to find diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index a44ed0037ee..dfc4603d7ae 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -252,84 +252,18 @@ static void lto_indexable_tree_ref (struct output_block *ob, tree expr, enum LTO_tags *tag, unsigned *index) { - enum tree_code code; - enum lto_decl_stream_e_t encoder; - gcc_checking_assert (tree_is_indexable (expr)); - if (TYPE_P (expr)) + if (TREE_CODE (expr) == SSA_NAME) { - *tag = LTO_type_ref; - encoder = LTO_DECL_STREAM; + *tag = LTO_ssa_name_ref; + *index = SSA_NAME_VERSION (expr); } else { - code = TREE_CODE (expr); - switch (code) - { - case SSA_NAME: - *tag = LTO_ssa_name_ref; - *index = SSA_NAME_VERSION (expr); - return; - break; - - case FIELD_DECL: - *tag = LTO_field_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case FUNCTION_DECL: - *tag = LTO_function_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case VAR_DECL: - case DEBUG_EXPR_DECL: - gcc_checking_assert (decl_function_context (expr) == NULL - || TREE_STATIC (expr)); - /* FALLTHRU */ - case PARM_DECL: - *tag = LTO_global_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case CONST_DECL: - *tag = LTO_const_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case TYPE_DECL: - *tag = LTO_type_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case NAMESPACE_DECL: - *tag = LTO_namespace_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case LABEL_DECL: - *tag = LTO_label_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case RESULT_DECL: - *tag = LTO_result_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - case TRANSLATION_UNIT_DECL: - *tag = LTO_translation_unit_decl_ref; - encoder = LTO_DECL_STREAM; - break; - - default: - /* No other node is indexable, so it should have been handled by - lto_output_tree. */ - gcc_unreachable (); - } + *tag = LTO_global_stream_ref; + *index = lto_get_index (&ob->decl_state->streams[LTO_DECL_STREAM], expr); } - *index = lto_get_index (&ob->decl_state->streams[encoder], expr); } diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index f7d3f24b0b1..7d0fd3924c0 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -84,24 +84,10 @@ lto_tag_name (enum LTO_tags tag) return "LTO_ert_must_not_throw"; case LTO_tree_pickle_reference: return "LTO_tree_pickle_reference"; - case LTO_field_decl_ref: - return "LTO_field_decl_ref"; - case LTO_function_decl_ref: - return "LTO_function_decl_ref"; - case LTO_label_decl_ref: - return "LTO_label_decl_ref"; - case LTO_namespace_decl_ref: - return "LTO_namespace_decl_ref"; - case LTO_result_decl_ref: - return "LTO_result_decl_ref"; + case LTO_global_stream_ref: + return "LTO_global_sream_ref"; case LTO_ssa_name_ref: return "LTO_ssa_name_ref"; - case LTO_type_decl_ref: - return "LTO_type_decl_ref"; - case LTO_type_ref: - return "LTO_type_ref"; - case LTO_global_decl_ref: - return "LTO_global_decl_ref"; default: return "LTO_UNKNOWN"; } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index fc7e4312420..241a46d4f31 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -185,28 +185,15 @@ enum LTO_tags LTO_trees, /* References to indexable tree nodes. These objects are stored in - tables that are written separately from the function bodies that - reference them. This way they can be instantiated even when the - referencing functions aren't (e.g., during WPA) and it also allows - functions to be copied from one file to another without having - to unpickle the body first (the references are location - independent). - - NOTE, do not regroup these values as the grouping is exposed - in the range checks done in lto_input_tree. */ - LTO_field_decl_ref, /* Do not change. */ - LTO_function_decl_ref, - LTO_label_decl_ref, - LTO_namespace_decl_ref, - LTO_result_decl_ref, + tables that are written separately from the function bodies + and variable constructors that reference them. This way they can be + instantiated even when the referencing functions aren't (e.g., during WPA) + and it also allows functions to be copied from one file to another without + having to unpickle the body first (the references are location + independent). */ + LTO_global_stream_ref, + LTO_ssa_name_ref, - LTO_type_decl_ref, - LTO_type_ref, - LTO_const_decl_ref, - LTO_imported_decl_ref, - LTO_translation_unit_decl_ref, - LTO_global_decl_ref, - LTO_namelist_decl_ref, /* Do not change. */ /* This tag must always be last. */ LTO_NUM_TAGS