diff options
author | Teresa Johnson <tejohnson@google.com> | 2013-08-31 01:43:33 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@gcc.gnu.org> | 2013-08-31 01:43:33 +0000 |
commit | 600b5b1d5cb381a652a9b57445b27793304e954f (patch) | |
tree | 5309c6fb7e215165052af90d314125c561039563 /gcc/predict.c | |
parent | 7b55c620f002242dfa035572deb1bd1ed9c97dd7 (diff) | |
download | gcc-600b5b1d5cb381a652a9b57445b27793304e954f.zip gcc-600b5b1d5cb381a652a9b57445b27793304e954f.tar.gz gcc-600b5b1d5cb381a652a9b57445b27793304e954f.tar.bz2 |
This patch sanitizes the partitioning to address issues such as edge weight insanities that sometimes occur due to upstream optimizations...
This patch sanitizes the partitioning to address issues such as edge
weight insanities that sometimes occur due to upstream optimizations,
and ensures that hot blocks are not dominated by cold blocks. This
needs to be resanitized after certain cfg optimizations that may
cause hot blocks previously reached via both hot and cold paths to
only be reached by cold paths.
The verification code in sanitize_dominator_hotness was contributed by
Steven Bosscher.
2013-08-29 Teresa Johnson <tejohnson@google.com>
Steven Bosscher <steven@gcc.gnu.org>
* cfgrtl.c (fixup_new_cold_bb): New routine.
(commit_edge_insertions): Invoke fixup_partitions.
(find_partition_fixes): New routine.
(fixup_partitions): Ditto.
(verify_hot_cold_block_grouping): Update comments.
(rtl_verify_edges): Invoke find_partition_fixes.
(rtl_verify_bb_pointers): Update comments.
(rtl_verify_bb_layout): Ditto.
* basic-block.h (probably_never_executed_edge_p): Declare.
(fixup_partitions): Ditto.
* cfgcleanup.c (try_optimize_cfg): Invoke fixup_partitions.
* bb-reorder.c (sanitize_hot_paths): New function.
(find_rarely_executed_basic_blocks_and_crossing_edges): Invoke
sanitize_hot_paths.
* predict.c (probably_never_executed_edge_p): New routine.
* cfg.c (check_bb_profile): Add partition insanity warnings.
Co-Authored-By: Steven Bosscher <steven@gcc.gnu.org>
From-SVN: r202125
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index ec79338..06da1cd 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -241,6 +241,22 @@ probably_never_executed_bb_p (struct function *fun, const_basic_block bb) return false; } + +/* Return true in case edge E is probably never executed. */ + +bool +probably_never_executed_edge_p (struct function *fun, edge e) +{ + gcc_checking_assert (fun); + if (profile_info && flag_branch_probabilities) + return ((e->count + profile_info->runs / 2) / profile_info->runs) == 0; + if ((!profile_info || !flag_branch_probabilities) + && (cgraph_get_node (fun->decl)->frequency + == NODE_FREQUENCY_UNLIKELY_EXECUTED)) + return true; + return false; +} + /* Return true if NODE should be optimized for size. */ bool |