* [PATCH] Port value profiling to -fopt-info infrastructure.
@ 2019-08-08 13:42 Martin Liška
2019-08-08 14:21 ` Jeff Law
0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2019-08-08 13:42 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2086 bytes --]
Hi.
As requested by Richi, I'm suggesting to use new dump_printf
optimization info infrastructure.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
2019-08-08 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.
gcc/testsuite/ChangeLog:
2019-08-08 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.
---
.../g++.dg/tree-prof/indir-call-prof.C | 2 +-
gcc/testsuite/g++.dg/tree-prof/morefunc.C | 2 +-
gcc/testsuite/g++.dg/tree-prof/reorder.C | 2 +-
.../gcc.dg/tree-prof/ic-misattribution-1.c | 2 +-
.../gcc.dg/tree-prof/indir-call-prof.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/stringop-1.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/stringop-2.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c | 2 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c | 2 +-
gcc/value-prof.c | 105 +++++++++---------
14 files changed, 64 insertions(+), 67 deletions(-)
[-- Attachment #2: 0001-Port-value-profiling-to-fopt-info-infrastructure.patch --]
[-- Type: text/x-patch, Size: 12699 bytes --]
diff --git a/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
index 3134c3c0643..be896c02774 100644
--- a/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
+++ b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
@@ -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 () {}
diff --git a/gcc/testsuite/g++.dg/tree-prof/morefunc.C b/gcc/testsuite/g++.dg/tree-prof/morefunc.C
index a9bdc167f45..621d09aec5b 100644
--- a/gcc/testsuite/g++.dg/tree-prof/morefunc.C
+++ b/gcc/testsuite/g++.dg/tree-prof/morefunc.C
@@ -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"
diff --git a/gcc/testsuite/g++.dg/tree-prof/reorder.C b/gcc/testsuite/g++.dg/tree-prof/reorder.C
index 6b3bad1f54d..000fb651a69 100644
--- a/gcc/testsuite/g++.dg/tree-prof/reorder.C
+++ b/gcc/testsuite/g++.dg/tree-prof/reorder.C
@@ -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"
diff --git a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
index 3979b17b156..126236eba8e 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
@@ -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);
diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
index 53063c3e7fa..3ca78936e1c 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
@@ -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)
{
diff --git a/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c b/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c
index d75b2548dbc..51e1080b9f4 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c b/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c
index c1f757388fd..0264bb37c9c 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
index 492c4c1c4b2..8495c4caf89 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
index b3bbadfeb40..4f758af71ca 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
index 60953d09b15..5897d750d80 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
index 50ae2de792a..b13601ede69 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
index 80eb3205a4f..982bcb13435 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
@@ -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
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c
index 18b2b2590ac..5ddb1a88c29 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c
@@ -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;
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 759458868a8..9d9785b179d 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -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);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Port value profiling to -fopt-info infrastructure.
2019-08-08 13:42 [PATCH] Port value profiling to -fopt-info infrastructure Martin Liška
@ 2019-08-08 14:21 ` Jeff Law
2019-08-09 8:11 ` Martin Liška
2019-08-09 8:20 ` Richard Biener
0 siblings, 2 replies; 6+ messages in thread
From: Jeff Law @ 2019-08-08 14:21 UTC (permalink / raw)
To: Martin Liška, gcc-patches
On 8/8/19 7:04 AM, Martin Liška wrote:
> Hi.
>
> As requested by Richi, I'm suggesting to use new dump_printf
> optimization info infrastructure.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2019-08-08 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.
>
> gcc/testsuite/ChangeLog:
>
> 2019-08-08 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.
> ---
> .../g++.dg/tree-prof/indir-call-prof.C | 2 +-
> diff --git a/gcc/value-prof.c b/gcc/value-prof.c
> index 759458868a8..9d9785b179d 100644
> --- a/gcc/value-prof.c
> +++ b/gcc/value-prof.c
> @@ -809,12 +809,9 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
> @@ -1445,41 +1447,36 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
[ ... ]
> - 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);
> }
It's not entirely clear if you want MSG_OPTIMIZED_LOCATION vs
MSG_MISSED_OPTIMIZATION here. Double check and adjust if needed.
OK with or without that adjustment.
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Port value profiling to -fopt-info infrastructure.
2019-08-08 14:21 ` Jeff Law
@ 2019-08-09 8:11 ` Martin Liška
2019-08-09 8:20 ` Richard Biener
1 sibling, 0 replies; 6+ messages in thread
From: Martin Liška @ 2019-08-09 8:11 UTC (permalink / raw)
To: Jeff Law, gcc-patches
On 8/8/19 4:17 PM, Jeff Law wrote:
> On 8/8/19 7:04 AM, Martin Liška wrote:
>> Hi.
>>
>> As requested by Richi, I'm suggesting to use new dump_printf
>> optimization info infrastructure.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2019-08-08 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.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2019-08-08 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.
>> ---
>> .../g++.dg/tree-prof/indir-call-prof.C | 2 +-
>> diff --git a/gcc/value-prof.c b/gcc/value-prof.c
>> index 759458868a8..9d9785b179d 100644
>> --- a/gcc/value-prof.c
>> +++ b/gcc/value-prof.c
>> @@ -809,12 +809,9 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
>> @@ -1445,41 +1447,36 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
> [ ... ]
>> - 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);
>> }
> It's not entirely clear if you want MSG_OPTIMIZED_LOCATION vs
> MSG_MISSED_OPTIMIZATION here. Double check and adjust if needed.
Yes, I want MSG_OPTIMIZED_LOCATIONS as we optimize here but postpone
the transformation.
Thanks for review,
Martin
>
> OK with or without that adjustment.
>
> Jeff
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Port value profiling to -fopt-info infrastructure.
2019-08-08 14:21 ` Jeff Law
2019-08-09 8:11 ` Martin Liška
@ 2019-08-09 8:20 ` Richard Biener
2019-08-09 13:57 ` Martin Liška
1 sibling, 1 reply; 6+ messages in thread
From: Richard Biener @ 2019-08-09 8:20 UTC (permalink / raw)
To: Jeff Law; +Cc: Martin Liška, GCC Patches
On Thu, Aug 8, 2019 at 4:17 PM Jeff Law <law@redhat.com> wrote:
>
> On 8/8/19 7:04 AM, Martin Liška wrote:
> > Hi.
> >
> > As requested by Richi, I'm suggesting to use new dump_printf
> > optimization info infrastructure.
> >
> > Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> >
> > Ready to be installed?
> > Thanks,
> > Martin
> >
> > gcc/ChangeLog:
> >
> > 2019-08-08 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.
> >
> > gcc/testsuite/ChangeLog:
> >
> > 2019-08-08 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.
> > ---
> > .../g++.dg/tree-prof/indir-call-prof.C | 2 +-
> > diff --git a/gcc/value-prof.c b/gcc/value-prof.c
> > index 759458868a8..9d9785b179d 100644
> > --- a/gcc/value-prof.c
> > +++ b/gcc/value-prof.c
> > @@ -809,12 +809,9 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
> > @@ -1445,41 +1447,36 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
> [ ... ]
> > - 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);
> > }
> It's not entirely clear if you want MSG_OPTIMIZED_LOCATION vs
> MSG_MISSED_OPTIMIZATION here. Double check and adjust if needed.
But we don't want multi-line stuff here but a single message for
MSG_OPTIMIZED_LOCATION, eventually detail printed with MSG_NOTE.
Can you adjust accordingly, esp. try not dumping GIMPLE stmts for
the non-NOTE message give it is directed at users. So just
Indirect call -> direct call %T -> %T transformation
(without the postponed stuff, that's implementation detail not interesting).
Richard.
> OK with or without that adjustment.
>
> Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Port value profiling to -fopt-info infrastructure.
2019-08-09 8:20 ` Richard Biener
@ 2019-08-09 13:57 ` Martin Liška
2019-08-12 15:17 ` Jeff Law
0 siblings, 1 reply; 6+ messages in thread
From: Martin Liška @ 2019-08-09 13:57 UTC (permalink / raw)
To: Richard Biener, Jeff Law; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 3864 bytes --]
On 8/9/19 10:13 AM, Richard Biener wrote:
> On Thu, Aug 8, 2019 at 4:17 PM Jeff Law <law@redhat.com> wrote:
>>
>> On 8/8/19 7:04 AM, Martin Liška wrote:
>>> Hi.
>>>
>>> As requested by Richi, I'm suggesting to use new dump_printf
>>> optimization info infrastructure.
>>>
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>
>>> Ready to be installed?
>>> Thanks,
>>> Martin
>>>
>>> gcc/ChangeLog:
>>>
>>> 2019-08-08 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.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 2019-08-08 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.
>>> ---
>>> .../g++.dg/tree-prof/indir-call-prof.C | 2 +-
>>> diff --git a/gcc/value-prof.c b/gcc/value-prof.c
>>> index 759458868a8..9d9785b179d 100644
>>> --- a/gcc/value-prof.c
>>> +++ b/gcc/value-prof.c
>>> @@ -809,12 +809,9 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
>>> @@ -1445,41 +1447,36 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
>> [ ... ]
>>> - 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);
>>> }
>> It's not entirely clear if you want MSG_OPTIMIZED_LOCATION vs
>> MSG_MISSED_OPTIMIZATION here. Double check and adjust if needed.
>
> But we don't want multi-line stuff here but a single message for
> MSG_OPTIMIZED_LOCATION, eventually detail printed with MSG_NOTE.
> Can you adjust accordingly, esp. try not dumping GIMPLE stmts for
> the non-NOTE message give it is directed at users. So just
>
> Indirect call -> direct call %T -> %T transformation
>
> (without the postponed stuff, that's implementation detail not interesting).
Ok, there's a patch that I've just tested.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
>
> Richard.
>
>> OK with or without that adjustment.
>>
>> Jeff
[-- Attachment #2: 0001-Simplify-dump_printf-in-value-prof.c.patch --]
[-- Type: text/x-patch, Size: 2311 bytes --]
From 4eafa3655a6f557d69c2c41e29634a8c805ea8cc Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Fri, 9 Aug 2019 14:34:55 +0200
Subject: [PATCH] Simplify dump_printf in value-prof.c
gcc/ChangeLog:
2019-08-09 Martin Liska <mliska@suse.cz>
* value-prof.c (gimple_ic_transform): Add new line.
Print details with MSG_NOTE.
gcc/testsuite/ChangeLog:
2019-08-09 Martin Liska <mliska@suse.cz>
* gcc.dg/tree-prof/ic-misattribution-1.c: Use -fdump-ipa-profile-node.
---
gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c | 2 +-
gcc/value-prof.c | 9 ++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
index 126236eba8e..0c69045591b 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-ipa-profile-optimized" } */
+/* { dg-options "-O2 -fdump-ipa-profile-note" } */
/* { dg-additional-sources "ic-misattribution-1a.c" } */
extern void other_caller (void);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 9d9785b179d..00ede8d985f 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1450,7 +1450,7 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
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)",
+ "module %T=> %i (will resolve only with LTO)\n",
gimple_call_fn (stmt), (int)val);
}
return false;
@@ -1471,10 +1471,9 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
{
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,
+ "%T => %T transformation on insn postponed\n",
+ gimple_call_fn (stmt), direct_call->decl);
+ dump_printf_loc (MSG_NOTE, stmt,
"hist->count %" PRId64
" hist->all %" PRId64"\n", count, all);
}
--
2.22.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Port value profiling to -fopt-info infrastructure.
2019-08-09 13:57 ` Martin Liška
@ 2019-08-12 15:17 ` Jeff Law
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Law @ 2019-08-12 15:17 UTC (permalink / raw)
To: Martin Liška, Richard Biener; +Cc: GCC Patches
On 8/9/19 7:13 AM, Martin Liška wrote:
> On 8/9/19 10:13 AM, Richard Biener wrote:
>> On Thu, Aug 8, 2019 at 4:17 PM Jeff Law <law@redhat.com> wrote:
>>> On 8/8/19 7:04 AM, Martin Liška wrote:
>>>> Hi.
>>>>
>>>> As requested by Richi, I'm suggesting to use new dump_printf
>>>> optimization info infrastructure.
>>>>
>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>>
>>>> Ready to be installed?
>>>> Thanks,
>>>> Martin
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>> 2019-08-08 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.
>>>>
>>>> gcc/testsuite/ChangeLog:
>>>>
>>>> 2019-08-08 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.
>>>> ---
>>>> .../g++.dg/tree-prof/indir-call-prof.C | 2 +-
>>>> diff --git a/gcc/value-prof.c b/gcc/value-prof.c
>>>> index 759458868a8..9d9785b179d 100644
>>>> --- a/gcc/value-prof.c
>>>> +++ b/gcc/value-prof.c
>>>> @@ -809,12 +809,9 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
>>>> @@ -1445,41 +1447,36 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
>>> [ ... ]
>>>> - 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);
>>>> }
>>> It's not entirely clear if you want MSG_OPTIMIZED_LOCATION vs
>>> MSG_MISSED_OPTIMIZATION here. Double check and adjust if needed.
>> But we don't want multi-line stuff here but a single message for
>> MSG_OPTIMIZED_LOCATION, eventually detail printed with MSG_NOTE.
>> Can you adjust accordingly, esp. try not dumping GIMPLE stmts for
>> the non-NOTE message give it is directed at users. So just
>>
>> Indirect call -> direct call %T -> %T transformation
>>
>> (without the postponed stuff, that's implementation detail not interesting).
> Ok, there's a patch that I've just tested.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
>> Richard.
>>
>>> OK with or without that adjustment.
>>>
>>> Jeff
>
>
> 0001-Simplify-dump_printf-in-value-prof.c.patch
>
> From 4eafa3655a6f557d69c2c41e29634a8c805ea8cc Mon Sep 17 00:00:00 2001
> From: Martin Liska <mliska@suse.cz>
> Date: Fri, 9 Aug 2019 14:34:55 +0200
> Subject: [PATCH] Simplify dump_printf in value-prof.c
>
> gcc/ChangeLog:
>
> 2019-08-09 Martin Liska <mliska@suse.cz>
>
> * value-prof.c (gimple_ic_transform): Add new line.
> Print details with MSG_NOTE.
>
> gcc/testsuite/ChangeLog:
>
> 2019-08-09 Martin Liska <mliska@suse.cz>
>
> * gcc.dg/tree-prof/ic-misattribution-1.c: Use -fdump-ipa-profile-node.
OK
jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-12 14:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 13:42 [PATCH] Port value profiling to -fopt-info infrastructure Martin Liška
2019-08-08 14:21 ` Jeff Law
2019-08-09 8:11 ` Martin Liška
2019-08-09 8:20 ` Richard Biener
2019-08-09 13:57 ` Martin Liška
2019-08-12 15:17 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).