aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-09-06 16:13:21 +0200
committerMartin Liska <marxin@gcc.gnu.org>2016-09-06 14:13:21 +0000
commit7fe76f6ae806fda9a5efe335ccf0e250dd4dde1a (patch)
tree315ef19a1505b76db80cb9f8f37a31a21332de73 /gcc
parent209b636eddd6602c55b4a65237578953b7d80225 (diff)
downloadgcc-7fe76f6ae806fda9a5efe335ccf0e250dd4dde1a.zip
gcc-7fe76f6ae806fda9a5efe335ccf0e250dd4dde1a.tar.gz
gcc-7fe76f6ae806fda9a5efe335ccf0e250dd4dde1a.tar.bz2
Detect whether target can use -fprofile-update=atomic
PR gcov-profile/77378 PR gcov-profile/77466 * libgcov-profiler.c: Use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{4,8} to conditionaly enable/disable *_atomic functions. PR gcov-profile/77378 PR gcov-profile/77466 * tree-profile.c (tree_profiling): Detect whether target can use -fprofile-update=atomic. PR gcov-profile/77378 PR gcov-profile/77466 * gcc.dg/profile-update-warning.c: New test. From-SVN: r240008
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/profile-update-warning.c7
-rw-r--r--gcc/tree-profile.c35
4 files changed, 55 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 87910e4..e23891e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2016-09-06 Martin Liska <mliska@suse.cz>
+
+ PR gcov-profile/77378
+ PR gcov-profile/77466
+ * tree-profile.c (tree_profiling): Detect whether target can use
+ -fprofile-update=atomic.
+
2016-09-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/77479
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9fcda6e..80905ad 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-09-06 Martin Liska <mliska@suse.cz>
+
+ PR gcov-profile/77378
+ PR gcov-profile/77466
+ * gcc.dg/profile-update-warning.c: New test.
+
2016-09-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/77479
diff --git a/gcc/testsuite/gcc.dg/profile-update-warning.c b/gcc/testsuite/gcc.dg/profile-update-warning.c
new file mode 100644
index 0000000..0614fad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/profile-update-warning.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fprofile-update=atomic -fprofile-generate -march=i386 -m32" } */
+
+int main(int argc, char *argv[])
+{
+ return 0;
+} /* { dg-warning "target does not support atomic profile update, single mode is selected" } */
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 622869e..69b48e5 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -528,6 +528,20 @@ gimple_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base)
gsi_insert_before (&gsi, call, GSI_NEW_STMT);
}
+#ifndef HAVE_sync_compare_and_swapsi
+#define HAVE_sync_compare_and_swapsi 0
+#endif
+#ifndef HAVE_atomic_compare_and_swapsi
+#define HAVE_atomic_compare_and_swapsi 0
+#endif
+
+#ifndef HAVE_sync_compare_and_swapdi
+#define HAVE_sync_compare_and_swapdi 0
+#endif
+#ifndef HAVE_atomic_compare_and_swapdi
+#define HAVE_atomic_compare_and_swapdi 0
+#endif
+
/* Profile all functions in the callgraph. */
static unsigned int
@@ -535,6 +549,27 @@ 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 = 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;
+ }
+ }
+
/* This is a small-ipa pass that gets called only once, from
cgraphunit.c:ipa_passes(). */
gcc_assert (symtab->state == IPA_SSA);