summaryrefslogtreecommitdiff
path: root/gcc/tree-profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-profile.c')
-rw-r--r--gcc/tree-profile.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index d18b954a385..a4f9d11b161 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -592,25 +592,26 @@ tree_profiling (void)
struct cgraph_node *node;
/* Verify whether we can utilize atomic update operations. */
- if (flag_profile_update == PROFILE_UPDATE_ATOMIC)
+ bool can_support_atomic = false;
+ unsigned HOST_WIDE_INT gcov_type_size
+ = tree_to_uhwi (TYPE_SIZE_UNIT (get_gcov_type ()));
+ if (gcov_type_size == 4)
+ can_support_atomic
+ = HAVE_sync_compare_and_swapsi || HAVE_atomic_compare_and_swapsi;
+ else if (gcov_type_size == 8)
+ can_support_atomic
+ = HAVE_sync_compare_and_swapdi || HAVE_atomic_compare_and_swapdi;
+
+ if (flag_profile_update == PROFILE_UPDATE_ATOMIC
+ && !can_support_atomic)
{
- bool can_support = false;
- unsigned HOST_WIDE_INT gcov_type_size
- = tree_to_uhwi (TYPE_SIZE_UNIT (get_gcov_type ()));
- if (gcov_type_size == 4)
- can_support
- = HAVE_sync_compare_and_swapsi || HAVE_atomic_compare_and_swapsi;
- else if (gcov_type_size == 8)
- can_support
- = HAVE_sync_compare_and_swapdi || HAVE_atomic_compare_and_swapdi;
-
- if (!can_support)
- {
- warning (0, "target does not support atomic profile update, "
- "single mode is selected");
- flag_profile_update = PROFILE_UPDATE_SINGLE;
- }
+ warning (0, "target does not support atomic profile update, "
+ "single mode is selected");
+ flag_profile_update = PROFILE_UPDATE_SINGLE;
}
+ else if (flag_profile_update == PROFILE_UPDATE_PREFER_ATOMIC)
+ flag_profile_update = can_support_atomic
+ ? PROFILE_UPDATE_ATOMIC : PROFILE_UPDATE_SINGLE;
/* This is a small-ipa pass that gets called only once, from
cgraphunit.c:ipa_passes(). */