From patchwork Sun Oct 13 10:12:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1175826 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-510867-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="As9ljLt9"; 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 46rcv46Sq0z9s4Y for ; Sun, 13 Oct 2019 21:12:29 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=w4vKv3Iyp+PQmS8jBSShkGoF44xkzfAOPOIKFmtgU/T0wTEIm2ZMq fxyuGVv9w8d1tH/R+yeZula0olD/s2a5PU+GfP539VhRMA7uUGtrKznLRRa1Z77n u5Zw4lCtrQvTyt0FxksWRVkhS16IbEzM9lhUQEstQ4LiTMjg7NzXTY= 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=ar0NjeXgxhTkKs+pHg3rX4qv4zU=; b=As9ljLt9xP01ErzG06YV RaC4mea0KspKPoHlcMAmad8t8e5PPtntHeztpBDqvarUyD1pGVWU3+5yTd40PrYo EAHY7D8hT6jhyxFGfvWQletOs6/uYpyYYsuFzddmDRG4pmCkuOz//w7lf6MfKnBA NtAcESBV4bhWLnV3wfr13RQ= Received: (qmail 98915 invoked by alias); 13 Oct 2019 10:12:21 -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 98907 invoked by uid 89); 13 Oct 2019 10:12:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.7 required=5.0 tests=AWL, BAYES_40, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=UD:lto-streamer-out.c, sk:lto_pre, output_function, sk:renumbe X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Oct 2019 10:12:18 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 814E72825A2; Sun, 13 Oct 2019 12:12:15 +0200 (CEST) Date: Sun, 13 Oct 2019 12:12:15 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix duplicated renumbering of statements during streaming Message-ID: <20191013101215.7wyahwu5vukqo5ra@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, currently we renumber statements during streaming twice - once using renumber_gimple_stmt_uids and second inside output_function. The numbering only differs by fact that first one does mix normal and virtual PHI sets while the second doesn't. This patch reduces renumbering to only one per streaming. Honza * lto.c (lto_wpa_write_files): Do not update bodies of clones. * lto-streamer-out.c (collect_block_tree_leafs): Renumber statements so non-virutal are before virutals. (output_function): Avoid body modifications. Index: lto/lto.c =================================================================== --- lto/lto.c (revision 276870) +++ lto/lto.c (working copy) @@ -308,7 +308,7 @@ lto_wpa_write_files (void) /* Do body modifications needed for streaming before we fork out worker processes. */ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) - if (gimple_has_body_p (node->decl)) + if (!node->clone_of && gimple_has_body_p (node->decl)) lto_prepare_function_for_streaming (node); /* Generate a prefix for the LTRANS unit files. */ Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 276870) +++ lto-streamer-out.c (working copy) @@ -2066,14 +2066,54 @@ collect_block_tree_leafs (tree root, vec void lto_prepare_function_for_streaming (struct cgraph_node *node) { - if (number_of_loops (DECL_STRUCT_FUNCTION (node->decl))) + struct function *fn = DECL_STRUCT_FUNCTION (node->decl); + basic_block bb; + + if (number_of_loops (fn)) { - push_cfun (DECL_STRUCT_FUNCTION (node->decl)); + push_cfun (fn); loop_optimizer_init (AVOID_CFG_MODIFICATIONS); loop_optimizer_finalize (); pop_cfun (); } - renumber_gimple_stmt_uids (DECL_STRUCT_FUNCTION (node->decl)); + /* We will renumber the statements. The code that does this uses + the same ordering that we use for serializing them so we can use + the same code on the other end and not have to write out the + statement numbers. We do not assign UIDs to PHIs here because + virtual PHIs get re-computed on-the-fly which would make numbers + inconsistent. */ + set_gimple_stmt_max_uid (fn, 0); + FOR_ALL_BB_FN (bb, fn) + { + for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gphi *stmt = gsi.phi (); + + /* Virtual PHIs are not going to be streamed. */ + if (!virtual_operand_p (gimple_phi_result (stmt))) + gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn)); + } + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn)); + } + } + /* To avoid keeping duplicate gimple IDs in the statements, renumber + virtual phis now. */ + FOR_ALL_BB_FN (bb, fn) + { + for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gphi *stmt = gsi.phi (); + if (virtual_operand_p (gimple_phi_result (stmt))) + gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn)); + } + } + } /* Output the body of function NODE->DECL. */ @@ -2144,45 +2184,6 @@ output_function (struct cgraph_node *nod /* Output any exception handling regions. */ output_eh_regions (ob, fn); - - /* We will renumber the statements. The code that does this uses - the same ordering that we use for serializing them so we can use - the same code on the other end and not have to write out the - statement numbers. We do not assign UIDs to PHIs here because - virtual PHIs get re-computed on-the-fly which would make numbers - inconsistent. */ - set_gimple_stmt_max_uid (fn, 0); - FOR_ALL_BB_FN (bb, fn) - { - for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); - gsi_next (&gsi)) - { - gphi *stmt = gsi.phi (); - - /* Virtual PHIs are not going to be streamed. */ - if (!virtual_operand_p (gimple_phi_result (stmt))) - gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn)); - } - for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); - gsi_next (&gsi)) - { - gimple *stmt = gsi_stmt (gsi); - gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn)); - } - } - /* To avoid keeping duplicate gimple IDs in the statements, renumber - virtual phis now. */ - FOR_ALL_BB_FN (bb, fn) - { - for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); - gsi_next (&gsi)) - { - gphi *stmt = gsi.phi (); - if (virtual_operand_p (gimple_phi_result (stmt))) - gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn)); - } - } - /* Output the code for the function. */ FOR_ALL_BB_FN (bb, fn) output_bb (ob, bb, fn);