Re: [PATCH] Add -fprofile-note option.

2019-07-08 Thread Sandra Loosemore

On 7/8/19 11:43 AM, Martin Liška wrote:


@@ -12407,7 +12407,9 @@ To optimize the program based on the collected profile 
information, use
 @item -fprofile-note=@var{path}
 @opindex fprofile-note
 
-If @var{path} is specified, GCC saves gcno filename into @var{path} location.

+If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
+location.  If you not combine the option with multiple source files,


s/not // ??
It doesn't make sense as written.


+the @file{.gcno} file will be overwritten.
 
 @item -fprofile-update=@var{method}

 @opindex fprofile-update


-Sandra


Re: [PATCH] Add -fprofile-note option.

2019-07-08 Thread Martin Liška

On 7/4/19 1:15 AM, Sandra Loosemore wrote:

On 7/2/19 6:37 AM, Martin Liška wrote:


@@ -12403,6 +12403,11 @@ the profile feedback data files. See 
@option{-fprofile-dir}.
 To optimize the program based on the collected profile information, use
 @option{-fprofile-use}.  @xref{Optimize Options}, for more information.

+@item -fprofile-note=@var{path}
+@opindex fprofile-note
+
+If @var{path} is specified, GCC saves gcno filename into @var{path} location.
+
 @item -fprofile-update=@var{method}
 @opindex fprofile-update




Hi.



"gcno filename" is implementor-speak with no context.  In other places the documentation 
uses "@file{.gcno} file".  Please use that here as well, and add a @cindex entry on the 
main definition/discussion of these things and a cross-reference here.


Thank you for the comments. Yes, the suggested wording is much bettern.



I assume this option only makes sense with some other profiling options.  What 
are they?


Yes, I listed the option in the section.



Can there be more than one of these files per gcc invocation?  E.g. if you 
specify a command line like

gcc -c foo.c bar.c

??  It looks like the code part of the patch would cause the file to be 
overwritten.  Maybe this should be like -o and diagnose an error?


Yes, it can be combined, I added a caveat into documentation patch.

Martin



-Sandra



>From d1182429f5565a4e82f035af30ef98151fc36a48 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Mon, 8 Jul 2019 19:37:53 +0200
Subject: [PATCH] Enhance documentation of -fprofile-note option.

gcc/ChangeLog:

2019-07-08  Martin Liska  

	* doc/invoke.texi: Add link from -fprofile-dir option.
	Use better wording for 'gcno filename'.
---
 gcc/doc/invoke.texi | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 73d16b59d91..6c1692eb4b7 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12369,7 +12369,7 @@ profile data file appears in the same directory as the object file.
 In order to prevent the file name clashing, if the object file name is
 not an absolute path, we mangle the absolute path of the
 @file{@var{sourcename}.gcda} file and use it as the file name of a
-@file{.gcda} file.
+@file{.gcda} file.  See similar option @option{-fprofile-note}.
 
 When an executable is run in a massive parallel environment, it is recommended
 to save profile to different folders.  That can be done with variables
@@ -12407,7 +12407,9 @@ To optimize the program based on the collected profile information, use
 @item -fprofile-note=@var{path}
 @opindex fprofile-note
 
-If @var{path} is specified, GCC saves gcno filename into @var{path} location.
+If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
+location.  If you not combine the option with multiple source files,
+the @file{.gcno} file will be overwritten.
 
 @item -fprofile-update=@var{method}
 @opindex fprofile-update
-- 
2.22.0



Re: [PATCH] Add -fprofile-note option.

2019-07-03 Thread Sandra Loosemore

On 7/2/19 6:37 AM, Martin Liška wrote:


@@ -12403,6 +12403,11 @@ the profile feedback data files. See 
@option{-fprofile-dir}.
 To optimize the program based on the collected profile information, use
 @option{-fprofile-use}.  @xref{Optimize Options}, for more information.
 
+@item -fprofile-note=@var{path}

+@opindex fprofile-note
+
+If @var{path} is specified, GCC saves gcno filename into @var{path} location.
+
 @item -fprofile-update=@var{method}
 @opindex fprofile-update
 



"gcno filename" is implementor-speak with no context.  In other places 
the documentation uses "@file{.gcno} file".  Please use that here as 
well, and add a @cindex entry on the main definition/discussion of these 
things and a cross-reference here.


I assume this option only makes sense with some other profiling options. 
 What are they?


Can there be more than one of these files per gcc invocation?  E.g. if 
you specify a command line like


gcc -c foo.c bar.c

??  It looks like the code part of the patch would cause the file to be 
overwritten.  Maybe this should be like -o and diagnose an error?


-Sandra



Re: [PATCH] Add -fprofile-note option.

2019-07-02 Thread Jeff Law
On 7/2/19 6:37 AM, Martin Liška wrote:
> Hi.
> 
> The patch is about a new option that can be handy when you pipe
> output and you do not use an object file.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2019-07-02  Martin Liska  
> 
>   * common.opt: Add fprofile-note.
>   * coverage.c (coverage_init): Append the option
>   to bbg_file_name.
>   * doc/invoke.texi: Document -fprofile-note.
OK
jeff


[PATCH] Add -fprofile-note option.

2019-07-02 Thread Martin Liška
Hi.

The patch is about a new option that can be handy when you pipe
output and you do not use an object file.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-07-02  Martin Liska  

* common.opt: Add fprofile-note.
* coverage.c (coverage_init): Append the option
to bbg_file_name.
* doc/invoke.texi: Document -fprofile-note.
---
 gcc/common.opt  |  4 
 gcc/coverage.c  | 11 ---
 gcc/doc/invoke.texi |  9 +++--
 3 files changed, 19 insertions(+), 5 deletions(-)


diff --git a/gcc/common.opt b/gcc/common.opt
index a1544d06824..c1b90562b9b 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2096,6 +2096,10 @@ Common Joined RejectNegative Var(profile_data_prefix)
 Set the top-level directory for storing the profile data.
 The default is 'pwd'.
 
+fprofile-note=
+Common Joined RejectNegative Var(profile_note_location)
+Select the name for storing the profile note file.
+
 fprofile-correction
 Common Report Var(flag_profile_correction)
 Enable correction of flow inconsistent profile data input.
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 1ffefd5f482..960ff7ee86a 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1255,9 +1255,14 @@ coverage_init (const char *filename)
   /* Name of bbg file.  */
   if (flag_test_coverage && !flag_compare_debug)
 {
-  bbg_file_name = XNEWVEC (char, len + strlen (GCOV_NOTE_SUFFIX) + 1);
-  memcpy (bbg_file_name, filename, len);
-  strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX);
+  if (profile_note_location)
+	bbg_file_name = xstrdup (profile_note_location);
+  else
+	{
+	  bbg_file_name = XNEWVEC (char, len + strlen (GCOV_NOTE_SUFFIX) + 1);
+	  memcpy (bbg_file_name, filename, len);
+	  strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX);
+	}
 
   if (!gcov_open (bbg_file_name, -1))
 	{
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9c6050b574b..918987b6656 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -493,8 +493,8 @@ Objective-C and Objective-C++ Dialects}.
 @gccoptlist{-p  -pg  -fprofile-arcs  --coverage  -ftest-coverage @gol
 -fprofile-abs-path @gol
 -fprofile-dir=@var{path}  -fprofile-generate  -fprofile-generate=@var{path} @gol
--fprofile-update=@var{method}  -fprofile-filter-files=@var{regex} @gol
--fprofile-exclude-files=@var{regex} @gol
+-fprofile-note=@var{path}  -fprofile-update=@var{method} @gol
+-fprofile-filter-files=@var{regex}  -fprofile-exclude-files=@var{regex} @gol
 -fsanitize=@var{style}  -fsanitize-recover  -fsanitize-recover=@var{style} @gol
 -fasan-shadow-offset=@var{number}  -fsanitize-sections=@var{s1},@var{s2},... @gol
 -fsanitize-undefined-trap-on-error  -fbounds-check @gol
@@ -12403,6 +12403,11 @@ the profile feedback data files. See @option{-fprofile-dir}.
 To optimize the program based on the collected profile information, use
 @option{-fprofile-use}.  @xref{Optimize Options}, for more information.
 
+@item -fprofile-note=@var{path}
+@opindex fprofile-note
+
+If @var{path} is specified, GCC saves gcno filename into @var{path} location.
+
 @item -fprofile-update=@var{method}
 @opindex fprofile-update