Commit 1500c66f by Felix Yang Committed by Fei Yang

auto-profile.c (afdo_find_equiv_class): Remove unnecessary test.

        * auto-profile.c (afdo_find_equiv_class): Remove unnecessary test.
        (autofdo_source_profile::get_callsite_total_count,
        function_instance::get_function_instance_by_decl,
        string_table::get_index, string_table::get_index_by_decl,
        afdo_vpt_for_early_inline, afdo_callsite_hot_enough_for_early_inline):
        Fix comment typos. Reformatting and minor code rearrangement.

From-SVN: r219812
parent a07c25b5
2015-01-18 Felix Yang <felix.yang@huawei.com>
* auto-profile.c (afdo_find_equiv_class): Remove unnecessary test.
(autofdo_source_profile::get_callsite_total_count,
function_instance::get_function_instance_by_decl,
string_table::get_index, string_table::get_index_by_decl,
afdo_vpt_for_early_inline, afdo_callsite_hot_enough_for_early_inline):
Fix comment typos. Reformatting and minor code rearrangement.
2015-01-17 Segher Boessenkool <segher@kernel.crashing.org> 2015-01-17 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (probe_stack): Delete. * config/rs6000/rs6000.md (probe_stack): Delete.
......
...@@ -107,7 +107,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -107,7 +107,7 @@ along with GCC; see the file COPYING3. If not see
standalone symbol, or a clone of a function that is inlined into another standalone symbol, or a clone of a function that is inlined into another
function. function.
Phase 2: Early inline + valur profile transformation. Phase 2: Early inline + value profile transformation.
Early inline uses autofdo_source_profile to find if a callsite is: Early inline uses autofdo_source_profile to find if a callsite is:
* inlined in the profiled binary. * inlined in the profiled binary.
* callee body is hot in the profiling run. * callee body is hot in the profiling run.
...@@ -372,7 +372,7 @@ get_original_name (const char *name) ...@@ -372,7 +372,7 @@ get_original_name (const char *name)
/* Return the combined location, which is a 32bit integer in which /* Return the combined location, which is a 32bit integer in which
higher 16 bits stores the line offset of LOC to the start lineno higher 16 bits stores the line offset of LOC to the start lineno
of DECL, The lower 16 bits stores the discrimnator. */ of DECL, The lower 16 bits stores the discriminator. */
static unsigned static unsigned
get_combined_location (location_t loc, tree decl) get_combined_location (location_t loc, tree decl)
...@@ -435,7 +435,7 @@ get_inline_stack (location_t locus, inline_stack *stack) ...@@ -435,7 +435,7 @@ get_inline_stack (location_t locus, inline_stack *stack)
/* Return STMT's combined location, which is a 32bit integer in which /* Return STMT's combined location, which is a 32bit integer in which
higher 16 bits stores the line offset of LOC to the start lineno higher 16 bits stores the line offset of LOC to the start lineno
of DECL, The lower 16 bits stores the discrimnator. */ of DECL, The lower 16 bits stores the discriminator. */
static unsigned static unsigned
get_relative_location_for_stmt (gimple stmt) get_relative_location_for_stmt (gimple stmt)
...@@ -492,8 +492,8 @@ string_table::get_index (const char *name) const ...@@ -492,8 +492,8 @@ string_table::get_index (const char *name) const
string_index_map::const_iterator iter = map_.find (name); string_index_map::const_iterator iter = map_.find (name);
if (iter == map_.end ()) if (iter == map_.end ())
return -1; return -1;
else
return iter->second; return iter->second;
} }
/* Return the index of a given function DECL. Return -1 if DECL is not /* Return the index of a given function DECL. Return -1 if DECL is not
...@@ -513,8 +513,8 @@ string_table::get_index_by_decl (tree decl) const ...@@ -513,8 +513,8 @@ string_table::get_index_by_decl (tree decl) const
return ret; return ret;
if (DECL_ABSTRACT_ORIGIN (decl)) if (DECL_ABSTRACT_ORIGIN (decl))
return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl)); return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl));
else
return -1; return -1;
} }
/* Return the function name of a given INDEX. */ /* Return the function name of a given INDEX. */
...@@ -580,8 +580,8 @@ function_instance::get_function_instance_by_decl (unsigned lineno, ...@@ -580,8 +580,8 @@ function_instance::get_function_instance_by_decl (unsigned lineno,
} }
if (DECL_ABSTRACT_ORIGIN (decl)) if (DECL_ABSTRACT_ORIGIN (decl))
return get_function_instance_by_decl (lineno, DECL_ABSTRACT_ORIGIN (decl)); return get_function_instance_by_decl (lineno, DECL_ABSTRACT_ORIGIN (decl));
else
return NULL; return NULL;
} }
/* Store the profile info for LOC in INFO. Return TRUE if profile info /* Store the profile info for LOC in INFO. Return TRUE if profile info
...@@ -608,7 +608,7 @@ function_instance::mark_annotated (location_t loc) ...@@ -608,7 +608,7 @@ function_instance::mark_annotated (location_t loc)
iter->second.annotated = true; iter->second.annotated = true;
} }
/* Read the inlinied indirect call target profile for STMT and store it in /* Read the inlined indirect call target profile for STMT and store it in
MAP, return the total count for all inlined indirect calls. */ MAP, return the total count for all inlined indirect calls. */
gcov_type gcov_type
...@@ -835,8 +835,8 @@ autofdo_source_profile::get_callsite_total_count ( ...@@ -835,8 +835,8 @@ autofdo_source_profile::get_callsite_total_count (
|| afdo_string_table->get_index (IDENTIFIER_POINTER ( || afdo_string_table->get_index (IDENTIFIER_POINTER (
DECL_ASSEMBLER_NAME (edge->callee->decl))) != s->name ()) DECL_ASSEMBLER_NAME (edge->callee->decl))) != s->name ())
return 0; return 0;
else
return s->total_count (); return s->total_count ();
} }
/* Read AutoFDO profile and returns TRUE on success. */ /* Read AutoFDO profile and returns TRUE on success. */
...@@ -967,9 +967,9 @@ read_profile (void) ...@@ -967,9 +967,9 @@ read_profile (void)
histograms for indirect-call optimization. histograms for indirect-call optimization.
This function is actually served for 2 purposes: This function is actually served for 2 purposes:
    * before annotation, we need to mark histogram, promote and inline * before annotation, we need to mark histogram, promote and inline
    * after annotation, we just need to mark, and let follow-up logic to * after annotation, we just need to mark, and let follow-up logic to
      decide if it needs to promote and inline. */ decide if it needs to promote and inline. */
static void static void
afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map &map, afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map &map,
...@@ -1065,7 +1065,7 @@ set_edge_annotated (edge e, edge_set *annotated) ...@@ -1065,7 +1065,7 @@ set_edge_annotated (edge e, edge_set *annotated)
} }
/* For a given BB, set its execution count. Attach value profile if a stmt /* For a given BB, set its execution count. Attach value profile if a stmt
is not in PROMOTED, because we only want to promot an indirect call once. is not in PROMOTED, because we only want to promote an indirect call once.
Return TRUE if BB is annotated. */ Return TRUE if BB is annotated. */
static bool static bool
...@@ -1149,7 +1149,7 @@ afdo_find_equiv_class (bb_set *annotated_bb) ...@@ -1149,7 +1149,7 @@ afdo_find_equiv_class (bb_set *annotated_bb)
bb1->aux = bb; bb1->aux = bb;
if (bb1->count > bb->count && is_bb_annotated (bb1, *annotated_bb)) if (bb1->count > bb->count && is_bb_annotated (bb1, *annotated_bb))
{ {
bb->count = MAX (bb->count, bb1->count); bb->count = bb1->count;
set_bb_annotated (bb, annotated_bb); set_bb_annotated (bb, annotated_bb);
} }
} }
...@@ -1161,7 +1161,7 @@ afdo_find_equiv_class (bb_set *annotated_bb) ...@@ -1161,7 +1161,7 @@ afdo_find_equiv_class (bb_set *annotated_bb)
bb1->aux = bb; bb1->aux = bb;
if (bb1->count > bb->count && is_bb_annotated (bb1, *annotated_bb)) if (bb1->count > bb->count && is_bb_annotated (bb1, *annotated_bb))
{ {
bb->count = MAX (bb->count, bb1->count); bb->count = bb1->count;
set_bb_annotated (bb, annotated_bb); set_bb_annotated (bb, annotated_bb);
} }
} }
...@@ -1466,13 +1466,14 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmts) ...@@ -1466,13 +1466,14 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmts)
} }
} }
} }
if (has_vpt) if (has_vpt)
{ {
optimize_inline_calls (current_function_decl); optimize_inline_calls (current_function_decl);
return true; return true;
} }
else
return false; return false;
} }
/* Annotate auto profile to the control flow graph. Do not annotate value /* Annotate auto profile to the control flow graph. Do not annotate value
...@@ -1667,19 +1668,20 @@ afdo_callsite_hot_enough_for_early_inline (struct cgraph_edge *edge) ...@@ -1667,19 +1668,20 @@ afdo_callsite_hot_enough_for_early_inline (struct cgraph_edge *edge)
{ {
gcov_type count gcov_type count
= autofdo::afdo_source_profile->get_callsite_total_count (edge); = autofdo::afdo_source_profile->get_callsite_total_count (edge);
if (count > 0) if (count > 0)
{ {
bool is_hot; bool is_hot;
const struct gcov_ctr_summary *saved_profile_info = profile_info; const struct gcov_ctr_summary *saved_profile_info = profile_info;
/* At earling inline stage, profile_info is not set yet. We need to /* At early inline stage, profile_info is not set yet. We need to
temporarily set it to afdo_profile_info to calculate hotness. */ temporarily set it to afdo_profile_info to calculate hotness. */
profile_info = autofdo::afdo_profile_info; profile_info = autofdo::afdo_profile_info;
is_hot = maybe_hot_count_p (NULL, count); is_hot = maybe_hot_count_p (NULL, count);
profile_info = saved_profile_info; profile_info = saved_profile_info;
return is_hot; return is_hot;
} }
else
return false; return false;
} }
namespace namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment