]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcov: No atomic ops for -fprofile-update=single
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Thu, 23 Nov 2023 13:45:50 +0000 (14:45 +0100)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Thu, 23 Nov 2023 14:54:43 +0000 (15:54 +0100)
gcc/ChangeLog:

PR tree-optimization/112678

* tree-profile.cc (tree_profiling): Do not use atomic operations
for -fprofile-update=single.

gcc/tree-profile.cc

index 1ac0fdb3bc98d90e813902fe71191f7ad95461f1..9c8fdb8b18f44b3ffd60a50a1aa76c2b4f5102e0 100644 (file)
@@ -767,6 +767,7 @@ tree_profiling (void)
     = HAVE_sync_compare_and_swapsi || HAVE_atomic_compare_and_swapsi;
   bool have_atomic_8
     = HAVE_sync_compare_and_swapdi || HAVE_atomic_compare_and_swapdi;
+  bool needs_split = gcov_type_size == 8 && !have_atomic_8 && have_atomic_4;
   if (!can_support_atomic)
     {
       if (gcov_type_size == 4)
@@ -775,6 +776,9 @@ tree_profiling (void)
        can_support_atomic = have_atomic_8;
     }
 
+  if (flag_profile_update != PROFILE_UPDATE_SINGLE && needs_split)
+    counter_update = COUNTER_UPDATE_ATOMIC_PARTIAL;
+
   if (flag_profile_update == PROFILE_UPDATE_ATOMIC
       && !can_support_atomic)
     {
@@ -788,13 +792,11 @@ tree_profiling (void)
 
   if (flag_profile_update == PROFILE_UPDATE_ATOMIC)
     {
-      if (gcov_type_size == 8 && !have_atomic_8 && have_atomic_4)
+      if (needs_split)
        counter_update = COUNTER_UPDATE_ATOMIC_SPLIT;
       else
        counter_update = COUNTER_UPDATE_ATOMIC_BUILTIN;
     }
-  else if (gcov_type_size == 8 && have_atomic_4)
-    counter_update = COUNTER_UPDATE_ATOMIC_PARTIAL;
 
   /* This is a small-ipa pass that gets called only once, from
      cgraphunit.cc:ipa_passes().  */