]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Introduce -fprofile-update=prefer-atomic
authorMartin Liska <mliska@suse.cz>
Mon, 14 Nov 2016 12:09:48 +0000 (13:09 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 14 Nov 2016 12:09:48 +0000 (12:09 +0000)
PR bootstrap/78069
* common.opt: Add prefer-atomic as a new enum value for
-fprofile-update.
* coretypes.h: Likewise.
* doc/invoke.texi: Document the new option value.
* gcc.c: Replace atomic with prefer-atomic.  Remove warning.
* tree-profile.c (tree_profiling): Select default value
of -fprofile-update when 'prefer-atomic' is selected.
PR bootstrap/78069
* gcc.dg/no_profile_instrument_function-attr-1.c: Update test
to match scanned pattern.
* gcc.dg/tree-ssa/ssa-lim-11.c: Likewise.

From-SVN: r242386

gcc/ChangeLog
gcc/common.opt
gcc/coretypes.h
gcc/doc/invoke.texi
gcc/gcc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-11.c
gcc/tree-profile.c

index e1306dc51d2b4d5aac538e509d00efb6013e6015..f8dc1bd2bf84dc00b48d724494ca96d7087ff297 100644 (file)
@@ -1,3 +1,14 @@
+2016-11-14  Martin Liska  <mliska@suse.cz>
+
+       PR bootstrap/78069
+       * common.opt: Add prefer-atomic as a new enum value for
+       -fprofile-update.
+       * coretypes.h: Likewise.
+       * doc/invoke.texi: Document the new option value.
+       * gcc.c: Replace atomic with prefer-atomic.  Remove warning.
+       * tree-profile.c (tree_profiling): Select default value
+       of -fprofile-update when 'prefer-atomic' is selected.
+
 2016-11-14  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * config/arm/cortex-a57.md (cortex_a57_alu): Move extend here, bfm...
index 314145a09d3ddeb07682e45517323f652f5ec058..5e8d72d6ae673e5be6cac88f9b68e3f4e4f04765 100644 (file)
@@ -1959,7 +1959,7 @@ Enable correction of flow inconsistent profile data input.
 
 fprofile-update=
 Common Joined RejectNegative Enum(profile_update) Var(flag_profile_update) Init(PROFILE_UPDATE_SINGLE)
--fprofile-update=[single|atomic]       Set the profile update method.
+-fprofile-update=[single|atomic|prefer-atomic] Set the profile update method.
 
 Enum
 Name(profile_update) Type(enum profile_update) UnknownError(unknown profile update method %qs)
@@ -1970,6 +1970,9 @@ Enum(profile_update) String(single) Value(PROFILE_UPDATE_SINGLE)
 EnumValue
 Enum(profile_update) String(atomic) Value(PROFILE_UPDATE_ATOMIC)
 
+EnumValue
+Enum(profile_update) String(prefer-atomic) Value(PROFILE_UPDATE_PREFER_ATOMIC)
+
 fprofile-generate
 Common
 Enable common options for generating profile info for profile feedback directed optimizations.
index 869f858d4a13b9f95f72b536ee0ee23b5a7d4522..6d78a25c9719743c37b13848625c32efdbaa77c1 100644 (file)
@@ -177,7 +177,8 @@ enum offload_abi {
 /* Types of profile update methods.  */
 enum profile_update {
   PROFILE_UPDATE_SINGLE,
-  PROFILE_UPDATE_ATOMIC
+  PROFILE_UPDATE_ATOMIC,
+  PROFILE_UPDATE_PREFER_ATOMIC
 };
 
 /* Types of unwind/exception handling info that can be generated.  */
index 4251bc2010e7d5a3ba1886079e1ffed3499d0190..0668d2bb9ee65c48e10ff949187eb517ef4ef006 100644 (file)
@@ -10504,13 +10504,18 @@ To optimize the program based on the collected profile information, use
 
 Alter the update method for an application instrumented for profile
 feedback based optimization.  The @var{method} argument should be one of
-@samp{single} or @samp{atomic}.  The first one is useful for single-threaded
-applications, while the second one prevents profile corruption by emitting
-thread-safe code.
+@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
+The first one is useful for single-threaded applications,
+while the second one prevents profile corruption by emitting thread-safe code.
 
 @strong{Warning:} When an application does not properly join all threads
 (or creates an detached thread), a profile file can be still corrupted.
 
+Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
+when supported by a target, or to @samp{single} otherwise.  The GCC driver
+automatically selects @samp{prefer-atomic} when @option{-pthread}
+is present in the command line.
+
 @item -fsanitize=address
 @opindex fsanitize=address
 Enable AddressSanitizer, a fast memory error detector.
index 5213cb0fafaf4f68d6b284bac4626bc6e865f84f..f78acd68606ceba08cd096ccee972a6b3336c681 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1144,11 +1144,7 @@ static const char *cc1_options =
  %{coverage:-fprofile-arcs -ftest-coverage}\
  %{fprofile-arcs|fprofile-generate*|coverage:\
    %{!fprofile-update=single:\
-     %{pthread:-fprofile-update=atomic}}}\
- %{fprofile-update=single:\
-   %{fprofile-arcs|fprofile-generate*|coverage:\
-     %{pthread:%n-fprofile-update=atomic should be used\
- for a multithreaded application}}}";
+     %{pthread:-fprofile-update=prefer-atomic}}}";
 
 static const char *asm_options =
 "%{-target-help:%:print-asm-header()} "
index bf99ab981b9ac2a9477e7feb3ab052a25b44819f..c47c8b2af5c3425772cc3b0b5c8594fa5f80f408 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-14  Martin Liska  <mliska@suse.cz>
+
+       PR bootstrap/78069
+       * gcc.dg/no_profile_instrument_function-attr-1.c: Update test
+       to match scanned pattern.
+       * gcc.dg/tree-ssa/ssa-lim-11.c: Likewise.
+
 2016-11-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78312
index e0c2600b400c8612062fb0a18f3646d64e2e64a9..f7afb346d7f7507785c030d3902fe80349d6ed6e 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fprofile-generate -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fprofile-generate -fprofile-update=single -fdump-tree-optimized" } */
 
 __attribute__ ((no_profile_instrument_function))
 int foo()
index e4c11aab1959d25cb07cba40c24b930763687e39..4c3898278b112589e41ae68073c9c6f90d66e717 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fprofile-arcs -fdump-tree-lim2-details" } */
+/* { dg-options "-O -fprofile-arcs -fprofile-update=single -fdump-tree-lim2-details" } */
 /* { dg-require-profiling "-fprofile-generate" } */
 
 struct thread_param
index d18b954a385da8549f278fe95659a96df12f9552..a4f9d11b16100731b73225d82b0bdfca0b512c63 100644 (file)
@@ -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().  */