From patchwork Tue Dec 10 17:49:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1207188 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515627-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="aOSWRAhL"; 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 47XSJF2YqDz9sP3 for ; Wed, 11 Dec 2019 04:50:03 +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=SuW43kZkVKYfqbcVkXzFUs1wwvsjh+egUX8vbClvlOw7Fjz1IEB4I qZy2s3nZRGXK67xDi9rhz1YDUzHyH5tUE9SVQ9NvUop/O2oCQD+MdrcRyohGj0d+ O7r+AJypze6kHuyvQB6jF3hEBfLpZN2xi1kiGHi/n+zYQad3EDdgz0= 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=IxxdItw8Ua8c2nUYxI2EVPgF/wk=; b=aOSWRAhLnASyB0WG2i1M PjW5ybpO5f7+g2wawavubb11Zt3Ve7hJonGD0I0jY5Cu9UdvicZSMjzT2i+czLnf h37td2zkjAP5zA6tnzjdejnbT3MBqzEEhE/R0kzDoeLRgLrWYJ+IEtj1JB7ruSPG 8FR1BmTAEZgH+PVuxw+3c+c= Received: (qmail 99092 invoked by alias); 10 Dec 2019 17:49:56 -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 99084 invoked by uid 89); 10 Dec 2019 17:49:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=heatmap, enu, martins 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; Tue, 10 Dec 2019 17:49:55 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 80BC9280830; Tue, 10 Dec 2019 18:49:53 +0100 (CET) Date: Tue, 10 Dec 2019 18:49:53 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix hot/startup partitioning with LTO Message-ID: <20191210174953.cbwbsz6ur6oxtgya@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, as noticed by Martin's new heatmaps default_function_sections disables test.unlikely and text.startup sections during LTO. This was meant to be only with tp_first_run profiling. The hot section is still useful since it does "poor man's clustering" so I kept only the test to disable startup subsection with corrected fix. Bootstrapped/regtested x86_64-linux and checked that it works well with heatmap. Honza * varasm.c (default_function_section): Fix confused tests for tp_first_run reordering. Index: varasm.c =================================================================== --- varasm.c (revision 279167) +++ varasm.c (working copy) @@ -589,9 +589,13 @@ default_function_section (tree decl, enu where we can split away unnecessary parts of static constructors. */ if (startup && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED) { - /* If we do have a profile or(and) LTO phase is executed, we do not need - these ELF section. */ - if (!in_lto_p || !flag_profile_values) + /* During LTO the tp_first_run profiling will naturally place all + initialization code first. Using separate section is counter-productive + because startup only code may call functions which are no longer + startup only. */ + if (!in_lto_p + || !cgraph_node::get (decl)->tp_first_run + || !opt_for_fn (decl, flag_profile_reorder_functions)) return get_named_text_section (decl, ".text.startup", NULL); else return NULL; @@ -607,10 +611,7 @@ default_function_section (tree decl, enu case NODE_FREQUENCY_UNLIKELY_EXECUTED: return get_named_text_section (decl, ".text.unlikely", NULL); case NODE_FREQUENCY_HOT: - /* If we do have a profile or(and) LTO phase is executed, we do not need - these ELF section. */ - if (!in_lto_p || !flag_profile_values) - return get_named_text_section (decl, ".text.hot", NULL); + return get_named_text_section (decl, ".text.hot", NULL); /* FALLTHRU */ default: return NULL;