From patchwork Thu Sep 19 17:10:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 276026 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 04C2C2C0110 for ; Fri, 20 Sep 2013 03:11:01 +1000 (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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=oorVF/lfvL1c7s+p0C 9dDmirfrOMlnQitMZVnACP+EjqWX3OGuYAsF1+tzHWMF6Bm9ioQ8tycEL7fAcBJm o/7plZuw20nmz3/zSx/EptnQmOcLSpbT97X6m48ccG1/M003W9DQOAR/n+4bRGig fzPH6H4MkxDjoLV9A+13G94Kw= 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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=RmrIo1Pp2JUL91LT9VCSn7n7 q1w=; b=juLhrrYOwkwCCNK06SIhfZ01hnReO4279/6RJMtbzPW6MJYTTeLJZdzX h4eTwd6VYYwqXsCg6AbSD9F0Ne5VsJIWg0UjTPNtzMNETXsiZnVLEB9zy1UllEpe wLunsu9FdxPxgbUTZDUZPvTFRaDR5gvi5jvLvawJG8LuY4hxnv4= Received: (qmail 5949 invoked by alias); 19 Sep 2013 17:10:54 -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 5930 invoked by uid 89); 19 Sep 2013 17:10:53 -0000 Received: from mail-ie0-f174.google.com (HELO mail-ie0-f174.google.com) (209.85.223.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 19 Sep 2013 17:10:53 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, NO_RELAYS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f174.google.com Received: by mail-ie0-f174.google.com with SMTP id u16so15494642iet.19 for ; Thu, 19 Sep 2013 10:10:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=xKW4HZk8oulOyszSBJpm1J7guboF40dlS+Rv7xxLo5g=; b=kJgrdwf6K5y8KIpHOrkW1nywnZoJ20c/N3BkAA3a+ckl9e7VIM6dbyhJRErdZjcyIy rxq5WurDYObi5pyNF++QV6ofWd9NN/u5GG51QE+I4E0tThtWR6JoS8CJ4JUk6+xWE24j 4h55eO2mzCbZnR2lTKoy65HuNoMP4EvraFkzbq4UaKbC/TpPM3OdybRKYJJKWUtCbM1b hVau17Bqng3lGa2ypwL+gS9+v9zKJIy0f9LJU7WJVu+TdYe+7gV8qS9C+xc8Em+lSQtK ddjXXYI9WbTfMSzHxfSJaAJbvsrcHRVA13a55WE9kwjFK561ttnt8kc3IdAc82opf778 xbVA== X-Gm-Message-State: ALoCoQnAfHTlN/Q4xQj6a4mPk9cm0jVET0AIZiNruozyO9sxSebR0Uncyw2sLVLfWniiZWyx1RLtchiqbpRHkzkva3+fFbXGcIv9kFl5c1tt8viYL+/cobpSlQxIT8QK/83+sLbN7gmzUBuXI+t0aX4iSqUn338mM+8g03JRfVCLgj2LlDeQoKjR7G3QCbSUsDMJNdgmRQg3yMW25yAX14D7tlgOlbwlVQ== MIME-Version: 1.0 X-Received: by 10.50.136.137 with SMTP id qa9mr2036520igb.42.1379610650808; Thu, 19 Sep 2013 10:10:50 -0700 (PDT) Received: by 10.64.9.133 with HTTP; Thu, 19 Sep 2013 10:10:50 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 Sep 2013 10:10:50 -0700 Message-ID: Subject: Re: [GOOGLE] Patch to fix AutoFDO LIPO performance regression From: Dehao Chen To: Xinliang David Li Cc: GCC Patches X-IsSubscribed: yes Thanks, patch updated: On Wed, Sep 18, 2013 at 5:16 PM, Xinliang David Li wrote: > On Wed, Sep 18, 2013 at 4:51 PM, Dehao Chen wrote: >> This patch fixup the call graph edge targets during AutoFDO pass, so >> that when rebuilding call graph edges, it can find the correct callee. >> >> Bootstrapped and passed regression test. Benchmark tests on-going. >> >> Ok for google-4_8 branch? >> >> Thanks, >> Dehao >> >> Index: gcc/Makefile.in >> =================================================================== >> --- gcc/Makefile.in (revision 202725) >> +++ gcc/Makefile.in (working copy) >> @@ -2960,7 +2960,7 @@ coverage.o : coverage.c $(GCOV_IO_H) $(CONFIG_H) $ >> auto-profile.o : auto-profile.c $(CONFIG_H) $(SYSTEM_H) $(FLAGS_H) \ >> $(BASIC_BLOCK_H) $(DIAGNOSTIC_CORE_H) $(GCOV_IO_H) $(INPUT_H) profile.h \ >> $(LANGHOOKS_H) $(OPTS_H) $(TREE_PASS_H) $(CGRAPH_H) $(GIMPLE_H) >> value-prof.h \ >> - $(COVERAGE_H) coretypes.h $(TREE_H) $(PARAMS_H) $(AUTO_PROFILE_H) >> + $(COVERAGE_H) coretypes.h $(TREE_H) $(PARAMS_H) l-ipo.h $(AUTO_PROFILE_H) >> cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h >> $(TM_H) $(RTL_H) \ >> $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h $(RECOG_H) \ >> $(EMIT_RTL_H) $(DIAGNOSTIC_CORE_H) $(FUNCTION_H) \ >> Index: gcc/auto-profile.c >> =================================================================== >> --- gcc/auto-profile.c (revision 202725) >> +++ gcc/auto-profile.c (working copy) >> @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see >> #include "value-prof.h" >> #include "coverage.h" >> #include "params.h" >> +#include "l-ipo.h" >> #include "auto-profile.h" >> >> /* The following routines implements AutoFDO optimization. >> @@ -1290,6 +1291,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)) >> @@ -1301,6 +1309,21 @@ 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); >> + } >> + } >> + } >> + > > Need this: > > > if (execute_fixup_cfg () & TODO_cleanup_cfg) > cleanup_tree_cfg (); > > > as in tree-profiling. Changing call stmt targets can lead to CFG changes. > > > > David > >> autofdo::afdo_annotate_cfg (); >> compute_function_frequency (); >> update_ssa (TODO_update_ssa); >> @@ -1309,13 +1332,6 @@ auto_profile (void) >> 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 (); >> - >> return TODO_rebuild_cgraph_edges; >> } Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 202725) +++ gcc/Makefile.in (working copy) @@ -2960,7 +2960,7 @@ coverage.o : coverage.c $(GCOV_IO_H) $(CONFIG_H) $ auto-profile.o : auto-profile.c $(CONFIG_H) $(SYSTEM_H) $(FLAGS_H) \ $(BASIC_BLOCK_H) $(DIAGNOSTIC_CORE_H) $(GCOV_IO_H) $(INPUT_H) profile.h \ $(LANGHOOKS_H) $(OPTS_H) $(TREE_PASS_H) $(CGRAPH_H) $(GIMPLE_H) value-prof.h \ - $(COVERAGE_H) coretypes.h $(TREE_H) $(PARAMS_H) $(AUTO_PROFILE_H) + $(COVERAGE_H) coretypes.h $(TREE_H) $(PARAMS_H) l-ipo.h $(AUTO_PROFILE_H) cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_H) $(RTL_H) \ $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h $(RECOG_H) \ $(EMIT_RTL_H) $(DIAGNOSTIC_CORE_H) $(FUNCTION_H) \ Index: gcc/auto-profile.c =================================================================== --- gcc/auto-profile.c (revision 202725) +++ gcc/auto-profile.c (working copy) @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "value-prof.h" #include "coverage.h" #include "params.h" +#include "l-ipo.h" #include "auto-profile.h" /* The following routines implements AutoFDO optimization. @@ -1290,6 +1291,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)) @@ -1301,21 +1309,33 @@ 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); + } + } + } + autofdo::afdo_annotate_cfg (); compute_function_frequency (); update_ssa (TODO_update_ssa); + /* Local pure-const may imply need to fixup the cfg. */ + if (execute_fixup_cfg () & TODO_cleanup_cfg) + cleanup_tree_cfg (); + current_function_decl = NULL; 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 (); - return TODO_rebuild_cgraph_edges; }