]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcov: Fix counter update method selection
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Mon, 29 Dec 2025 23:41:38 +0000 (00:41 +0100)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 6 Jan 2026 23:23:50 +0000 (00:23 +0100)
The counter update method selection had some issues.

For PROFILE_UPDATE_ATOMIC, if atomic updates are not supported, then
fallback to single mode, however, use partial atomic updates if
available.  Issue warnings.

For PROFILE_UPDATE_PRFER_ATOMIC, if atomic updates are not supported,
then fallback to single mode, however, use partial atomic updates if
available.  Do not issue warnings.

gcc/ChangeLog:

* tree-profile.cc (tree_profiling): Do not use atomic operations
if they are not available.  Try to use at least partial atomic
updates as a fallback.

gcc/tree-profile.cc

index b8d9c76e466fc3eb49b81af201b89296539d8816..885716535f1c0654335506f3cfbaf5f469a47f33 100644 (file)
@@ -1847,19 +1847,32 @@ 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)
     {
-      warning (0, "target does not support atomic profile update, "
-              "single mode is selected");
+      if (needs_split)
+       {
+         warning (0, "target does not fully support atomic profile "
+                  "update, single mode is selected with partial "
+                  "atomic updates");
+         counter_update = COUNTER_UPDATE_ATOMIC_PARTIAL;
+       }
+      else
+       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;
+    {
+      if (can_support_atomic)
+       flag_profile_update = PROFILE_UPDATE_ATOMIC;
+      else
+       {
+         if (needs_split)
+           counter_update = COUNTER_UPDATE_ATOMIC_PARTIAL;
+         flag_profile_update = PROFILE_UPDATE_SINGLE;
+       }
+    }
 
   if (flag_profile_update == PROFILE_UPDATE_ATOMIC)
     {