Commit 160576e1 by Martin Liska Committed by Martin Liska

Improve -fprofile-report.

2018-11-13  Martin Liska  <mliska@suse.cz>

	PR tree-optimization/87885
	* cfghooks.c (account_profile_record): Rename
	to ...
	(profile_record_check_consistency): ... this.
	Calculate missing num_mismatched_freq_in.
	(profile_record_account_profile): New function
	that calculates time and size of a function.
	* cfghooks.h (struct profile_record): Remove
	all tuples.
	(struct cfg_hooks): Remove after_pass flag.
	(account_profile_record): Rename to ...
	(profile_record_check_consistency): ... this.
	(profile_record_account_profile): New.
	* cfgrtl.c (rtl_account_profile_record): Remove
	after_pass flag.
	* passes.c (check_profile_consistency): Do only
	checking.
	(account_profile): Calculate size and time of
	function only.
	(pass_manager::dump_profile_report): Reformat
	output.
	(execute_one_ipa_transform_pass): Call
	consistency check before clean upand call account_profile
	after a clean up is done.
	(execute_one_pass): Call check_profile_consistency and
	account_profile instead of using after_pass flag..
	* tree-cfg.c (gimple_account_profile_record): Likewise.

From-SVN: r266074
parent e4db210d
2018-11-13 Martin Liska <mliska@suse.cz> 2018-11-13 Martin Liska <mliska@suse.cz>
PR tree-optimization/87885
* cfghooks.c (account_profile_record): Rename
to ...
(profile_record_check_consistency): ... this.
Calculate missing num_mismatched_freq_in.
(profile_record_account_profile): New function
that calculates time and size of a function.
* cfghooks.h (struct profile_record): Remove
all tuples.
(struct cfg_hooks): Remove after_pass flag.
(account_profile_record): Rename to ...
(profile_record_check_consistency): ... this.
(profile_record_account_profile): New.
* cfgrtl.c (rtl_account_profile_record): Remove
after_pass flag.
* passes.c (check_profile_consistency): Do only
checking.
(account_profile): Calculate size and time of
function only.
(pass_manager::dump_profile_report): Reformat
output.
(execute_one_ipa_transform_pass): Call
consistency check before clean upand call account_profile
after a clean up is done.
(execute_one_pass): Call check_profile_consistency and
account_profile instead of using after_pass flag..
* tree-cfg.c (gimple_account_profile_record): Likewise.
2018-11-13 Martin Liska <mliska@suse.cz>
PR sanitizer/87930 PR sanitizer/87930
* config/i386/i386.c (ix86_option_override_internal): Error * config/i386/i386.c (ix86_option_override_internal): Error
about usage -mabi=ms and -fsanitize={,kernel-}address. about usage -mabi=ms and -fsanitize={,kernel-}address.
...@@ -1425,11 +1425,10 @@ split_block_before_cond_jump (basic_block bb) ...@@ -1425,11 +1425,10 @@ split_block_before_cond_jump (basic_block bb)
/* Work-horse for passes.c:check_profile_consistency. /* Work-horse for passes.c:check_profile_consistency.
Do book-keeping of the CFG for the profile consistency checker. Do book-keeping of the CFG for the profile consistency checker.
If AFTER_PASS is 0, do pre-pass accounting, or if AFTER_PASS is 1 Store the counting in RECORD. */
then do post-pass accounting. Store the counting in RECORD. */
void void
account_profile_record (struct profile_record *record, int after_pass) profile_record_check_consistency (profile_record *record)
{ {
basic_block bb; basic_block bb;
edge_iterator ei; edge_iterator ei;
...@@ -1445,26 +1444,49 @@ account_profile_record (struct profile_record *record, int after_pass) ...@@ -1445,26 +1444,49 @@ account_profile_record (struct profile_record *record, int after_pass)
sum += e->probability; sum += e->probability;
if (EDGE_COUNT (bb->succs) if (EDGE_COUNT (bb->succs)
&& sum.differs_from_p (profile_probability::always ())) && sum.differs_from_p (profile_probability::always ()))
record->num_mismatched_freq_out[after_pass]++; record->num_mismatched_freq_out++;
profile_count lsum = profile_count::zero (); profile_count lsum = profile_count::zero ();
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
lsum += e->count (); lsum += e->count ();
if (EDGE_COUNT (bb->succs) && (lsum.differs_from_p (bb->count))) if (EDGE_COUNT (bb->succs) && (lsum.differs_from_p (bb->count)))
record->num_mismatched_count_out[after_pass]++; record->num_mismatched_count_out++;
} }
if (bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) if (bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)
&& profile_status_for_fn (cfun) != PROFILE_ABSENT) && profile_status_for_fn (cfun) != PROFILE_ABSENT)
{ {
profile_probability sum = profile_probability::never ();
profile_count lsum = profile_count::zero (); profile_count lsum = profile_count::zero ();
FOR_EACH_EDGE (e, ei, bb->preds) FOR_EACH_EDGE (e, ei, bb->preds)
lsum += e->count (); {
sum += e->probability;
lsum += e->count ();
}
if (EDGE_COUNT (bb->preds)
&& sum.differs_from_p (profile_probability::always ()))
record->num_mismatched_freq_in++;
if (lsum.differs_from_p (bb->count)) if (lsum.differs_from_p (bb->count))
record->num_mismatched_count_in[after_pass]++; record->num_mismatched_count_in++;
} }
if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun) if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun)
|| bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) || bb == EXIT_BLOCK_PTR_FOR_FN (cfun))
continue; continue;
gcc_assert (cfg_hooks->account_profile_record); gcc_assert (cfg_hooks->account_profile_record);
cfg_hooks->account_profile_record (bb, after_pass, record); cfg_hooks->account_profile_record (bb, record);
}
}
/* Work-horse for passes.c:acount_profile.
Do book-keeping of the CFG for the profile accounting.
Store the counting in RECORD. */
void
profile_record_account_profile (profile_record *record)
{
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
{
gcc_assert (cfg_hooks->account_profile_record);
cfg_hooks->account_profile_record (bb, record);
} }
} }
...@@ -38,18 +38,18 @@ struct profile_record ...@@ -38,18 +38,18 @@ struct profile_record
{ {
/* The number of basic blocks where sum(freq) of the block's predecessors /* The number of basic blocks where sum(freq) of the block's predecessors
doesn't match reasonably well with the incoming frequency. */ doesn't match reasonably well with the incoming frequency. */
int num_mismatched_freq_in[2]; int num_mismatched_freq_in;
/* Likewise for a basic block's successors. */ /* Likewise for a basic block's successors. */
int num_mismatched_freq_out[2]; int num_mismatched_freq_out;
/* The number of basic blocks where sum(count) of the block's predecessors /* The number of basic blocks where sum(count) of the block's predecessors
doesn't match reasonably well with the incoming frequency. */ doesn't match reasonably well with the incoming frequency. */
int num_mismatched_count_in[2]; int num_mismatched_count_in;
/* Likewise for a basic block's successors. */ /* Likewise for a basic block's successors. */
int num_mismatched_count_out[2]; int num_mismatched_count_out;
/* A weighted cost of the run-time of the function body. */ /* A weighted cost of the run-time of the function body. */
gcov_type time[2]; gcov_type_unsigned time;
/* A weighted cost of the size of the function body. */ /* A weighted cost of the size of the function body. */
int size[2]; int size;
/* True iff this pass actually was run. */ /* True iff this pass actually was run. */
bool run; bool run;
}; };
...@@ -182,7 +182,7 @@ struct cfg_hooks ...@@ -182,7 +182,7 @@ struct cfg_hooks
basic_block (*split_block_before_cond_jump) (basic_block); basic_block (*split_block_before_cond_jump) (basic_block);
/* Do book-keeping of a basic block for the profile consistency checker. */ /* Do book-keeping of a basic block for the profile consistency checker. */
void (*account_profile_record) (basic_block, int, struct profile_record *); void (*account_profile_record) (basic_block, struct profile_record *);
}; };
extern void verify_flow_info (void); extern void verify_flow_info (void);
...@@ -254,7 +254,8 @@ extern void copy_bbs (basic_block *, unsigned, basic_block *, ...@@ -254,7 +254,8 @@ extern void copy_bbs (basic_block *, unsigned, basic_block *,
edge *, unsigned, edge *, struct loop *, edge *, unsigned, edge *, struct loop *,
basic_block, bool); basic_block, bool);
void account_profile_record (struct profile_record *, int); void profile_record_check_consistency (profile_record *);
void profile_record_account_profile (profile_record *);
/* Hooks containers. */ /* Hooks containers. */
extern struct cfg_hooks gimple_cfg_hooks; extern struct cfg_hooks gimple_cfg_hooks;
......
...@@ -5068,22 +5068,20 @@ rtl_duplicate_bb (basic_block bb) ...@@ -5068,22 +5068,20 @@ rtl_duplicate_bb (basic_block bb)
} }
/* Do book-keeping of basic block BB for the profile consistency checker. /* Do book-keeping of basic block BB for the profile consistency checker.
If AFTER_PASS is 0, do pre-pass accounting, or if AFTER_PASS is 1 Store the counting in RECORD. */
then do post-pass accounting. Store the counting in RECORD. */
static void static void
rtl_account_profile_record (basic_block bb, int after_pass, rtl_account_profile_record (basic_block bb, struct profile_record *record)
struct profile_record *record)
{ {
rtx_insn *insn; rtx_insn *insn;
FOR_BB_INSNS (bb, insn) FOR_BB_INSNS (bb, insn)
if (INSN_P (insn)) if (INSN_P (insn))
{ {
record->size[after_pass] += insn_cost (insn, false); record->size += insn_cost (insn, false);
if (bb->count.initialized_p ()) if (bb->count.initialized_p ())
record->time[after_pass] record->time
+= insn_cost (insn, true) * bb->count.to_gcov_type (); += insn_cost (insn, true) * bb->count.to_gcov_type ();
else if (profile_status_for_fn (cfun) == PROFILE_GUESSED) else if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
record->time[after_pass] record->time
+= insn_cost (insn, true) * bb->count.to_frequency (cfun); += insn_cost (insn, true) * bb->count.to_frequency (cfun);
} }
} }
......
...@@ -8798,23 +8798,22 @@ gimple_lv_add_condition_to_bb (basic_block first_head ATTRIBUTE_UNUSED, ...@@ -8798,23 +8798,22 @@ gimple_lv_add_condition_to_bb (basic_block first_head ATTRIBUTE_UNUSED,
/* Do book-keeping of basic block BB for the profile consistency checker. /* Do book-keeping of basic block BB for the profile consistency checker.
If AFTER_PASS is 0, do pre-pass accounting, or if AFTER_PASS is 1 Store the counting in RECORD. */
then do post-pass accounting. Store the counting in RECORD. */
static void static void
gimple_account_profile_record (basic_block bb, int after_pass, gimple_account_profile_record (basic_block bb,
struct profile_record *record) struct profile_record *record)
{ {
gimple_stmt_iterator i; gimple_stmt_iterator i;
for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
{ {
record->size[after_pass] record->size
+= estimate_num_insns (gsi_stmt (i), &eni_size_weights); += estimate_num_insns (gsi_stmt (i), &eni_size_weights);
if (bb->count.initialized_p ()) if (bb->count.initialized_p ())
record->time[after_pass] record->time
+= estimate_num_insns (gsi_stmt (i), += estimate_num_insns (gsi_stmt (i),
&eni_time_weights) * bb->count.to_gcov_type (); &eni_time_weights) * bb->count.to_gcov_type ();
else if (profile_status_for_fn (cfun) == PROFILE_GUESSED) else if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
record->time[after_pass] record->time
+= estimate_num_insns (gsi_stmt (i), += estimate_num_insns (gsi_stmt (i),
&eni_time_weights) * bb->count.to_frequency (cfun); &eni_time_weights) * bb->count.to_frequency (cfun);
} }
......
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