From patchwork Fri Jan 10 21:50:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 309424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 367E52C0099 for ; Sat, 11 Jan 2014 08:50:38 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=s/Gymv3OKFIXxjT/Tw7ahHjnyYPiwbq6ySQxAUCQH4R E3fA/pKJdL/gj+pxUyqYZ/tkqb5Rdpn2CgAkAuh4mO1vVsDyDQuHlLtBQtAITy8S bOrgTqlmtDeesza6C4t5FSihLTMaUIlSAkKpRpa6prWB1U8SyDiFrhqwxFufT1xE = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=ieXU7XvuuK2bpiTyrM8vR4uwxHY=; b=LwO0rHwMbTBK2TUYM mlWkuLbKyp+if9NrYR4BLr9ngv3f+GGKSRFKXDbYzf0pS5ydnwELKopfuuejljOd OW9BvrobAN67BtAeotIk8KgjBzRVq+6oFuWoihccnGYX/SPL/WWNiaYLwpU1h6PK 2w3nrLdE/kBXsOTTUB7ED2jtns= Received: (qmail 3252 invoked by alias); 10 Jan 2014 21:50:32 -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 3241 invoked by uid 89); 10 Jan 2014 21:50:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f180.google.com Received: from mail-ig0-f180.google.com (HELO mail-ig0-f180.google.com) (209.85.213.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 10 Jan 2014 21:50:30 +0000 Received: by mail-ig0-f180.google.com with SMTP id m12so404165iga.1 for ; Fri, 10 Jan 2014 13:50:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=281wbP1bxmljiaFrp7Hux0w29p1cc5tBBGSGzQKYmZo=; b=jICJJyqE+/284RyKNltFgUAl/dm/LSIGuJ4ENm9LRANGpF6iyMlLg/rWYpO0+3vYGj Rfx8ksRm6as2XarcwCn6YkaFn0PzLY5UvSAtF3GbaKKqZDj16ryWnjVYzG9POYANoSiC xVka6OSv/12InaEAb2fMM09l7h7PqZPA69upRK6fgPhBrLNCDwc2L/xzwYaV96Yc2knT Y5dQWKZWm1UeUJgXjYRdiDQCm6Y/LBlXRLn6AnBUjN7HLOkkAIwFMbB2VpF7dSTGVObN OVahdntmHIcXl/OiCgU3EbKz5LuGCZpfbVzR7ws2B2Cmgf6JRzv2eCZA7y9hMAA/UVJM pcDQ== X-Gm-Message-State: ALoCoQmbMdfq9Lc3yqI9/eY6np1O52rQJfTBZzK3AK2er2BG6yzQljKe8LalxOYvdXa2cEirDNwTe0oTIymyal4+RHxh7YxS8FhzFt37G2E0+/5qLbpXolaRbV5ZnzCMs501AxPQVR05kuDZ/kwYWCUDJxtbTDKfKeIMbFT1qhzjeT4CaRIMonHSrxZy8nHVYq3zFKBn+PPpw4bZRfnYdeWoEmjL2fvBZQ== MIME-Version: 1.0 X-Received: by 10.50.73.136 with SMTP id l8mr6184585igv.7.1389390629140; Fri, 10 Jan 2014 13:50:29 -0800 (PST) Received: by 10.64.229.35 with HTTP; Fri, 10 Jan 2014 13:50:29 -0800 (PST) Date: Fri, 10 Jan 2014 13:50:29 -0800 Message-ID: Subject: [GOOGLE] Move LIPO linking before profile annotation From: Dehao Chen To: GCC Patches Cc: David Li X-IsSubscribed: yes This patch moves the LIPO linking before profile annotation so that iterative-early-inline can cover functions from aux-module. Bootstrapped and passed regression test and benchmark test. OK for google-4_8? Thanks, Dehao Index: gcc/auto-profile.c =================================================================== --- gcc/auto-profile.c (revision 206534) +++ gcc/auto-profile.c (working copy) @@ -1450,6 +1450,13 @@ auto_profile (void) init_node_map (); profile_info = autofdo::afdo_profile_info; + cgraph_pre_profiling_inlining_done = true; + cgraph_process_module_scope_statics (); + /* Now perform link to allow cross module inlining. */ + cgraph_do_link (); + varpool_do_link (); + cgraph_unify_type_alias_sets (); + FOR_EACH_FUNCTION (node) { if (!gimple_has_body_p (node->symbol.decl)) @@ -1461,6 +1468,35 @@ auto_profile (void) push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl)); + if (L_IPO_COMP_MODE) + { + basic_block bb; + FOR_EACH_BB (bb) + { + gimple_stmt_iterator gsi; + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + if (is_gimple_call (stmt)) + lipo_fixup_cgraph_edge_call_target (stmt); + } + } + } + rebuild_cgraph_edges (); + pop_cfun (); + } + + FOR_EACH_FUNCTION (node) + { + if (!gimple_has_body_p (node->symbol.decl)) + continue; + + /* Don't profile functions produced for builtin stuff. */ + if (DECL_SOURCE_LOCATION (node->symbol.decl) == BUILTINS_LOCATION) + continue; + + push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl)); + /* First do indirect call promotion and early inline to make the IR match the profiled binary before actual annotation. @@ -1497,48 +1533,17 @@ auto_profile (void) early_inliner (); } + early_inliner (); autofdo::afdo_annotate_cfg (promoted_stmts); compute_function_frequency (); update_ssa (TODO_update_ssa); - pop_cfun (); - } - cgraph_pre_profiling_inlining_done = true; - cgraph_process_module_scope_statics (); - /* Now perform link to allow cross module inlining. */ - cgraph_do_link (); - varpool_do_link (); - cgraph_unify_type_alias_sets (); - - FOR_EACH_FUNCTION (node) - { - if (!gimple_has_body_p (node->symbol.decl)) - continue; - - /* Don't profile functions produced for builtin stuff. */ - if (DECL_SOURCE_LOCATION (node->symbol.decl) == BUILTINS_LOCATION) - continue; - - push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl)); - - if (L_IPO_COMP_MODE) - { - basic_block bb; - FOR_EACH_BB (bb) - { - gimple_stmt_iterator gsi; - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - { - gimple stmt = gsi_stmt (gsi); - if (is_gimple_call (stmt)) - lipo_fixup_cgraph_edge_call_target (stmt); - } - } - } /* Local pure-const may imply need to fixup the cfg. */ if (execute_fixup_cfg () & TODO_cleanup_cfg) cleanup_tree_cfg (); + free_dominance_info (CDI_DOMINATORS); + free_dominance_info (CDI_POST_DOMINATORS); rebuild_cgraph_edges (); pop_cfun (); }