Port value profiling to -fopt-info infrastructure.
authorMartin Liska <mliska@suse.cz>
Fri, 9 Aug 2019 07:47:35 +0000 (09:47 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 9 Aug 2019 07:47:35 +0000 (07:47 +0000)
2019-08-09  Martin Liska  <mliska@suse.cz>

* value-prof.c (gimple_divmod_fixed_value_transform):
Use dump_printf_loc.
(gimple_mod_pow2_value_transform): Likewise.
(gimple_mod_subtract_transform): Likewise.
(init_node_map): Likewise.
(gimple_ic_transform): Likewise.
(gimple_stringops_transform): Likewise.
2019-08-09  Martin Liska  <mliska@suse.cz>

* g++.dg/tree-prof/indir-call-prof.C: Add -optimize
to -fdump-ipa-profile.
* g++.dg/tree-prof/morefunc.C: Likewise.
* g++.dg/tree-prof/reorder.C: Likewise.
* gcc.dg/tree-prof/ic-misattribution-1.c: Likewise.
* gcc.dg/tree-prof/indir-call-prof.c: Likewise.
* gcc.dg/tree-prof/stringop-1.c: Likewise.
* gcc.dg/tree-prof/stringop-2.c: Likewise.
* gcc.dg/tree-prof/val-prof-1.c: Likewise.
* gcc.dg/tree-prof/val-prof-2.c: Likewise.
* gcc.dg/tree-prof/val-prof-3.c: Likewise.
* gcc.dg/tree-prof/val-prof-4.c: Likewise.
* gcc.dg/tree-prof/val-prof-5.c: Likewise.
* gcc.dg/tree-prof/val-prof-7.c: Likewise.

From-SVN: r274229

16 files changed:
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
gcc/testsuite/g++.dg/tree-prof/morefunc.C
gcc/testsuite/g++.dg/tree-prof/reorder.C
gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
gcc/testsuite/gcc.dg/tree-prof/stringop-1.c
gcc/testsuite/gcc.dg/tree-prof/stringop-2.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c
gcc/value-prof.c

index 25d09566a406785ee427a73fc89cb4d8c4c10861..b8d54e1380a284da4ff33a479b3ef6b0983e9894 100644 (file)
@@ -1,3 +1,13 @@
+2019-08-09  Martin Liska  <mliska@suse.cz>
+
+       * value-prof.c (gimple_divmod_fixed_value_transform):
+       Use dump_printf_loc.
+       (gimple_mod_pow2_value_transform): Likewise.
+       (gimple_mod_subtract_transform): Likewise.
+       (init_node_map): Likewise.
+       (gimple_ic_transform): Likewise.
+       (gimple_stringops_transform): Likewise.
+
 2019-08-08  Mihailo Stojanovic <mistojanovic@wavecomp.com>
 
        * doc/extend.texi: Add const qualifier to ld intrinsics.
index a31e2613dff9a01887fb1d6c33c6584b402e14ca..e64565e04671e2e61cafbe8c9f6bf43b49ec978b 100644 (file)
@@ -1,3 +1,20 @@
+2019-08-09  Martin Liska  <mliska@suse.cz>
+
+       * g++.dg/tree-prof/indir-call-prof.C: Add -optimize
+       to -fdump-ipa-profile.
+       * g++.dg/tree-prof/morefunc.C: Likewise.
+       * g++.dg/tree-prof/reorder.C: Likewise.
+       * gcc.dg/tree-prof/ic-misattribution-1.c: Likewise.
+       * gcc.dg/tree-prof/indir-call-prof.c: Likewise.
+       * gcc.dg/tree-prof/stringop-1.c: Likewise.
+       * gcc.dg/tree-prof/stringop-2.c: Likewise.
+       * gcc.dg/tree-prof/val-prof-1.c: Likewise.
+       * gcc.dg/tree-prof/val-prof-2.c: Likewise.
+       * gcc.dg/tree-prof/val-prof-3.c: Likewise.
+       * gcc.dg/tree-prof/val-prof-4.c: Likewise.
+       * gcc.dg/tree-prof/val-prof-5.c: Likewise.
+       * gcc.dg/tree-prof/val-prof-7.c: Likewise.
+
 2019-08-09  Jakub Jelinek  <jakub@redhat.com>
 
        * c-c++-common/gomp/if-4.c: New test.
index 3134c3c06437df56ef6d880791f926170d59e84c..be896c02774f2a7aa7ac9b795ad0d9d2e951826f 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile -fdump-ipa-afdo" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized -fdump-ipa-afdo" } */
 
 struct A {
   A () {}
index a9bdc167f4559a2e623cb2682e58c3af2bf5baa0..621d09aec5b337f7ebf91a09278f1e911b79dbcc 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -fdump-ipa-afdo -Wno-attributes -Wno-coverage-mismatch -Wno-missing-profile" } */
+/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile-optimized -fdump-ipa-afdo -Wno-attributes -Wno-coverage-mismatch -Wno-missing-profile" } */
 #include "reorder_class1.h"
 #include "reorder_class2.h"
 
index 6b3bad1f54d9e73ced3e756feded82f85f3c0cf4..000fb651a692ec784380c679e79bcd4546527dc1 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -fdump-ipa-afdo -Wno-coverage-mismatch -Wno-attributes" } */
+/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile-optimized -fdump-ipa-afdo -Wno-coverage-mismatch -Wno-attributes" } */
 
 #ifdef _PROFILE_USE
 #include "reorder_class1.h"
index 3979b17b1568420e565c8fee4044c51dc1020624..126236eba8e23a90459e6f3af2abf2852f50ee62 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-ipa-profile-optimized" } */
 /* { dg-additional-sources "ic-misattribution-1a.c" } */
 
 extern void other_caller (void);
index 53063c3e7fa619d1f3e02f8dafba8970dd53d2a9..3ca78936e1c3f87fbe2808869c1a367cb317533a 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile -fdump-ipa-afdo" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized -fdump-ipa-afdo" } */
 
 static int a1 (void)
 {
index d75b2548dbc42b57330ed96e5213256f87b1996b..51e1080b9f4ae281b077fb9ec0cd71d08806fcec 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 int a[1000];
 int b[1000];
 int size=1;
index c1f757388fd66fd2e92b81807906dc9f9ad19bfb..0264bb37c9cca94090a1dec6856cce3f2d16fdb6 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 int a[1000];
 int b[1000];
 int size=1;
index 492c4c1c4b2d10dc0186c2061e17a3043f02ffc4..8495c4caf89b349fd214c26dd3059f76502130f3 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 int a[1000];
 int b = 256;
 int c = 257;
index b3bbadfeb40a27cae0e2f1098ce8838d0dd48006..4f758af71ca9a3adf1d4e7747718d5f15c4e0086 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 unsigned int a[1000];
 unsigned int b = 256;
 unsigned int c = 1024;
index 60953d09b15900cf53656f40034876e86f829b1d..5897d750d80ee5aa797ca82771c717f47c53ca0c 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 unsigned int a[1000];
 unsigned int b = 257;
 unsigned int c = 1023;
index 50ae2de792ac8e61f484e01e328873d1b9ed7475..b13601ede69f8dedbebb273b52cd7a2fa4b5b675 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 unsigned int a[1000];
 unsigned int b = 999;
 unsigned int c = 1002;
index 80eb3205a4f7c1b9422c2c8af67bd45cde5e97a2..982bcb1343523dfe59598503d0539c9d37e57550 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
 int a[1000];
 int b=997;
 int
index 18b2b2590acf47a7e139639cbab905ac2fee66b3..5ddb1a88c29396b661848e67c5f3bbb813c99cd0 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-ipa-profile -mtune=core2" } */
+/* { dg-options "-O2 -fdump-ipa-profile-optimized -mtune=core2" } */
 /* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } } */
 
 char *buffer1;
index 759458868a89025ac74b903f110b89bb001f86cb..9d9785b179d6ea3b86e6ec82606d88e6da1f2a72 100644 (file)
@@ -809,12 +809,9 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
     }
   result = gimple_divmod_fixed_value (stmt, tree_val, prob, count, all);
 
-  if (dump_file)
-    {
-      fprintf (dump_file, "Transformation done: div/mod by constant ");
-      print_generic_expr (dump_file, tree_val, TDF_SLIM);
-      fprintf (dump_file, "\n");
-    }
+  if (dump_enabled_p ())
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, stmt,
+                    "Transformation done: div/mod by constant %T\n", tree_val);
 
   gimple_assign_set_rhs_from_tree (si, result);
   update_stmt (gsi_stmt (*si));
@@ -949,8 +946,9 @@ gimple_mod_pow2_value_transform (gimple_stmt_iterator *si)
   if (check_counter (stmt, "pow2", &count, &all, gimple_bb (stmt)->count))
     return false;
 
-  if (dump_file)
-    fprintf (dump_file, "Transformation done: mod power of 2\n");
+  if (dump_enabled_p ())
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, stmt,
+                    "Transformation done: mod power of 2\n");
 
   if (all > 0)
     prob = profile_probability::probability_in_gcov_type (count, all);
@@ -1133,8 +1131,9 @@ gimple_mod_subtract_transform (gimple_stmt_iterator *si)
     return false;
 
   gimple_remove_histogram_value (cfun, stmt, histogram);
-  if (dump_file)
-    fprintf (dump_file, "Transformation done: mod subtract\n");
+  if (dump_enabled_p ())
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, stmt,
+                    "Transformation done: mod subtract\n");
 
   /* Compute probability of taking the optimal path(s).  */
   if (all > 0)
@@ -1185,37 +1184,40 @@ init_node_map (bool local)
     if (n->has_gimple_body_p () || n->thunk.thunk_p)
       {
        cgraph_node **val;
+       dump_user_location_t loc
+         = dump_user_location_t::from_function_decl (n->decl);
        if (local)
          {
            n->profile_id = coverage_compute_profile_id (n);
            while ((val = cgraph_node_map->get (n->profile_id))
                   || !n->profile_id)
              {
-               if (dump_file)
-                 fprintf (dump_file, "Local profile-id %i conflict"
-                          " with nodes %s %s\n",
-                          n->profile_id,
-                          n->dump_name (),
-                          (*val)->dump_name ());
+               if (dump_enabled_p ())
+                 dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                                  "Local profile-id %i conflict"
+                                  " with nodes %s %s\n",
+                                  n->profile_id,
+                                  n->dump_name (),
+                                  (*val)->dump_name ());
                n->profile_id = (n->profile_id + 1) & 0x7fffffff;
              }
          }
        else if (!n->profile_id)
          {
-           if (dump_file)
-             fprintf (dump_file,
-                      "Node %s has no profile-id"
-                      " (profile feedback missing?)\n",
-                      n->dump_name ());
+           if (dump_enabled_p ())
+             dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                              "Node %s has no profile-id"
+                              " (profile feedback missing?)\n",
+                              n->dump_name ());
            continue;
          }
        else if ((val = cgraph_node_map->get (n->profile_id)))
          {
-           if (dump_file)
-             fprintf (dump_file,
-                      "Node %s has IP profile-id %i conflict. "
-                      "Giving up.\n",
-                      n->dump_name (), n->profile_id);
+           if (dump_enabled_p ())
+             dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                              "Node %s has IP profile-id %i conflict. "
+                              "Giving up.\n",
+                              n->dump_name (), n->profile_id);
            *val = NULL;
            continue;
          }
@@ -1445,41 +1447,36 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
     {
       if (val)
        {
-         if (dump_file)
-           {
-             fprintf (dump_file, "Indirect call -> direct call from other module");
-             print_generic_expr (dump_file, gimple_call_fn (stmt), TDF_SLIM);
-             fprintf (dump_file, "=> %i (will resolve only with LTO)\n", (int)val);
-           }
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, stmt,
+                            "Indirect call -> direct call from other "
+                            "module %T=> %i (will resolve only with LTO)",
+                            gimple_call_fn (stmt), (int)val);
        }
       return false;
     }
 
   if (!check_ic_target (stmt, direct_call))
     {
-      if (dump_file)
-       {
-         fprintf (dump_file, "Indirect call -> direct call ");
-         print_generic_expr (dump_file, gimple_call_fn (stmt), TDF_SLIM);
-         fprintf (dump_file, "=> ");
-         print_generic_expr (dump_file, direct_call->decl, TDF_SLIM);
-         fprintf (dump_file, " transformation skipped because of type mismatch");
-         print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
-       }
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, stmt,
+                        "Indirect call -> direct call %T => %T "
+                        "transformation skipped because of type mismatch: %G",
+                        gimple_call_fn (stmt), direct_call->decl, stmt);
       gimple_remove_histogram_value (cfun, stmt, histogram);
       return false;
     }
 
-  if (dump_file)
+  if (dump_enabled_p ())
     {
-      fprintf (dump_file, "Indirect call -> direct call ");
-      print_generic_expr (dump_file, gimple_call_fn (stmt), TDF_SLIM);
-      fprintf (dump_file, "=> ");
-      print_generic_expr (dump_file, direct_call->decl, TDF_SLIM);
-      fprintf (dump_file, " transformation on insn postponned to ipa-profile");
-      print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
-      fprintf (dump_file, "hist->count %" PRId64
-              " hist->all %" PRId64"\n", count, all);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, stmt,
+                      "Indirect call -> direct call "
+                      "%T => %T transformation on insn postponed "
+                      "to ipa-profile: %G", gimple_call_fn (stmt),
+                      direct_call->decl, stmt);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, stmt,
+                      "hist->count %" PRId64
+                      " hist->all %" PRId64"\n", count, all);
     }
 
   return true;
@@ -1708,10 +1705,10 @@ gimple_stringops_transform (gimple_stmt_iterator *gsi)
        TYPE_PRECISION (get_gcov_type ()), false));
     }
 
-  if (dump_file)
-    fprintf (dump_file,
-            "Transformation done: single value %i stringop for %s\n",
-            (int)val, built_in_names[(int)fcode]);
+  if (dump_enabled_p ())
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, stmt,
+                    "Transformation done: single value %i stringop for %s\n",
+                    (int)val, built_in_names[(int)fcode]);
 
   gimple_stringop_fixed_value (stmt, tree_val, prob, count, all);