Re: [PATCH] PR86957

2018-12-11 Thread Thomas Schwinge
Hi Indu!

I recently saw that you just started contributing to GCC, so: welcome,
and enjoy to journey!

On Mon, 10 Dec 2018 12:54:09 -0800, Indu Bhagat  wrote:
> On 12/06/2018 05:54 PM, Indu Bhagat wrote:
> > [...]

Thanks for looking into this issue again.  As I said in private email,
such things (like looking at the wrong build's test logs) happen to all
of us.  As long as we learn -- or, at least try to learn ;-) -- something
from that, that's fine, as far as I'm concerned.

Evidently, the peer review/collaboration that we have in these Free
Software/Open Source software projects worked, and we eventually caught
this issue.  :-)

> > 2. I do however see other tests (a total of 23) which are have 
> > regressed from
> >PASS --> UNRESOLVED. A diff is attached.
> >
> >Each one of them is due to "Error/Warning threshold exceeded: 1 0 
> > (max. 1 3)"
> False alarm.
> 
> Looks like there is some flakiness I ran into.

Anything we could help you with, or that you have questions about?

> New testsuite runs (make check-gcc) on a fresh builds of the GCC (with 
> and without missing-profile) enabled look OK.
> One additional failure as expected (Wmissing-profile.c). No additional 
> unresolved tests.

Good, thanks for verifying!


Grüße
 Thomas


Re: [PATCH] PR86957

2018-12-10 Thread Indu Bhagat



On 12/06/2018 05:54 PM, Indu Bhagat wrote:
2. I do however see other tests (a total of 23) which are have 
regressed from

   PASS --> UNRESOLVED. A diff is attached.

   Each one of them is due to "Error/Warning threshold exceeded: 1 0 
(max. 1 3)"

False alarm.

Looks like there is some flakiness I ran into.

New testsuite runs (make check-gcc) on a fresh builds of the GCC (with 
and without missing-profile) enabled look OK.
One additional failure as expected (Wmissing-profile.c). No additional 
unresolved tests.


Indu


Re: [PATCH] PR86957

2018-12-06 Thread Indu Bhagat

On 12/05/2018 03:33 AM, Thomas Schwinge wrote:

Hi!

Sorry for my late follow-up; had a lot of catch up to do back then.

On Thu, 27 Sep 2018 11:47:31 +0200, Richard Biener  
wrote:

On Mon, Sep 24, 2018 at 9:14 PM Indu Bhagat  wrote:

Done. Attached is updated patch.

Patch is tested on x86_64

You obviously did_not_  properly test the patch since it causes a
bunch of new testsuite
failures: [...]

and more.  Please get up to speed with GCC development and testing requirements!

Also, with this commit, several test cases regressed from PASS to
UNSUPPORTED because of "{ dg-require-effective-target freorder }" running
into:

 fprofile_use_freorder16732.c: In function 'void foo()':
 fprofile_use_freorder16732.c:2:20: warning: 
'[...]/gcc/testsuite/g++/fprofile_use_freorder16732.gcda' profile count data 
file not found [-Wmissing-profile]

Iain had just mentioned that in, and fixed
in r266785,.
(Back then, I had produced the same fix, but not yet posted.)  :-|

With "{ dg-require-effective-target freorder }" thusly restored, I then
also saw two other regressions/FAILs, back then:

 [-UNSUPPORTED: g++.dg/tree-prof/pr63581.C-]
 UNSUPPORTED: g++.dg/tree-prof/pr63581.C -fauto-profile
 {+PASS: g++.dg/tree-prof/pr63581.C compilation,  -fprofile-generate 
-D_PROFILE_GENERATE+}
 {+FAIL: g++.dg/tree-prof/pr63581.C compilation,  -fprofile-use 
-D_PROFILE_USE+}
 {+PASS: g++.dg/tree-prof/pr63581.C execution,-fprofile-generate 
-D_PROFILE_GENERATE+}
 {+UNRESOLVED: g++.dg/tree-prof/pr63581.C execution,-fprofile-use 
-D_PROFILE_USE+}
 
 [...]/gcc/testsuite/g++.dg/tree-prof/pr63581.C: In function 'int uptodate(page*)':

 [...]/gcc/testsuite/g++.dg/tree-prof/pr63581.C:28:19: warning: profile for 
function 'int uptodate(page*)' not found in profile data [-Wmissing-profile]

..., and:

 [-UNSUPPORTED: gcc.dg/tree-prof/20041218-1.c-]
 UNSUPPORTED: gcc.dg/tree-prof/20041218-1.c -fauto-profile
 {+PASS: gcc.dg/tree-prof/20041218-1.c compilation,  -fprofile-generate 
-D_PROFILE_GENERATE+}
 {+FAIL: gcc.dg/tree-prof/20041218-1.c compilation,  -fprofile-use 
-D_PROFILE_USE+}
 {+PASS: gcc.dg/tree-prof/20041218-1.c execution,-fprofile-generate 
-D_PROFILE_GENERATE+}
 {+UNRESOLVED: gcc.dg/tree-prof/20041218-1.c execution,-fprofile-use 
-D_PROFILE_USE+}
 
 [...]/gcc/testsuite/gcc.dg/tree-prof/20041218-1.c: In function 'bar':

 [...]/gcc/testsuite/gcc.dg/tree-prof/20041218-1.c:58:1: warning: profile 
for function 'bar' not found in profile data [-Wmissing-profile]

..., for which I came up with the following patch.

But, this doesn't now seem to be necessary anymore, or am I confused?
Maybe this got fixed differently -- or is anybody still seeing these
FAILs?  (If not, then I'm not proposing to commit this, of course.)


I tested the trunk as of commit 85df98d7fbb6ef5c5b6e97190fff4028f4b70747
(Dec 5 PR c/87028) with and without the -Wmissing-profile on by default
in the compiler. I.e., with the following change :

Common Var(warn_missing_profile) Init(1) Warning
+Common Var(warn_missing_profile) Init(0) Warning

Two observations :
1. The two issues (tree-prof/pr63581.C and tree-prof/20041218-1.c) that you run
   into are not repeatable on my end. I am not sure why you run into them.

2. I do however see other tests (a total of 23) which are have regressed from
   PASS --> UNRESOLVED. A diff is attached.

   Each one of them is due to "Error/Warning threshold exceeded:  1 0 (max. 1 
3)"

E.g.,
ERROR: gcc.dg/tree-prof/20050826-2.c: error executing dg-final-use: couldn't open 
"20050826-2.c.116t.dom2 20050826-2.c.115t.dom2": no such file or directory
  Error/Warning threshold exceeded:  1 0 (max. 1 3)

(I have not been able to see the -Wmissing-profile warning explicitly in my logs
 yet. I was thinking a RUNTESTFLAGS="-v -v -v" should have helped, but it 
didnt.)

Any suggestions to resolve these tests are appreciated. I am not sure yet of the
most maintainable way to "allow the warning in all tests that it appears". I
need to look around a bit (Is Thomas' patch doing just what needs to be done 
here ?).

Thanks
Indu

UNRESOLVED: c-c++-common/unroll-1.c  -Wc++-compat : error executing dg-final: 
couldn't open "unroll-1.c.250r.loop2_unroll unroll-1.c.251r.loop2_unroll": no 
such file or directory
UNRESOLVED: gcc.dg/ipa/ipa-icf-38.c: error executing dg-final: couldn't open 
"ipa-icf-38.exe.wpa.069i.icf ipa-icf-38.exe.wpa.070i.icf": no such file or 
directory
UNRESOLVED: gcc.dg/tree-prof/20050826-2.c: Error executing dg-final-use: 
couldn't open "20050826-2.c.116t.dom2 20050826-2.c.115t.dom2": no such file or 
directory
UNRESOLVED: gcc.dg/tree-prof/cmpsf-1.c: Error executing dg-final-use: couldn't 
open "cmpsf-1.c.115t.dom2 cmpsf-1.c.116t.dom2": no such file or directory
UNRESOLVED: gcc.dg/tree-prof/inliner-1.c: Error executing dg-final-use: 
couldn't open 

Re: [PATCH] PR86957

2018-12-05 Thread Thomas Schwinge
Hi!

Sorry for my late follow-up; had a lot of catch up to do back then.

On Thu, 27 Sep 2018 11:47:31 +0200, Richard Biener  
wrote:
> On Mon, Sep 24, 2018 at 9:14 PM Indu Bhagat  wrote:
> >
> > Done. Attached is updated patch.
> >
> > Patch is tested on x86_64
> 
> You obviously did _not_ properly test the patch since it causes a
> bunch of new testsuite
> failures: [...]
> 
> and more.  Please get up to speed with GCC development and testing 
> requirements!

Also, with this commit, several test cases regressed from PASS to
UNSUPPORTED because of "{ dg-require-effective-target freorder }" running
into:

fprofile_use_freorder16732.c: In function 'void foo()':
fprofile_use_freorder16732.c:2:20: warning: 
'[...]/gcc/testsuite/g++/fprofile_use_freorder16732.gcda' profile count data 
file not found [-Wmissing-profile]

Iain had just mentioned that in , and fixed
in r266785, .
(Back then, I had produced the same fix, but not yet posted.)  :-|

With "{ dg-require-effective-target freorder }" thusly restored, I then
also saw two other regressions/FAILs, back then:

[-UNSUPPORTED: g++.dg/tree-prof/pr63581.C-]
UNSUPPORTED: g++.dg/tree-prof/pr63581.C -fauto-profile
{+PASS: g++.dg/tree-prof/pr63581.C compilation,  -fprofile-generate 
-D_PROFILE_GENERATE+}
{+FAIL: g++.dg/tree-prof/pr63581.C compilation,  -fprofile-use 
-D_PROFILE_USE+}
{+PASS: g++.dg/tree-prof/pr63581.C execution,-fprofile-generate 
-D_PROFILE_GENERATE+}
{+UNRESOLVED: g++.dg/tree-prof/pr63581.C execution,-fprofile-use 
-D_PROFILE_USE+}

[...]/gcc/testsuite/g++.dg/tree-prof/pr63581.C: In function 'int 
uptodate(page*)':
[...]/gcc/testsuite/g++.dg/tree-prof/pr63581.C:28:19: warning: profile for 
function 'int uptodate(page*)' not found in profile data [-Wmissing-profile]

..., and:

[-UNSUPPORTED: gcc.dg/tree-prof/20041218-1.c-]
UNSUPPORTED: gcc.dg/tree-prof/20041218-1.c -fauto-profile
{+PASS: gcc.dg/tree-prof/20041218-1.c compilation,  -fprofile-generate 
-D_PROFILE_GENERATE+}
{+FAIL: gcc.dg/tree-prof/20041218-1.c compilation,  -fprofile-use 
-D_PROFILE_USE+}
{+PASS: gcc.dg/tree-prof/20041218-1.c execution,-fprofile-generate 
-D_PROFILE_GENERATE+}
{+UNRESOLVED: gcc.dg/tree-prof/20041218-1.c execution,-fprofile-use 
-D_PROFILE_USE+}

[...]/gcc/testsuite/gcc.dg/tree-prof/20041218-1.c: In function 'bar':
[...]/gcc/testsuite/gcc.dg/tree-prof/20041218-1.c:58:1: warning: profile 
for function 'bar' not found in profile data [-Wmissing-profile]

..., for which I came up with the following patch.

But, this doesn't now seem to be necessary anymore, or am I confused?
Maybe this got fixed differently -- or is anybody still seeing these
FAILs?  (If not, then I'm not proposing to commit this, of course.)

commit 04ad00f79075a0c5eff1f806959918081e54684c
Author: Thomas Schwinge 
Date:   Wed Oct 31 23:29:32 2018 +0100

Avoid two -Wmissing-profile diagnostics
---
 gcc/testsuite/g++.dg/tree-prof/pr63581.C|5 +
 gcc/testsuite/gcc.dg/tree-prof/20041218-1.c |5 +
 2 files changed, 10 insertions(+)

diff --git gcc/testsuite/g++.dg/tree-prof/pr63581.C 
gcc/testsuite/g++.dg/tree-prof/pr63581.C
index c8caf07..9800851 100644
--- gcc/testsuite/g++.dg/tree-prof/pr63581.C
+++ gcc/testsuite/g++.dg/tree-prof/pr63581.C
@@ -25,10 +25,15 @@ __attribute__((noinline)) static int zero (void)
   return ii;
 }
 
+#pragma GCC diagnostic push
+/* WARNING: profopt.exp does not support dg-warning */
+/* "profile for function 'int uptodate(page*)' not found in profile data" */
+#pragma GCC diagnostic ignored "-Wmissing-profile"
 static inline int uptodate (struct page* p)
 {
   return (p->i < 709);
 }
+#pragma GCC diagnostic pop
 
 static struct page* bar(int i)
 {
diff --git gcc/testsuite/gcc.dg/tree-prof/20041218-1.c 
gcc/testsuite/gcc.dg/tree-prof/20041218-1.c
index cbd1c7c..41c60a7 100644
--- gcc/testsuite/gcc.dg/tree-prof/20041218-1.c
+++ gcc/testsuite/gcc.dg/tree-prof/20041218-1.c
@@ -54,6 +54,10 @@ check (void *x, struct S *y)
   return 1;
 }
 
+#pragma GCC diagnostic push
+/* WARNING: profopt.exp does not support dg-warning */
+/* "profile for function 'bar' not found in profile data" */
+#pragma GCC diagnostic ignored "-Wmissing-profile"
 static struct V *
 bar (unsigned int x, void *y)
 {
@@ -75,6 +79,7 @@ bar (unsigned int x, void *y)
 return (void *) 0;
   return u;
 }
+#pragma GCC diagnostic pop
 
 int
 foo (unsigned int *x, unsigned int y, void **z)


Grüße
 Thomas


Re: [PATCH] PR86957

2018-09-27 Thread Richard Biener
On Thu, Sep 27, 2018 at 3:10 PM Martin Liška  wrote:
>
> On 9/27/18 12:14 PM, Martin Liška wrote:
> > On 9/27/18 11:47 AM, Richard Biener wrote:
> >> On Mon, Sep 24, 2018 at 9:14 PM Indu Bhagat  wrote:
> >>>
> >>> Done. Attached is updated patch.
> >>>
> >>> Patch is tested on x86_64
> >>
> >> You obviously did _not_ properly test the patch since it causes a
> >> bunch of new testsuite
> >> failures:
> >>
> >> FAIL: g++.dg/pr60518.C  -std=gnu++11 (test for excess errors)
> >> FAIL: g++.dg/pr60518.C  -std=gnu++14 (test for excess errors)
> >> FAIL: g++.dg/pr60518.C  -std=gnu++98 (test for excess errors)
> >> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++11 (test for excess errors)
> >> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++14 (test for excess errors)
> >> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++98 (test for excess errors)
> >> FAIL: g++.dg/guality/pr55665.C   -O2 -flto -fno-use-linker-plugin
> >> -flto-partition=none  line 23 p == 40
> >> FAIL: g++.dg/torture/pr59265.C   -O0  (test for excess errors)
> >> FAIL: g++.dg/torture/pr59265.C   -O1  (test for excess errors)
> >> FAIL: g++.dg/torture/pr59265.C   -O2  (test for excess errors)
> >> FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fno-use-linker-plugin
> >> -flto-partition=none  (test for excess errors)
> >> FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fuse-linker-plugin
> >> -fno-fat-lto-objects  (test for excess errors)
> >> FAIL: g++.dg/torture/pr59265.C   -O3 -g  (test for excess errors)
> >> FAIL: g++.dg/torture/pr59265.C   -Os  (test for excess errors)
> >> FAIL: g++.dg/tree-prof/morefunc.C compilation,  -fprofile-use 
> >> -D_PROFILE_USE
> >> UNRESOLVED: g++.dg/tree-prof/morefunc.C execution,-fprofile-use
> >> -D_PROFILE_USE
> >>
> >> and more.  Please get up to speed with GCC development and testing 
> >> requirements!
> >>
> >> Richard.
> >
> > I'll cook patch for it in order to remove the failures as soon as possible.
> >
> > Martin
> >
> >>
> >>> Thanks
> >>>
> >>>
> >>> On 09/24/2018 09:37 AM, Martin Sebor wrote:
>  I would suggest to use the term "remove" or "delete" instead of
>  the informal "wipe out" when referring to removing files or their
>  contents.
> 
>  Martin
> >>>
> >
>
> There's tested patch that I made. It's tested on x86_64-linux-gnu. Feel free
> to install it after approval. I'll be back on Monday.

Patch is OK (and I installed it).

Richard.

> Martin


Re: [PATCH] PR86957

2018-09-27 Thread Martin Liška
On 9/27/18 12:14 PM, Martin Liška wrote:
> On 9/27/18 11:47 AM, Richard Biener wrote:
>> On Mon, Sep 24, 2018 at 9:14 PM Indu Bhagat  wrote:
>>>
>>> Done. Attached is updated patch.
>>>
>>> Patch is tested on x86_64
>>
>> You obviously did _not_ properly test the patch since it causes a
>> bunch of new testsuite
>> failures:
>>
>> FAIL: g++.dg/pr60518.C  -std=gnu++11 (test for excess errors)
>> FAIL: g++.dg/pr60518.C  -std=gnu++14 (test for excess errors)
>> FAIL: g++.dg/pr60518.C  -std=gnu++98 (test for excess errors)
>> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++11 (test for excess errors)
>> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++14 (test for excess errors)
>> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++98 (test for excess errors)
>> FAIL: g++.dg/guality/pr55665.C   -O2 -flto -fno-use-linker-plugin
>> -flto-partition=none  line 23 p == 40
>> FAIL: g++.dg/torture/pr59265.C   -O0  (test for excess errors)
>> FAIL: g++.dg/torture/pr59265.C   -O1  (test for excess errors)
>> FAIL: g++.dg/torture/pr59265.C   -O2  (test for excess errors)
>> FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fno-use-linker-plugin
>> -flto-partition=none  (test for excess errors)
>> FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fuse-linker-plugin
>> -fno-fat-lto-objects  (test for excess errors)
>> FAIL: g++.dg/torture/pr59265.C   -O3 -g  (test for excess errors)
>> FAIL: g++.dg/torture/pr59265.C   -Os  (test for excess errors)
>> FAIL: g++.dg/tree-prof/morefunc.C compilation,  -fprofile-use -D_PROFILE_USE
>> UNRESOLVED: g++.dg/tree-prof/morefunc.C execution,-fprofile-use
>> -D_PROFILE_USE
>>
>> and more.  Please get up to speed with GCC development and testing 
>> requirements!
>>
>> Richard.
> 
> I'll cook patch for it in order to remove the failures as soon as possible.
> 
> Martin
> 
>>
>>> Thanks
>>>
>>>
>>> On 09/24/2018 09:37 AM, Martin Sebor wrote:
 I would suggest to use the term "remove" or "delete" instead of
 the informal "wipe out" when referring to removing files or their
 contents.

 Martin
>>>
> 

There's tested patch that I made. It's tested on x86_64-linux-gnu. Feel free
to install it after approval. I'll be back on Monday.

Martin
>From 1757b63f13e0f18bab4be90001e1056069f8799a Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 27 Sep 2018 12:14:09 +0200
Subject: [PATCH] Fix fallout of -Wmissing-profile warning.

gcc/ChangeLog:

2018-09-27  Martin Liska  

	* coverage.c (get_coverage_counts): Revert the formatting
	of missing profile opt info.

gcc/testsuite/ChangeLog:

2018-09-27  Martin Liska  

	* g++.dg/pr60518.C: Add -Wno-missing-profile.
	* g++.dg/torture/pr59265.C: Likewise.
	* g++.dg/tree-prof/morefunc.C: Likewise.
	* g++.dg/tree-ssa/dom-invalid.C: Likewise.
	* gcc.dg/pr26570.c: Likewise.
	* gcc.dg/pr32773.c: Likewise.
	* gcc.dg/pr40209.c: Likewise.
	* gcc.dg/pr51957-1.c: Likewise.
	* gcc.dg/pr80747.c: Likewise.
	* gcc.target/aarch64/pr62262.c: Likewise.
---
 gcc/coverage.c  | 10 --
 gcc/testsuite/g++.dg/pr60518.C  |  2 +-
 gcc/testsuite/g++.dg/torture/pr59265.C  |  2 +-
 gcc/testsuite/g++.dg/tree-prof/morefunc.C   |  2 +-
 gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C |  2 +-
 gcc/testsuite/gcc.dg/pr26570.c  |  2 +-
 gcc/testsuite/gcc.dg/pr32773.c  |  4 ++--
 gcc/testsuite/gcc.dg/pr40209.c  |  2 +-
 gcc/testsuite/gcc.dg/pr51957-1.c|  2 +-
 gcc/testsuite/gcc.dg/pr80747.c  |  2 +-
 gcc/testsuite/gcc.target/aarch64/pr62262.c  |  2 +-
 11 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 19c696c3493..6b45ce9085b 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -314,12 +314,10 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
 	  dump_user_location_t loc
 		= dump_user_location_t::from_location_t (input_location);
 	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
-			   "file %s not found\n",
-			   da_file_name);
-	  dump_printf (MSG_OPTIMIZED_LOCATIONS,
-			   (flag_guess_branch_prob
-			? "execution counts estimated\n"
-			: "execution counts assumed to be zero\n"));
+			   "file %s not found, %s\n", da_file_name,
+			   (flag_guess_branch_prob
+? "execution counts estimated"
+: "execution counts assumed to be zero"));
 	}
 	}
   return NULL;
diff --git a/gcc/testsuite/g++.dg/pr60518.C b/gcc/testsuite/g++.dg/pr60518.C
index e3da48a2ec9..e4a80da29ee 100644
--- a/gcc/testsuite/g++.dg/pr60518.C
+++ b/gcc/testsuite/g++.dg/pr60518.C
@@ -1,5 +1,5 @@
 // { dg-do compile }
-// { dg-options "-Os -fprofile-use" }
+// { dg-options "-Os -fprofile-use -Wno-missing-profile" }
 
 int a;
 int fn1 () { return a == ',' || a == ';'; }
diff --git a/gcc/testsuite/g++.dg/torture/pr59265.C b/gcc/testsuite/g++.dg/torture/pr59265.C
index d48efe59395..f3dceb929d2 100644
--- a/gcc/testsuite/g++.dg/torture/pr59265.C
+++ b/gcc/testsuite/g++.dg/torture/pr59265.C
@@ -1,5 +1,5 

Re: [PATCH] PR86957

2018-09-27 Thread Martin Liška
On 9/27/18 11:47 AM, Richard Biener wrote:
> On Mon, Sep 24, 2018 at 9:14 PM Indu Bhagat  wrote:
>>
>> Done. Attached is updated patch.
>>
>> Patch is tested on x86_64
> 
> You obviously did _not_ properly test the patch since it causes a
> bunch of new testsuite
> failures:
> 
> FAIL: g++.dg/pr60518.C  -std=gnu++11 (test for excess errors)
> FAIL: g++.dg/pr60518.C  -std=gnu++14 (test for excess errors)
> FAIL: g++.dg/pr60518.C  -std=gnu++98 (test for excess errors)
> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++11 (test for excess errors)
> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++14 (test for excess errors)
> FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++98 (test for excess errors)
> FAIL: g++.dg/guality/pr55665.C   -O2 -flto -fno-use-linker-plugin
> -flto-partition=none  line 23 p == 40
> FAIL: g++.dg/torture/pr59265.C   -O0  (test for excess errors)
> FAIL: g++.dg/torture/pr59265.C   -O1  (test for excess errors)
> FAIL: g++.dg/torture/pr59265.C   -O2  (test for excess errors)
> FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fno-use-linker-plugin
> -flto-partition=none  (test for excess errors)
> FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fuse-linker-plugin
> -fno-fat-lto-objects  (test for excess errors)
> FAIL: g++.dg/torture/pr59265.C   -O3 -g  (test for excess errors)
> FAIL: g++.dg/torture/pr59265.C   -Os  (test for excess errors)
> FAIL: g++.dg/tree-prof/morefunc.C compilation,  -fprofile-use -D_PROFILE_USE
> UNRESOLVED: g++.dg/tree-prof/morefunc.C execution,-fprofile-use
> -D_PROFILE_USE
> 
> and more.  Please get up to speed with GCC development and testing 
> requirements!
> 
> Richard.

I'll cook patch for it in order to remove the failures as soon as possible.

Martin

> 
>> Thanks
>>
>>
>> On 09/24/2018 09:37 AM, Martin Sebor wrote:
>>> I would suggest to use the term "remove" or "delete" instead of
>>> the informal "wipe out" when referring to removing files or their
>>> contents.
>>>
>>> Martin
>>



Re: [PATCH] PR86957

2018-09-27 Thread Richard Biener
On Mon, Sep 24, 2018 at 9:14 PM Indu Bhagat  wrote:
>
> Done. Attached is updated patch.
>
> Patch is tested on x86_64

You obviously did _not_ properly test the patch since it causes a
bunch of new testsuite
failures:

FAIL: g++.dg/pr60518.C  -std=gnu++11 (test for excess errors)
FAIL: g++.dg/pr60518.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/pr60518.C  -std=gnu++98 (test for excess errors)
FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++11 (test for excess errors)
FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/tree-ssa/dom-invalid.C  -std=gnu++98 (test for excess errors)
FAIL: g++.dg/guality/pr55665.C   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  line 23 p == 40
FAIL: g++.dg/torture/pr59265.C   -O0  (test for excess errors)
FAIL: g++.dg/torture/pr59265.C   -O1  (test for excess errors)
FAIL: g++.dg/torture/pr59265.C   -O2  (test for excess errors)
FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  (test for excess errors)
FAIL: g++.dg/torture/pr59265.C   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)
FAIL: g++.dg/torture/pr59265.C   -O3 -g  (test for excess errors)
FAIL: g++.dg/torture/pr59265.C   -Os  (test for excess errors)
FAIL: g++.dg/tree-prof/morefunc.C compilation,  -fprofile-use -D_PROFILE_USE
UNRESOLVED: g++.dg/tree-prof/morefunc.C execution,-fprofile-use
-D_PROFILE_USE

and more.  Please get up to speed with GCC development and testing requirements!

Richard.

> Thanks
>
>
> On 09/24/2018 09:37 AM, Martin Sebor wrote:
> > I would suggest to use the term "remove" or "delete" instead of
> > the informal "wipe out" when referring to removing files or their
> > contents.
> >
> > Martin
>


Re: [PATCH] PR86957

2018-09-26 Thread Martin Liška
On 9/24/18 9:21 PM, Indu Bhagat wrote:
> Done. Attached is updated patch.

Thanks for it, I tested that right now.
You have ACK, so please install the patch. Please do not forget
to install ChangeLog entry and I would include PR entry:
https://www.gnu.org/software/gcc/contribute.html

example can be seen here:
https://github.com/gcc-mirror/gcc/blob/089d1a5f4939282881c108e0d04d026bdd82f6c6/ChangeLog#L178

Martin

> 
> Patch is tested on x86_64
> 
> Thanks
> 
> 
> On 09/24/2018 09:37 AM, Martin Sebor wrote:
>> I would suggest to use the term "remove" or "delete" instead of
>> the informal "wipe out" when referring to removing files or their
>> contents.
>>
>> Martin 
> 



Re: [PATCH] PR86957

2018-09-24 Thread Indu Bhagat

Done. Attached is updated patch.

Patch is tested on x86_64

Thanks


On 09/24/2018 09:37 AM, Martin Sebor wrote:

I would suggest to use the term "remove" or "delete" instead of
the informal "wipe out" when referring to removing files or their
contents.

Martin 


diff --git a/gcc/common.opt b/gcc/common.opt
index ef6a630..53aac19 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -811,6 +811,10 @@ Wcoverage-mismatch
 Common Var(warn_coverage_mismatch) Init(1) Warning
 Warn in case profiles in -fprofile-use do not match.
 
+Wmissing-profile
+Common Var(warn_missing_profile) Init(1) Warning
+Warn in case profiles in -fprofile-use do not exist.
+
 Wvector-operation-performance
 Common Var(warn_vector_operation_performance) Warning
 Warn when a vector operation is compiled outside the SIMD.
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 8f12778..19c696c 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -304,16 +304,23 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
 {
   static int warned = 0;
 
-  if (!warned++ && dump_enabled_p ())
+  if (!warned++)
 	{
-	  dump_user_location_t loc
-	= dump_user_location_t::from_location_t (input_location);
-	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+	  warning (OPT_Wmissing_profile,
+		   "%qs profile count data file not found",
+		   da_file_name);
+	  if (dump_enabled_p ())
+	{
+	  dump_user_location_t loc
+		= dump_user_location_t::from_location_t (input_location);
+	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+			   "file %s not found\n",
+			   da_file_name);
+	  dump_printf (MSG_OPTIMIZED_LOCATIONS,
 			   (flag_guess_branch_prob
-			? "file %s not found, execution counts estimated\n"
-			: "file %s not found, execution counts assumed to "
-			"be zero\n"),
-			   da_file_name);
+			? "execution counts estimated\n"
+			: "execution counts assumed to be zero\n"));
+	}
 	}
   return NULL;
 }
@@ -327,10 +334,17 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
   elt.ctr = counter;
   entry = counts_hash->find ();
   if (!entry)
-/* The function was not emitted, or is weak and not chosen in the
-   final executable.  Silently fail, because there's nothing we
-   can do about it.  */
-return NULL;
+{
+  if (counter == GCOV_COUNTER_ARCS)
+	warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+		OPT_Wmissing_profile,
+		"profile for function %qD not found in profile data",
+		current_function_decl);
+  /* The function was not emitted, or is weak and not chosen in the
+	 final executable.  Silently fail, because there's nothing we
+	 can do about it.  */
+  return NULL;
+}
   
   if (entry->cfg_checksum != cfg_checksum)
 {
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index abbd9ec..1b6cd68 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -315,7 +315,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wlogical-op  -Wlogical-not-parentheses  -Wlong-long @gol
 -Wmain  -Wmaybe-uninitialized  -Wmemset-elt-size  -Wmemset-transposed-args @gol
 -Wmisleading-indentation  -Wmissing-attributes -Wmissing-braces @gol
--Wmissing-field-initializers  -Wmissing-include-dirs @gol
+-Wmissing-field-initializers  -Wmissing-include-dirs  -Wmissing-profile @gol
 -Wno-multichar  -Wmultistatement-macros  -Wnonnull  -Wnonnull-compare @gol
 -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
 -Wnull-dereference  -Wodr  -Wno-overflow  -Wopenmp-simd  @gol
@@ -4218,8 +4218,8 @@ Warn about an invalid memory access that is found by Pointer Bounds Checker
 @opindex Wcoverage-mismatch
 Warn if feedback profiles do not match when using the
 @option{-fprofile-use} option.
-If a source file is changed between compiling with @option{-fprofile-gen} and
-with @option{-fprofile-use}, the files with the profile feedback can fail
+If a source file is changed between compiling with @option{-fprofile-generate}
+and with @option{-fprofile-use}, the files with the profile feedback can fail
 to match the source file and GCC cannot use the profile feedback
 information.  By default, this warning is enabled and is treated as an
 error.  @option{-Wno-coverage-mismatch} can be used to disable the
@@ -4823,6 +4823,23 @@ This warning is enabled by @option{-Wall}.
 @opindex Wno-missing-include-dirs
 Warn if a user-supplied include directory does not exist.
 
+@item -Wmissing-profile
+@opindex Wmissing-profile
+@opindex Wno-missing-profile
+Warn if feedback profiles are missing when using the
+@option{-fprofile-use} option.
+This option diagnoses those cases where a new function or a new file is added
+to the user code between compiling with @option{-fprofile-generate} and with
+@option{-fprofile-use}, without regenerating the profiles.  In these cases, the
+profile feedback data files do not contain any profile feedback information for
+the newly added function or file respectively.  Also, in the case when profile

Re: [PATCH] PR86957

2018-09-24 Thread Martin Sebor

On 09/21/2018 05:27 PM, Indu Bhagat wrote:

Attached is the refreshed patch for trunk.

After commit 264462 (Remove arc profile histogram in non-LTO mode.), the
API
of get_coverage_counts was changed a bit. So the main difference between
the
current version of my patch from the previous one is that :

Now I use
+  if (counter == GCOV_COUNTER_ARCS)
+   warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+   OPT_Wmissing_profile,
+   "profile for function %qD not found in profile data",
+   current_function_decl);

instead of
+  if (summary)
+   warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+   OPT_Wmissing_profile,
+   "profile for function %qD not found in profile data",
+   current_function_decl);

to warn about missing profile of a function only once
(get_coverage_counts is
called from two diff flows : getting exec counts for arc counter and
computing
histogram for other other counters)

I am not sure of any better way to avoid superfluous warnings per function.

Is the patch OK ?



In the text below:

@@ -4823,6 +4823,23 @@
 This warning is enabled by @option{-Wall}.
 @opindex Wno-missing-include-dirs
 Warn if a user-supplied include directory does not exist.

+@item -Wmissing-profile
+@opindex Wmissing-profile
+@opindex Wno-missing-profile
+Warn if feedback profiles are missing when using the
+@option{-fprofile-use} option.
+This option diagnoses those cases where a new function or a new file is 
added
+to the user code between compiling with @option{-fprofile-generate} and 
with
+@option{-fprofile-use}, without regenerating the profiles.  In these 
cases, the
+profile feedback data files do not contain any profile feedback 
information for
+the newly added function or file respectively.  Also, in the case when 
profile
+count data (.gcda) files are wiped out, GCC cannot use any profile 
feedback

+information.

I would suggest to use the term "remove" or "delete" instead of
the informal "wipe out" when referring to removing files or their
contents.

Martin


Re: [PATCH] PR86957

2018-09-21 Thread Indu Bhagat

Attached is the refreshed patch for trunk.

After commit 264462 (Remove arc profile histogram in non-LTO mode.), the API
of get_coverage_counts was changed a bit. So the main difference between the
current version of my patch from the previous one is that :

Now I use
+  if (counter == GCOV_COUNTER_ARCS)
+   warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+   OPT_Wmissing_profile,
+   "profile for function %qD not found in profile data",
+   current_function_decl);

instead of
+  if (summary)
+   warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+   OPT_Wmissing_profile,
+   "profile for function %qD not found in profile data",
+   current_function_decl);

to warn about missing profile of a function only once (get_coverage_counts is
called from two diff flows : getting exec counts for arc counter and computing
histogram for other other counters)

I am not sure of any better way to avoid superfluous warnings per function.

Is the patch OK ?

diff --git a/gcc/common.opt b/gcc/common.opt
index ef6a630..53aac19 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -811,6 +811,10 @@ Wcoverage-mismatch
 Common Var(warn_coverage_mismatch) Init(1) Warning
 Warn in case profiles in -fprofile-use do not match.
 
+Wmissing-profile
+Common Var(warn_missing_profile) Init(1) Warning
+Warn in case profiles in -fprofile-use do not exist.
+
 Wvector-operation-performance
 Common Var(warn_vector_operation_performance) Warning
 Warn when a vector operation is compiled outside the SIMD.
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 26cce2b..4b6df8a 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -304,16 +304,23 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
 {
   static int warned = 0;
 
-  if (!warned++ && dump_enabled_p ())
+  if (!warned++)
 	{
-	  dump_user_location_t loc
-	= dump_user_location_t::from_location_t (input_location);
-	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+	  warning (OPT_Wmissing_profile,
+		   "%qs profile count data file not found",
+		   da_file_name);
+	  if (dump_enabled_p ())
+	{
+	  dump_user_location_t loc
+		= dump_user_location_t::from_location_t (input_location);
+	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+			   "file %s not found\n",
+			   da_file_name);
+	  dump_printf (MSG_OPTIMIZED_LOCATIONS,
 			   (flag_guess_branch_prob
-			? "file %s not found, execution counts estimated\n"
-			: "file %s not found, execution counts assumed to "
-			"be zero\n"),
-			   da_file_name);
+			? "execution counts estimated\n"
+			: "execution counts assumed to be zero\n"));
+	}
 	}
   return NULL;
 }
@@ -327,10 +334,17 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
   elt.ctr = counter;
   entry = counts_hash->find ();
   if (!entry)
-/* The function was not emitted, or is weak and not chosen in the
-   final executable.  Silently fail, because there's nothing we
-   can do about it.  */
-return NULL;
+{
+  if (counter == GCOV_COUNTER_ARCS)
+	warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+		OPT_Wmissing_profile,
+		"profile for function %qD not found in profile data",
+		current_function_decl);
+  /* The function was not emitted, or is weak and not chosen in the
+	 final executable.  Silently fail, because there's nothing we
+	 can do about it.  */
+  return NULL;
+}
   
   if (entry->cfg_checksum != cfg_checksum)
 {
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index abbd9ec..ed56af3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -315,7 +315,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wlogical-op  -Wlogical-not-parentheses  -Wlong-long @gol
 -Wmain  -Wmaybe-uninitialized  -Wmemset-elt-size  -Wmemset-transposed-args @gol
 -Wmisleading-indentation  -Wmissing-attributes -Wmissing-braces @gol
--Wmissing-field-initializers  -Wmissing-include-dirs @gol
+-Wmissing-field-initializers  -Wmissing-include-dirs  -Wmissing-profile @gol
 -Wno-multichar  -Wmultistatement-macros  -Wnonnull  -Wnonnull-compare @gol
 -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
 -Wnull-dereference  -Wodr  -Wno-overflow  -Wopenmp-simd  @gol
@@ -4218,8 +4218,8 @@ Warn about an invalid memory access that is found by Pointer Bounds Checker
 @opindex Wcoverage-mismatch
 Warn if feedback profiles do not match when using the
 @option{-fprofile-use} option.
-If a source file is changed between compiling with @option{-fprofile-gen} and
-with @option{-fprofile-use}, the files with the profile feedback can fail
+If a source file is changed between compiling with @option{-fprofile-generate}
+and with @option{-fprofile-use}, the files with the profile feedback can fail
 to match the source file and GCC cannot use the profile feedback
 information.  By default, this warning is enabled and 

Re: [PATCH] PR86957

2018-09-18 Thread Indu Bhagat



On 09/17/2018 03:52 AM, Jan Hubicka wrote:

On 09/11/2018 02:21 AM, Martin Liška wrote:

--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -811,6 +811,10 @@ Wcoverage-mismatch
  Common Var(warn_coverage_mismatch) Init(1) Warning
  Warn in case profiles in -fprofile-use do not match.
  
+Wmissing-profile

+Common Var(warn_missing_profile) Init(1) Warning
+Warn in case profiles in -fprofile-use do not exist.

Maybe 'Want about missing profile for a function in -fprofile-use build.' ?


Since, it also warns when feedback file is missing for a compilation unit, the
suggested text above will be more restrictive. So I did not change.

Perhaps we want also to have reference from -fprofile-use documentation so 
users notice
this option.

Honza

Thanks

Yes, I had added that in the patch. Following additional text will 
appear at the end of

-fprofile-use :

+ Additionally, by default, GCC also emits a warning message if
+the feedback profiles do not exist (See @option{-Wmissing-profile}).


Re: [PATCH] PR86957

2018-09-17 Thread Jan Hubicka
> On 9/16/18 12:58 AM, Indu Bhagat wrote:
> > Thanks for the reviews. I have incorporated them in this patch except the 
> > one 
> > (changes in common.opt) below.
> > 
> > In this patch,
> > 
> > 1. -Wmissing-profile is a warning by default and is ON by default with 
> >-fprofile-use
> > 2. Attached pr86957-missing-profile-diagnostic-2 shows the warning messages
> > 3. Added a testcase for warning in the case of missing profile feedback data
> >file for a compilation unit
> > 
> > Thanks
> 
> Hi.
> 
> The patch looks fine for me now. Honza can you approve it?
Patch looks OK.  We used to have this warning but it was removed by google floks
because if you build a static library it may happen that object file was never 
linked
into your test application, so its use is a bit limited. Having an option for 
this makes
sense to me though.

Honza
> 
> Martin
> 
> > 
> > gcc/ChangeLog:
> > 
> > 2018-09-14  "Indu Bhagat"  <"indu.bha...@oracle.com">
> > 
> > * common.opt: New warning option -Wmissing-profile.
> > * coverage.c (get_coverage_counts): Add warning for missing .gcda 
> > file.
> > * doc/invoke.texi: Document -Wmissing-profile.
> > 
> > gcc/testsuite/ChangeLog:
> > 
> > 2018-09-14  "Indu Bhagat"  <"indu.bha...@oracle.com">
> > 
> > * gcc.dg/Wmissing-profile.c: New test.
> > 
> > 
> > On 09/11/2018 02:21 AM, Martin Liška wrote:
> >>> --- a/gcc/common.opt
> >>> +++ b/gcc/common.opt
> >>> @@ -811,6 +811,10 @@ Wcoverage-mismatch
> >>>  Common Var(warn_coverage_mismatch) Init(1) Warning
> >>>  Warn in case profiles in -fprofile-use do not match.
> >>>  
> >>> +Wmissing-profile
> >>> +Common Var(warn_missing_profile) Init(1) Warning
> >>> +Warn in case profiles in -fprofile-use do not exist.
> >> Maybe 'Want about missing profile for a function in -fprofile-use build.' ?
> >>
> > Since, it also warns when feedback file is missing for a compilation unit, 
> > the
> > suggested text above will be more restrictive. So I did not change.

Perhaps we want also to have reference from -fprofile-use documentation so 
users notice
this option.

Honza
> > 
> > 
> 


Re: [PATCH] PR86957

2018-09-17 Thread Martin Liška
On 9/16/18 12:58 AM, Indu Bhagat wrote:
> Thanks for the reviews. I have incorporated them in this patch except the one 
> (changes in common.opt) below.
> 
> In this patch,
> 
> 1. -Wmissing-profile is a warning by default and is ON by default with 
>-fprofile-use
> 2. Attached pr86957-missing-profile-diagnostic-2 shows the warning messages
> 3. Added a testcase for warning in the case of missing profile feedback data
>file for a compilation unit
> 
> Thanks

Hi.

The patch looks fine for me now. Honza can you approve it?

Martin

> 
> gcc/ChangeLog:
> 
> 2018-09-14  "Indu Bhagat"  <"indu.bha...@oracle.com">
> 
> * common.opt: New warning option -Wmissing-profile.
> * coverage.c (get_coverage_counts): Add warning for missing .gcda 
> file.
> * doc/invoke.texi: Document -Wmissing-profile.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-09-14  "Indu Bhagat"  <"indu.bha...@oracle.com">
> 
> * gcc.dg/Wmissing-profile.c: New test.
> 
> 
> On 09/11/2018 02:21 AM, Martin Liška wrote:
>>> --- a/gcc/common.opt
>>> +++ b/gcc/common.opt
>>> @@ -811,6 +811,10 @@ Wcoverage-mismatch
>>>  Common Var(warn_coverage_mismatch) Init(1) Warning
>>>  Warn in case profiles in -fprofile-use do not match.
>>>  
>>> +Wmissing-profile
>>> +Common Var(warn_missing_profile) Init(1) Warning
>>> +Warn in case profiles in -fprofile-use do not exist.
>> Maybe 'Want about missing profile for a function in -fprofile-use build.' ?
>>
> Since, it also warns when feedback file is missing for a compilation unit, the
> suggested text above will be more restrictive. So I did not change.
> 
> 



Re: [PATCH] PR86957

2018-09-15 Thread Indu Bhagat

Thanks for the reviews. I have incorporated all but one (See below; its the 
change in the warning's
brief summary in common.opt) in the patch.

In this patch,

1. -Wmissing-profile is a warning by default and is ON by default with
   -fprofile-use
2. Attached pr86957-missing-profile-diagnostic-2 shows the warning messages
3. Added a testcase for warning in the case of missing profile feedback data
   file for a compilation unit

Thanks

gcc/ChangeLog:

2018-09-14  "Indu Bhagat"

* common.opt: New warning option -Wmissing-profile.
* coverage.c (get_coverage_counts): Add warning for missing .gcda file.
* doc/invoke.texi: Document -Wmissing-profile.

gcc/testsuite/ChangeLog:

2018-09-14  "Indu Bhagat"

* gcc.dg/Wmissing-profile.c: New test.


On 09/11/2018 02:21 AM, Martin Liška wrote:

diff --git a/gcc/common.opt b/gcc/common.opt
index ebc3ef4..d93ddca 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -811,6 +811,10 @@ Wcoverage-mismatch
  Common Var(warn_coverage_mismatch) Init(1) Warning
  Warn in case profiles in -fprofile-use do not match.
  
+Wmissing-profile

+Common Var(warn_missing_profile) Init(1) Warning
+Warn in case profiles in -fprofile-use do not exist.

Maybe 'Want about missing profile for a function in -fprofile-use build.' ?



Since, Wmissing-profile also warns when feedback data file is missing for a 
compilation unit, the
suggested text above will be more restrictive. So I did not change.

[Testcase 1] Missing profile data file with -fprofile-use. The sort.c file 
contains two functions main() and stop()

gcc -c sort.c -fprofile-use -O1 
-fprofile-dir=/scratch/user/gcc-temp/fdo/profdata/
sort.c: In function ‘main’:
sort.c:29:1: warning: 
‘/scratch/user/gcc-temp/fdo/profdata//#scratch#user#gcc-temp#fdo#sort.gcda’ 
profile count data file not found [-Wmissing-profile]
29 | }
   | ^


[Testcase 2] bubble_sort.c has a non-empty function bubble_sort() for which 
profile data exists.
Now at profile-use phase, a user adds empty function before1() before an 
existing lone function bubble_sort() and empty function after1() after the lone 
existing function bubble_sort()

gcc -c bubble_sort.c -fprofile-use -O1 
-fprofile-dir=/scratch/user/gcc-temp/fdo/profdata/
bubble_sort.c:20:6: warning: profile for function ‘after1’ not found in profile 
data [-Wmissing-profile]
20 | void after1() { }
   |  ^~
bubble_sort.c: In function ‘bubble_sort’:
bubble_sort.c:20:1: error: source locations for function ‘bubble_sort’ have 
changed, the profile data may be out of date [-Werror=coverage-mismatch]
20 | void after1() { }
   | ^~~~
bubble_sort.c: In function ‘before1’:
bubble_sort.c:3:6: warning: profile for function ‘before1’ not found in profile 
data [-Wmissing-profile]
3 | void before1() { }
  |  ^~~
cc1: some warnings being treated as errors
make: *** [bubble_sort.o] Error 1


[Testcase 3] Use -Wno-missing-profile to disable warnings (A coverage-mismatch 
error remains here because of source file changes as mentioned in Testcase 2 
above; but no warnings are issued for before1() and after1())

gcc -c bubble_sort.c -fprofile-use -O1 -Wno-missing-profile 
-fprofile-dir=/scratch/user/gcc-temp/fdo/profdata/
bubble_sort.c: In function ‘bubble_sort’:
bubble_sort.c:20:1: error: source locations for function ‘bubble_sort’ have 
changed, the profile data may be out of date [-Werror=coverage-mismatch]
20 | void after1() { }
   | ^~~~
cc1: some warnings being treated as errors

diff --git a/gcc/common.opt b/gcc/common.opt
index ef6a630..53aac19 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -811,6 +811,10 @@ Wcoverage-mismatch
 Common Var(warn_coverage_mismatch) Init(1) Warning
 Warn in case profiles in -fprofile-use do not match.
 
+Wmissing-profile
+Common Var(warn_missing_profile) Init(1) Warning
+Warn in case profiles in -fprofile-use do not exist.
+
 Wvector-operation-performance
 Common Var(warn_vector_operation_performance) Warning
 Warn when a vector operation is compiled outside the SIMD.
diff --git a/gcc/coverage.c b/gcc/coverage.c
index bae6f5c..f9b54d8 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -341,16 +341,23 @@ get_coverage_counts (unsigned counter, unsigned expected,
 {
   static int warned = 0;
 
-  if (!warned++ && dump_enabled_p ())
+  if (!warned++)
 	{
-	  dump_user_location_t loc
-	= dump_user_location_t::from_location_t (input_location);
-	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+	  warning (OPT_Wmissing_profile,
+		   "%qs profile count data file not found",
+		   da_file_name);
+	  if (dump_enabled_p ())
+	{
+	  dump_user_location_t loc
+		= dump_user_location_t::from_location_t (input_location);
+	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+			   "file %s not found\n",
+			   da_file_name);
+	  dump_printf (MSG_OPTIMIZED_LOCATIONS,
 			   (flag_guess_branch_prob
-			? "file %s not found, execution counts estimated\n"
-			: "file %s not found, execution counts 

Re: [PATCH] PR86957

2018-09-11 Thread Martin Liška
On 09/05/2018 09:28 PM, Indu Bhagat wrote:
> Patch for PR 86957 " gcc should warn about missing profiles for a compilation 
> unit or a new function with -fprofile-use".
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86957
> 
> The patch adds -Wmissing-profile warning flag to alert user about cases when 
> there is no profile data for a compilation unit or a function when using 
> -fprofile-use.
> 
> The flag is on by default when -fprofile-use is specified and generates errors
> by default (like -Wcoverage-mismatch).
> 
> The attachment pr86957-missing-profile-diagnostic shows the behavior of GCC 
> with the patch.
> 
> Thanks
> Indu
> 
> --
> 
> 
> gcc/ChangeLog:
> 
> 2018-09-05  "Indu Bhagat"  <"indu.bha...@oracle.com">
> 
>     * common.opt: New warning option -Wmissing-profile.
>     * coverage.c (get_coverage_counts): Add warning for missing .gcda 
> file.
>     * doc/invoke.texi: Document -Wmissing-profile.
>     * profile.c (get_exec_counts): Add warning for missing feedback
>   profile for a function.
>     * toplev.c (process_options): -Wmissing-profile warning as error.
> 

... and please add a test-case for the missing file. That's easy to achieve by 
running
a test-case with -fprofile-use.

Martin


Re: [PATCH] PR86957

2018-09-11 Thread Martin Liška
On 09/05/2018 09:28 PM, Indu Bhagat wrote:

Hi.

Thanks for working on that. I believe it's useful enhancement. Note that I'm 
not profile feedback maintainer,
but I'll provide some feedback:

> Patch for PR 86957 " gcc should warn about missing profiles for a compilation 
> unit or a new function with -fprofile-use".
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86957
> 
> The patch adds -Wmissing-profile warning flag to alert user about cases when 
> there is no profile data for a compilation unit or a function when using 
> -fprofile-use.
> 
> The flag is on by default when -fprofile-use is specified and generates errors
> by default (like -Wcoverage-mismatch).
> 
> The attachment pr86957-missing-profile-diagnostic shows the behavior of GCC 
> with the patch.
> 
> Thanks
> Indu
> 
> --
> 
> 
> gcc/ChangeLog:
> 
> 2018-09-05  "Indu Bhagat"  <"indu.bha...@oracle.com">
> 
> * common.opt: New warning option -Wmissing-profile.
> * coverage.c (get_coverage_counts): Add warning for missing .gcda 
> file.
> * doc/invoke.texi: Document -Wmissing-profile.
> * profile.c (get_exec_counts): Add warning for missing feedback
>   profile for a function.
> * toplev.c (process_options): -Wmissing-profile warning as error.
> 
> 
> pr86957-patch
> 
> 
> diff --git a/gcc/common.opt b/gcc/common.opt
> index ebc3ef4..d93ddca 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -811,6 +811,10 @@ Wcoverage-mismatch
>  Common Var(warn_coverage_mismatch) Init(1) Warning
>  Warn in case profiles in -fprofile-use do not match.
>  
> +Wmissing-profile
> +Common Var(warn_missing_profile) Init(1) Warning
> +Warn in case profiles in -fprofile-use do not exist.

Maybe 'Want about missing profile for a function in -fprofile-use build.' ?

> +
>  Wvector-operation-performance
>  Common Var(warn_vector_operation_performance) Warning
>  Warn when a vector operation is compiled outside the SIMD.
> diff --git a/gcc/coverage.c b/gcc/coverage.c
> index bae6f5c..df031df 100644
> --- a/gcc/coverage.c
> +++ b/gcc/coverage.c
> @@ -341,16 +341,24 @@ get_coverage_counts (unsigned counter, unsigned 
> expected,
>  {
>static int warned = 0;
>  
> -  if (!warned++ && dump_enabled_p ())
> +  if (!warned++)
>   {
> -   dump_user_location_t loc
> - = dump_user_location_t::from_location_t (input_location);
> -   dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
> +   warning (OPT_Wmissing_profile,
> +"%qs profile count data file not found,"
> +" regenerating profiles may help",

I would not append 'regenerating profiles may help'. We don't do it for other
profile corruption warnings/errors.

> +da_file_name);
> +   if (dump_enabled_p ())
> + {
> +   dump_user_location_t loc
> + = dump_user_location_t::from_location_t (input_location);
> +   dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
> +"file %s not found\n",
> +da_file_name);
> +   dump_printf (MSG_OPTIMIZED_LOCATIONS,
>  (flag_guess_branch_prob
> - ? "file %s not found, execution counts estimated\n"
> - : "file %s not found, execution counts assumed to "
> - "be zero\n"),
> -da_file_name);
> + ? "execution counts estimated\n"
> + : "execution counts assumed to be zero\n"));
> + }
>   }
>return NULL;
>  }
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index ca92028..e62bcae 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -314,7 +314,7 @@ Objective-C and Objective-C++ Dialects}.
>  -Wlogical-op  -Wlogical-not-parentheses  -Wlong-long @gol
>  -Wmain  -Wmaybe-uninitialized  -Wmemset-elt-size  -Wmemset-transposed-args 
> @gol
>  -Wmisleading-indentation  -Wmissing-attributes -Wmissing-braces @gol
> --Wmissing-field-initializers  -Wmissing-include-dirs @gol
> +-Wmissing-field-initializers  -Wmissing-include-dirs  -Wmissing-profile @gol
>  -Wno-multichar  -Wmultistatement-macros  -Wnonnull  -Wnonnull-compare @gol
>  -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
>  -Wnull-dereference  -Wodr  -Wno-overflow  -Wopenmp-simd  @gol
> @@ -4816,6 +4816,25 @@ This warning is enabled by @option{-Wall}.
>  @opindex Wno-missing-include-dirs
>  Warn if a user-supplied include directory does not exist.
>  
> +@item -Wmissing-profile
> +@opindex Wmissing-profile
> +@opindex Wno-missing-profile
> +Warn if feedback profiles are missing when using the
> +@option{-fprofile-use} option.
> +If a new function or a new file is added to the user code between compiling
> +with @option{-fprofile-gen} and with @option{-fprofile-use} without

s/profile-gen/profile-generate

> +regenerating the profiles, the