Backported r185231 from trunk. (issue 6878045)

2012-12-03 Thread asharif

Reviewers: davidxl, xur,

Message:
When I backported this patch to google/gcc-4.6, I forgot to do it for
main. So now I am backporting this to google/main, google/4_7 and
google/4_7-mobile.

This is the first of the 3 (google/main is the target).

I am running crosstool_validate.py and it should most likely pass.
Meanwhile, please look at the patch.

Description:
2012-03-12  Richard Guenther  

* gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
* gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
(__gthread_mutex_init_function): New function.
* gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.

PR gcov/49484
* libgcov.c: Include gthr.h.
(__gcov_flush_mx): New global variable.
(init_mx, init_mx_once): New functions.
(__gcov_flush): Protect self with a mutex.
(__gcov_fork): Re-initialize mutex after forking.
* unwind-dw2-fde.c: Change condition under which to use
__GTHREAD_MUTEX_INIT_FUNCTION.

Please review this at https://codereview.appspot.com/6878045/

Affected files:
   M.
   Mcontrib
   Mgcc
  M gcc/ChangeLog.google-main
   Mgcc/testsuite/gcc.target/powerpc/ppc-round.c
  M libgcc/ChangeLog
  M libgcc/gthr-posix.h
  M libgcc/gthr-single.h
  M libgcc/gthr.h
  M libgcc/libgcov.c
  M libgcc/unwind-dw2-fde.c
   Mlibjava/classpath



Property changes on: .
___
Modified: svn:mergeinfo
   Merged /trunk:r185231


Property changes on: gcc
___
Modified: svn:mergeinfo
   Merged /trunk/gcc:r185231


Property changes on: gcc/testsuite/gcc.target/powerpc/ppc-round.c
___
Modified: svn:mergeinfo
   Merged /trunk/gcc/testsuite/gcc.target/powerpc/ppc-round.c:r185231

Index: gcc/ChangeLog.google-main
===
--- gcc/ChangeLog.google-main   (revision 194106)
+++ gcc/ChangeLog.google-main   (working copy)
@@ -1,3 +1,24 @@
+2012-12-03  Ahmad Sharif 
+
+   Backport r185231 from trunk.
+
+   2012-03-12  Richard Guenther  
+
+   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
+   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+   (__gthread_mutex_init_function): New function.
+   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+
+   PR gcov/49484
+   * libgcov.c: Include gthr.h.
+   (__gcov_flush_mx): New global variable.
+   (init_mx, init_mx_once): New functions.
+   (__gcov_flush): Protect self with a mutex.
+   (__gcov_fork): Re-initialize mutex after forking.
+   * unwind-dw2-fde.c: Change condition under which to use
+   __GTHREAD_MUTEX_INIT_FUNCTION.
+
+
 2012-11-09  Harshit Chopra  

 * gcc/c-family/c-common.c  
(handle_always_patch_for_instrumentation_attribute):

Index: libgcc/unwind-dw2-fde.c
===
--- libgcc/unwind-dw2-fde.c (revision 194106)
+++ libgcc/unwind-dw2-fde.c (working copy)
@@ -47,11 +47,10 @@

 #ifdef __GTHREAD_MUTEX_INIT
 static __gthread_mutex_t object_mutex = __GTHREAD_MUTEX_INIT;
+#define init_object_mutex_once()
 #else
 static __gthread_mutex_t object_mutex;
-#endif

-#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
 static void
 init_object_mutex (void)
 {
@@ -64,8 +63,6 @@
   static __gthread_once_t once = __GTHREAD_ONCE_INIT;
   __gthread_once (&once, init_object_mutex);
 }
-#else
-#define init_object_mutex_once()
 #endif

 /* Called from crtbegin.o to register the unwind info for an object.  */
Index: libgcc/gthr.h
===
--- libgcc/gthr.h   (revision 194106)
+++ libgcc/gthr.h   (working copy)
@@ -52,11 +52,12 @@
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
  __GTHREAD_MUTEX_INIT_FUNCTION
-   some systems can't initialize a mutex without a
-   function call.  On such systems, define this to a
-   function which looks like this:
+   to initialize __gthread_mutex_t to get a fast
+   non-recursive mutex.
+   Define this to a function which looks like this:
  void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
-   Don't define __GTHREAD_MUTEX_INIT in this case
+   Some systems can't initialize a mutex without a
+   function call.  Don't define __GTHREAD_MUTEX_INIT in this case.
  __GTHREAD_RECURSIVE_MUTEX_INIT
  __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
as above, but for a recursive mutex.
Index: libgcc/gthr-posix.h
===
--- libgcc/gthr-posix.h (revision 194106)
+++ libgcc/gthr-posix.h (working copy)
@

Re: Backported r185231 from trunk. (issue 6878045)

2012-12-03 Thread asharif

On 2012/12/04 00:50:45, asharif wrote:

When I backported this patch to google/gcc-4.6, I forgot to do it for

main. So

now I am backporting this to google/main, google/4_7 and

google/4_7-mobile.


This is the first of the 3 (google/main is the target).



I am running crosstool_validate.py and it should most likely pass.

Meanwhile,

please look at the patch.


FYI, the original patch is here:
https://codereview.appspot.com/6139063/, and it was submitted in CL:
http://gcc.gnu.org/viewcvs?view=revision&revision=187026.

https://codereview.appspot.com/6878045/


Backported r185231 from trunk to google/gcc-4_7. (issue 6888044)

2012-12-05 Thread asharif

Reviewers: xur, davidxl,

Message:
Please take a look at this patch.

Description:
2012-03-12  Richard Guenther  

* gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
* gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
(__gthread_mutex_init_function): New function.
* gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.

PR gcov/49484
* libgcov.c: Include gthr.h.
(__gcov_flush_mx): New global variable.
(init_mx, init_mx_once): New functions.
(__gcov_flush): Protect self with a mutex.
(__gcov_fork): Re-initialize mutex after forking.
* unwind-dw2-fde.c: Change condition under which to use
__GTHREAD_MUTEX_INIT_FUNCTION.

Please review this at https://codereview.appspot.com/6888044/

Affected files:
   M.
   Mgcc
  M gcc/ChangeLog.google-4_7
   Mgcc/testsuite/gcc.target/powerpc/ppc-round.c
  M libgcc/ChangeLog
  M libgcc/gthr-posix.h
  M libgcc/gthr-single.h
  M libgcc/gthr.h
  M libgcc/libgcov.c
  M libgcc/unwind-dw2-fde.c
   Mlibjava/classpath



Property changes on: .
___
Modified: svn:mergeinfo
   Merged /trunk:r185231


Property changes on: libjava/classpath
___
Modified: svn:mergeinfo
   Merged /trunk/libjava/classpath:r185231


Property changes on: gcc
___
Modified: svn:mergeinfo
   Merged /trunk/gcc:r185231

Index: gcc/ChangeLog.google-4_7
===
--- gcc/ChangeLog.google-4_7(revision 194106)
+++ gcc/ChangeLog.google-4_7(working copy)
@@ -1,3 +1,23 @@
+2012-12-03  Ahmad Sharif 
+
+   Backport r185231 from trunk.
+
+   2012-03-12  Richard Guenther  
+
+   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
+   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+   (__gthread_mutex_init_function): New function.
+   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+
+   PR gcov/49484
+   * libgcov.c: Include gthr.h.
+   (__gcov_flush_mx): New global variable.
+   (init_mx, init_mx_once): New functions.
+   (__gcov_flush): Protect self with a mutex.
+   (__gcov_fork): Re-initialize mutex after forking.
+   * unwind-dw2-fde.c: Change condition under which to use
+   __GTHREAD_MUTEX_INIT_FUNCTION.
+
 2010-12-01  Xinliang David Li  

Backport r194038 from trunk

Property changes on: gcc/testsuite/gcc.target/powerpc/ppc-round.c
___
Modified: svn:mergeinfo
   Merged /trunk/gcc/testsuite/gcc.target/powerpc/ppc-round.c:r185231

Index: libgcc/gthr-posix.h
===
--- libgcc/gthr-posix.h (revision 194106)
+++ libgcc/gthr-posix.h (working copy)
@@ -63,6 +63,7 @@
 #define __GTHREAD_HAS_COND 1

 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
+#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
 #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
 #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
 #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
@@ -754,6 +755,14 @@
 #endif

 static inline int
+__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+return __gthrw_(pthread_mutex_init) (__mutex, NULL);
+  return 0;
+}
+
+static inline int
 __gthread_mutex_destroy (__gthread_mutex_t *__mutex)
 {
   if (__gthread_active_p ())
Index: libgcc/gthr.h
===
--- libgcc/gthr.h   (revision 194106)
+++ libgcc/gthr.h   (working copy)
@@ -52,11 +52,12 @@
to initialize __gthread_mutex_t to get a fast
non-recursive mutex.
  __GTHREAD_MUTEX_INIT_FUNCTION
-   some systems can't initialize a mutex without a
-   function call.  On such systems, define this to a
-   function which looks like this:
+   to initialize __gthread_mutex_t to get a fast
+   non-recursive mutex.
+   Define this to a function which looks like this:
  void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
-   Don't define __GTHREAD_MUTEX_INIT in this case
+   Some systems can't initialize a mutex without a
+   function call.  Don't define __GTHREAD_MUTEX_INIT in this case.
  __GTHREAD_RECURSIVE_MUTEX_INIT
  __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
as above, but for a recursive mutex.
Index: libgcc/gthr-single.h
===
--- libgcc/gthr-single.h(revision 194106)
+++ libgcc/gthr-single.h(working copy)
@@ -36,6 +36,7 @@

 #define __GTHREAD

Re: Backported r185234 from trunk (r194264 from google/gcc-4_7). (issue 6904043)

2012-12-06 Thread asharif

On 2012/12/06 21:19:17, shenhan wrote:

On 2012/12/06 20:18:02, asharif wrote:
> Please review this backport needed to enable PGO for Chrome.



I think we shall only change ChangeLog.google-xxx when adding changes

to google

branch.



Quote from Diego -
'Please remember to use ChangeLog.google-xxx when adding ChangeLog

entries to

the google branches.'


I don't think the rule is to *only* update ChangeLog.google*. The rule
is to update ChangeLog, but also update ChangeLog.google*.

In the next patchset I have updated ChangeLog.google-4_7-mobile.

PTAL.

https://codereview.appspot.com/6904043/


Re: Backported r185234 from trunk (r194264 from google/gcc-4_7). (issue 6904043)

2012-12-06 Thread asharif

On 2012/12/06 22:02:16, Diego Novillo wrote:

On Thu, Dec 6, 2012 at 4:51 PM,   wrote:



> I don't think the rule is to *only* update ChangeLog.google*. The

rule

> is to update ChangeLog, but also update ChangeLog.google*.



Just ChangeLog.google*, actually.  When cherry picking revisions from
other branches, it's better not to update ChangeLog.  It's not really
necessary and it will actually cause merge conflicts later.  I'll
clarify the developer notes.




Thanks.  Diego.


Done.

I have removed the ChangeLog chunk. PTAL.

https://codereview.appspot.com/6904043/


Re: Added better handling of outdated profile data. (issue 5989046)

2012-07-09 Thread asharif

On 2012/04/24 22:14:17, asharif wrote:

Ping?


Ping.

I also filed a bug here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53547



Here is the formatted ChangeLog in case you want a summary of what I

did:


* gcc/ipa-inline.c (edge_badness): Make sure profile is valid before
using it to compute badness.
* gcc/predict.c (maybe_hot_frequency_p): Ditto.
(cgraph_maybe_hot_edge_p): Ditto.
(maybe_hot_edge_p): Ditto.
(probably_never_executed_bb_p): Ditto.
(compute_function_frequency): Ditto.
* gcc/profile.c (compute_branch_probabilities): Return without setting
the profile read flag if get_exec_counts returns NULL.
* gcc/tree.h: Added macro for accessing profile status.



The patch is in the original email and on the codereview issue
(http://codereview.appspot.com/5989046/).



http://codereview.appspot.com/5989046/


Backported r185231 from trunk. (issue 6139063)

2012-04-30 Thread asharif

Reviewers: xur, davidxl, iant2,

Message:
I backported the following patch:

2012-03-12  Richard Guenther  

* gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
* gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
(__gthread_mutex_init_function): New function.
* gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.

PR gcov/49484
* libgcov.c: Include gthr.h.
(__gcov_flush_mx): New global variable.
(init_mx, init_mx_once): New functions.
(__gcov_flush): Protect self with a mutex.
(__gcov_fork): Re-initialize mutex after forking.
* unwind-dw2-fde.c: Change condition under which to use
__GTHREAD_MUTEX_INIT_FUNCTION.



Please review this at http://codereview.appspot.com/6139063/

Affected files:
   M.
  M gcc/ChangeLog.google-4_6
  M gcc/gthr-posix.h
  M gcc/gthr-single.h
  M gcc/gthr.h
  M gcc/libgcov.c
  M gcc/unwind-dw2-fde.c
  M libgcc/ChangeLog


Index: .
===
--- .   (revision 186999)
+++ .   (working copy)

Property changes on: .
___
Modified: svn:mergeinfo
   Merged /trunk:r185231
Index: libgcc/ChangeLog
===
--- libgcc/ChangeLog(revision 186999)
+++ libgcc/ChangeLog(working copy)
@@ -1,3 +1,19 @@
+2012-03-12  Richard Guenther  
+
+   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
+   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+   (__gthread_mutex_init_function): New function.
+   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+
+   PR gcov/49484
+   * libgcov.c: Include gthr.h.
+   (__gcov_flush_mx): New global variable.
+   (init_mx, init_mx_once): New functions.
+   (__gcov_flush): Protect self with a mutex.
+   (__gcov_fork): Re-initialize mutex after forking.
+   * unwind-dw2-fde.c: Change condition under which to use
+   __GTHREAD_MUTEX_INIT_FUNCTION.
+
 2012-03-01  Release Manager

* GCC 4.6.3 released.
Index: gcc/unwind-dw2-fde.c
===
--- gcc/unwind-dw2-fde.c(revision 186999)
+++ gcc/unwind-dw2-fde.c(working copy)
@@ -46,11 +46,10 @@

 #ifdef __GTHREAD_MUTEX_INIT
 static __gthread_mutex_t object_mutex = __GTHREAD_MUTEX_INIT;
+#define init_object_mutex_once()
 #else
 static __gthread_mutex_t object_mutex;
-#endif

-#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
 static void
 init_object_mutex (void)
 {
@@ -63,8 +62,6 @@
   static __gthread_once_t once = __GTHREAD_ONCE_INIT;
   __gthread_once (&once, init_object_mutex);
 }
-#else
-#define init_object_mutex_once()
 #endif

 /* Called from crtbegin.o to register the unwind info for an object.  */
Index: gcc/ChangeLog.google-4_6
===
--- gcc/ChangeLog.google-4_6(revision 186999)
+++ gcc/ChangeLog.google-4_6(working copy)
@@ -1,3 +1,22 @@
+2012-02-21   Ahmad Sharif  
+
+   Backport from mainline r185231.
+   2012-03-12  Richard Guenther  
+
+   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
+   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+   (__gthread_mutex_init_function): New function.
+   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+
+   PR gcov/49484
+   * libgcov.c: Include gthr.h.
+   (__gcov_flush_mx): New global variable.
+   (init_mx, init_mx_once): New functions.
+   (__gcov_flush): Protect self with a mutex.
+   (__gcov_fork): Re-initialize mutex after forking.
+   * unwind-dw2-fde.c: Change condition under which to use
+   __GTHREAD_MUTEX_INIT_FUNCTION.
+
 2012-04-25   Rong Xu  

* gcc/gcc.c (ripa_lto_spec): Support -S in streaming LIPO.
Index: gcc/libgcov.c
===
--- gcc/libgcov.c   (revision 186999)
+++ gcc/libgcov.c   (working copy)
@@ -46,6 +46,7 @@
 #include "tsystem.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "gthr.h"
 #endif /* __KERNEL__ */

 #if 1
@@ -667,6 +668,26 @@
   info->version = 0;
 }

+#ifdef __GTHREAD_MUTEX_INIT
+ATTRIBUTE_HIDDEN __gthread_mutex_t __gcov_flush_mx = __GTHREAD_MUTEX_INIT;
+#define init_mx_once()
+#else
+__gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
+
+static void
+init_mx (void)
+{
+  __GTHREAD_MUTEX_INIT_FUNCTION (&__gcov_flush_mx);
+}
+static void
+init_mx_once (void)
+{
+  static __gthread_once_t once = __GTHREAD_ONCE_INIT;
+  __gthread_once (&once, init_mx);
+}
+#endif
+
+
 /* Called before fork or exec - write out profile information gathered so
far and reset it to zero.  This avoids duplication or loss of the
profile information gathered so far.  */
@@ -676,6 +697,9 @@
 {
   const struct gcov_info *gi_ptr;

+  init_mx_once ();
+  __gt

Re: Backported r185231 from trunk. (issue 6139063)

2012-05-01 Thread asharif

On 2012/04/30 19:54:14, asharif wrote:

I backported the following patch:



2012-03-12  Richard Guenther  <mailto:rguent...@suse.de>



* gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
* gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
(__gthread_mutex_init_function): New function.
* gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.



PR gcov/49484
* libgcov.c: Include gthr.h.
(__gcov_flush_mx): New global variable.
(init_mx, init_mx_once): New functions.
(__gcov_flush): Protect self with a mutex.
(__gcov_fork): Re-initialize mutex after forking.
* unwind-dw2-fde.c: Change condition under which to use
__GTHREAD_MUTEX_INIT_FUNCTION.


Ping.

I did not see any degradation on internal benchmarks.


http://codereview.appspot.com/6139063/


Re: Backported r185231 from trunk. (issue 6139063)

2012-05-01 Thread asharif

On 2012/05/01 20:44:05, davidxl wrote:

Ok for google branches (please also backport to google/gcc_47 branch.


Commited as r187026.

I'll backport to google/gcc-4_7 as well.



David




On 2012/05/01 20:37:44, asharif wrote:
> On 2012/04/30 19:54:14, asharif wrote:
> > I backported the following patch:
> >
> > 2012-03-12  Richard Guenther  <mailto:rguent...@suse.de>
> >
> >   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
> >   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
> >   (__gthread_mutex_init_function): New function.
> >   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
> >
> >   PR gcov/49484
> >   * libgcov.c: Include gthr.h.
> >   (__gcov_flush_mx): New global variable.
> >   (init_mx, init_mx_once): New functions.
> >   (__gcov_flush): Protect self with a mutex.
> >   (__gcov_fork): Re-initialize mutex after forking.
> >   * unwind-dw2-fde.c: Change condition under which to use
> >   __GTHREAD_MUTEX_INIT_FUNCTION.
>
> Ping.
>
> I did not see any degradation on internal benchmarks.



http://codereview.appspot.com/6139063/


Backported r185231 from trunk to google/gcc-4_7. (issue 6151043)

2012-05-01 Thread asharif

Reviewers: xur, davidxl,

Message:
Please take a look at this.

Description:
This fixes an issue with profile collection when multiple threads call
fork() around the same time.

2012-03-12  Richard Guenther  

* gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
* gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
(__gthread_mutex_init_function): New function.
* gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.

PR gcov/49484
* libgcov.c: Include gthr.h.
(__gcov_flush_mx): New global variable.
(init_mx, init_mx_once): New functions.
(__gcov_flush): Protect self with a mutex.
(__gcov_fork): Re-initialize mutex after forking.
* unwind-dw2-fde.c: Change condition under which to use
__GTHREAD_MUTEX_INIT_FUNCTION.


Please review this at http://codereview.appspot.com/6151043/

Affected files:
   M.
  M libgcc/ChangeLog
  M libgcc/ChangeLog.google-4_7
  M libgcc/gthr-posix.h
  M libgcc/gthr-single.h
  M libgcc/gthr.h
  M libgcc/libgcov.c
  M libgcc/unwind-dw2-fde.c


Index: .
===
--- .   (revision 187027)
+++ .   (working copy)

Property changes on: .
___
Modified: svn:mergeinfo
   Merged /trunk:r185231
Index: libgcc/ChangeLog
===
--- libgcc/ChangeLog(revision 187027)
+++ libgcc/ChangeLog(working copy)
@@ -1,3 +1,19 @@
+2012-03-12  Richard Guenther  
+
+   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
+   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+   (__gthread_mutex_init_function): New function.
+   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+
+   PR gcov/49484
+   * libgcov.c: Include gthr.h.
+   (__gcov_flush_mx): New global variable.
+   (init_mx, init_mx_once): New functions.
+   (__gcov_flush): Protect self with a mutex.
+   (__gcov_fork): Re-initialize mutex after forking.
+   * unwind-dw2-fde.c: Change condition under which to use
+   __GTHREAD_MUTEX_INIT_FUNCTION.
+
 2012-04-20  Thomas Schwinge  

struct siginfo vs. siginfo_t
Index: libgcc/ChangeLog.google-4_7
===
--- libgcc/ChangeLog.google-4_7 (revision 187027)
+++ libgcc/ChangeLog.google-4_7 (working copy)
@@ -1,3 +1,20 @@
+2012-05-01  Ahmad Sharif  
+   2012-03-12  Richard Guenther  
+
+   * gthr.h (__GTHREAD_MUTEX_INIT_FUNCTION): Adjust specification.
+   * gthr-posix.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+   (__gthread_mutex_init_function): New function.
+   * gthr-single.h (__GTHREAD_MUTEX_INIT_FUNCTION): Define.
+
+   PR gcov/49484
+   * libgcov.c: Include gthr.h.
+   (__gcov_flush_mx): New global variable.
+   (init_mx, init_mx_once): New functions.
+   (__gcov_flush): Protect self with a mutex.
+   (__gcov_fork): Re-initialize mutex after forking.
+   * unwind-dw2-fde.c: Change condition under which to use
+   __GTHREAD_MUTEX_INIT_FUNCTION.
+
 2012-04-17  Teresa Johnson  

Backport from google/main rev r186550
Index: libgcc/gthr-single.h
===
--- libgcc/gthr-single.h(revision 187027)
+++ libgcc/gthr-single.h(working copy)
@@ -36,6 +36,7 @@

 #define __GTHREAD_ONCE_INIT 0
 #define __GTHREAD_MUTEX_INIT 0
+#define __GTHREAD_MUTEX_INIT_FUNCTION (mx)
 #define __GTHREAD_RECURSIVE_MUTEX_INIT 0

 #define UNUSED __attribute__((unused))
Index: libgcc/libgcov.c
===
--- libgcc/libgcov.c(revision 187027)
+++ libgcc/libgcov.c(working copy)
@@ -48,6 +48,7 @@
 #include "tm.h"
 #endif /* __KERNEL__ */
 #include "libgcc_tm.h"
+#include "gthr.h"

 #if 1
 #define THREAD_PREFIX __thread
@@ -668,6 +669,25 @@
   info->version = 0;
 }

+#ifdef __GTHREAD_MUTEX_INIT
+ATTRIBUTE_HIDDEN __gthread_mutex_t __gcov_flush_mx = __GTHREAD_MUTEX_INIT;
+#define init_mx_once()
+#else
+__gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
+
+static void
+init_mx (void)
+{
+  __GTHREAD_MUTEX_INIT_FUNCTION (&mx);
+}
+static void
+init_mx_once (void)
+{
+  static __gthread_once_t once = __GTHREAD_ONCE_INIT;
+  __gthread_once (&once, init_mx);
+}
+#endif
+
 /* Called before fork or exec - write out profile information gathered so
far and reset it to zero.  This avoids duplication or loss of the
profile information gathered so far.  */
@@ -677,6 +697,9 @@
 {
   const struct gcov_info *gi_ptr;

+  init_mx_once ();
+  __gthread_mutex_lock (&__gcov_flush_mx);
+
   __gcov_stop_pmu_profiler ();
   gcov_exit ();
   for (gi_ptr = __gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
@@ -700,6 +723,7 @@
 }
 }
   __gcov_start_pmu_profiler ();
+  __gthread_mutex_unlock (&__

Re: Backported r187026 from branches/google/gcc-4_6 (issue 6148044)

2012-05-02 Thread asharif

On 2012/05/01 22:51:22, jingyu wrote:

1) Please add an description entry to libgcc/ChangeLog.google-4_6


Done.



2) Your gcc/ChangeLog.google-4_6 change reverts someone else's change.

Please

update it and also update the time of your entry.


Done.



3) Please list in the Description field what tests you have done.


Done.



Thanks,
Jing



On 2012/05/01 22:40:12, asharif wrote:
> +carrot@




http://codereview.appspot.com/6148044/


Re: [google/gcc-4_6_3-mobile] Port r187569 from google/gcc-4_6 branch (issue 6210060)

2012-05-16 Thread asharif

On 2012/05/16 01:02:26, shenhan wrote:

Hi Amhad and Jing, could you take a look at this CL at
http://codereview.appspot.com/6210060/



Thanks,
-Han


Shouldn't this have a corresponding ChangeLog entry and a
ChangeLog.google-gcc-4_6 entry?

http://codereview.appspot.com/6210060/


Re: [google/gcc-4_6_3-mobile] Port r187569 from google/gcc-4_6 branch (issue 6210060)

2012-05-16 Thread asharif

On 2012/05/16 22:11:08, shenhan wrote:

On 2012/05/16 17:27:59, asharif1 wrote:
> On 2012/05/16 01:02:26, shenhan wrote:
> > Hi Amhad and Jing, could you take a look at this CL at
> > http://codereview.appspot.com/6210060/
> >
> > Thanks,
> > -Han
>
> Shouldn't this have a corresponding ChangeLog entry and a
> ChangeLog.google-gcc-4_6 entry?



Hi Ahmad, thanks!



Done recreating the patch from "svn merge -c".



Regards,
-Han


Thanks a lot, shenhan.

lgtm.

http://codereview.appspot.com/6210060/


Re: [trunk] Copy TREE_STATIC() property from id in dwarf2asm.c (issue 6133061)

2012-05-31 Thread asharif

Reviewers: xur, davidxl, iant2, Diego Novillo,

Message:
The relevant bug is this:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53546.

Please take a look and provide feedback.

Thanks,

Description:
2012-05-31   Ahmad Sharif  

* gcc/dwarf2asm.c: (dw2_output_indirect_constant_1): Copy TREE_STATIC()
attribute from id to decl.

Index: gcc/dwarf2asm.c
===
--- gcc/dwarf2asm.c (revision 188089)
+++ gcc/dwarf2asm.c (working copy)
@@ -907,6 +907,7 @@
   DECL_IGNORED_P (decl) = 1;
   DECL_INITIAL (decl) = decl;
   TREE_READONLY (decl) = 1;
+  TREE_STATIC (decl) = TREE_STATIC (id);

   if (TREE_PUBLIC (id))
 {
@@ -915,8 +916,6 @@
   if (USE_LINKONCE_INDIRECT)
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
 }
-  else
-TREE_STATIC (decl) = 1;

   sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
   assemble_variable (decl, 1, 1, 1);


Please review this at http://codereview.appspot.com/6133061/

Affected files:
  M gcc/dwarf2asm.c


2012-04-30   Ahmad Sharif  

* gcc/dwarf2asm.c: copy TREE_STATIC() property from id.

Index: gcc/dwarf2asm.c
===
--- gcc/dwarf2asm.c (revision 186998)
+++ gcc/dwarf2asm.c (working copy)
@@ -907,6 +907,7 @@
   DECL_IGNORED_P (decl) = 1;
   DECL_INITIAL (decl) = decl;
   TREE_READONLY (decl) = 1;
+  TREE_STATIC (decl) = TREE_STATIC (id);

   if (TREE_PUBLIC (id))
 {
@@ -915,8 +916,6 @@
   if (USE_LINKONCE_INDIRECT)
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
 }
-  else
-TREE_STATIC (decl) = 1;

   sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
   assemble_variable (decl, 1, 1, 1);




[google/main] Copy TREE_STATIC() property from id in dwarf2asm.c (issue 6273045)

2012-06-01 Thread asharif

Reviewers: davidxl, xur, bjanakiraman_google.com,

Message:
A trunk version of this patch is already under review. I'm creating this
CL in order to get this patch in before the branch date.



Please review this at http://codereview.appspot.com/6273045/

Affected files:
  M gcc/ChangeLog.google-main
  M gcc/dwarf2asm.c


Index: gcc/dwarf2asm.c
===
--- gcc/dwarf2asm.c (revision 188129)
+++ gcc/dwarf2asm.c (working copy)
@@ -907,6 +907,7 @@
   DECL_IGNORED_P (decl) = 1;
   DECL_INITIAL (decl) = decl;
   TREE_READONLY (decl) = 1;
+  TREE_STATIC (decl) = TREE_STATIC(id);

   if (TREE_PUBLIC (id))
 {
@@ -915,8 +916,6 @@
   if (USE_LINKONCE_INDIRECT)
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
 }
-  else
-TREE_STATIC (decl) = 1;

   sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
   assemble_variable (decl, 1, 1, 1);
Index: gcc/ChangeLog.google-main
===
--- gcc/ChangeLog.google-main   (revision 188129)
+++ gcc/ChangeLog.google-main   (working copy)
@@ -1,3 +1,8 @@
+2012-06-01   Ahmad Sharif  
+
+   * gcc/dwarf2asm.c: (dw2_output_indirect_constant_1) copy the TREE_STATIC
+   attribute from id to decl.
+
 2012-05-30  Dehao Chen  

* predict.c (predict_extra_loop_exit): New function to predict for




Re: [google/main] Copy TREE_STATIC() property from id in dwarf2asm.c (issue 6273045)

2012-06-04 Thread asharif

On 2012/06/02 01:52:28, asharif wrote:

A trunk version of this patch is already under review. I'm creating

this CL in

order to get this patch in before the branch date.


Ping.

http://codereview.appspot.com/6273045/


[branches/google/gcc-4_6] Backported r179661 and 179662 from mainline. (issue 5989043)

2012-04-04 Thread asharif

Reviewers: Diego Novillo, jingyu, davidxl,

Message:
Please take a look at this patch and tell me if it's OK for
branches/google/gcc-4_6.

Description:
Backported the following patch from trunk:

2011-10-07  Andrew Stubbs  

gcc/
* config/arm/predicates.md (shift_amount_operand): Remove constant
range check.
(shift_operator): Check range of constants for all shift operators.

gcc/testsuite/
* gcc.dg/pr50193-1.c: New file.
* gcc.target/arm/shiftable.c: New file.


Please review this at http://codereview.appspot.com/5989043/

Affected files:
   M.
  M gcc/ChangeLog
  M gcc/ChangeLog.google-4_6
  M gcc/config/arm/predicates.md
  M gcc/testsuite/ChangeLog
  A  +  gcc/testsuite/gcc.dg/pr50193-1.c
  A  +  gcc/testsuite/gcc.target/arm/shiftable.c




Re: [branches/google/gcc-4_6] Backported r179661 and 179662 from mainline. (issue 5989043)

2012-04-05 Thread asharif

Committed as r186168.

http://codereview.appspot.com/5989043/


[branches/google/gcc-4_6_2-mobile] Backported r186168 from branches/google/gcc-4_6. (issue 5991052)

2012-04-05 Thread asharif

Reviewers: jingyu, bjanakiraman_google.com, dougkwan,

Message:
PTAL.

Description:
2012-04-04   Ahmad Sharif  

Backport from mainline r179661, r179662.

2011-10-07  Andrew Stubbs  

gcc/
* config/arm/predicates.md (shift_amount_operand): Remove constant
range check.
(shift_operator): Check range of constants for all shift operators.

gcc/testsuite/
* gcc.dg/pr50193-1.c: New file.
* gcc.target/arm/shiftable.c: New file.


Please review this at http://codereview.appspot.com/5991052/

Affected files:
   M.
  M gcc/ChangeLog
  M gcc/ChangeLog.google-4_6
  M gcc/config/arm/predicates.md
  M gcc/testsuite/ChangeLog
  A  +  gcc/testsuite/gcc.dg/pr50193-1.c
  A  +  gcc/testsuite/gcc.target/arm/shiftable.c




Added better handling of outdated profile data. (issue 5989046)

2012-04-05 Thread asharif

Reviewers: jh_suse.cz, davidxl, bjanakiraman_google.com,

Message:
Jan, please take a look and provide some feedback.

Thanks,

Description:
Added better handling of outdated profiles.

gcc dumps profile information in .gcda files that contain the function
id and
the corresponding counter information. The function cfg and line number
checksums are also stored along with the ids. When the program source
changes
between when the instrumentation run is done vs. when the -fprofile-use
is
passed, gcc will have functions that do not have a valid profile. These
functions could be hot and may not be inlined because the summary of the
profile
is still valid (sum_max, etc.). This can lead to a situation where the
performance with -fprofile-use is lower than with -fno-profile-use.

It is easy to have a situation where the profile is outdated. A single
line
change in the header file can potentially renumber all functions and
none of the
ids will match the profile generated from the old source.

This patch makes the performance degradation in the outdated case much
less
severe. It adds checks that the profile has been read for a certain
function
before using the counter values (which are 0 in the case where the
profile is
invalid).

Without this patch we see up to 15% performance degradation by using
outdated
profiles vs. not using any profile information for Chrome. This patch
decreases
that degradation down to (0% to 4%).


Please review this at http://codereview.appspot.com/5989046/

Affected files:
  M gcc/ipa-inline.c
  M gcc/predict.c
  M gcc/profile.c
  M gcc/tree.h


From 88d8094b6408b38d05241ecf574a51edabeabb3a Mon Sep 17 00:00:00 2001
From: Ahmad Sharif 
Date: Wed, 4 Apr 2012 19:09:23 -0700
Subject: [PATCH] Added better handling of outdated profiles.

gcc dumps profile information in .gcda files that contain the function id  
and

the corresponding counter information. The function cfg and line number
checksums are also stored along with the ids. When the program source  
changes

between when the instrumentation run is done vs. when the -fprofile-use is
passed, gcc will have functions that do not have a valid profile. These
functions could be hot and may not be inlined because the summary of the  
profile

is still valid (sum_max, etc.). This can lead to a situation where the
performance with -fprofile-use is lower than with -fno-profile-use.

It is easy to have a situation where the profile is outdated. A single line
change in the header file can potentially renumber all functions and none  
of the

ids will match the profile generated from the old source.

This patch makes the performance degradation in the outdated case much less
severe. It adds checks that the profile has been read for a certain function
before using the counter values (which are 0 in the case where the profile  
is

invalid).

Without this patch we see up to 15% performance degradation by using  
outdated
profiles vs. not using any profile information for Chrome. This patch  
decreases

that degradation down to (0% to 4%).
---
 gcc/ipa-inline.c |4 +++-
 gcc/predict.c|   13 +
 gcc/profile.c|2 +-
 gcc/tree.h   |5 +
 4 files changed, 18 insertions(+), 6 deletions(-)

Index: gcc/ipa-inline.c
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index d7ccf68..fbc6c4a 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -780,7 +780,9 @@ edge_badness (struct cgraph_edge *edge, bool dump)
 The fraction is upside down, becuase on edge counts and time beneits
 the bounds are known. Edge growth is essentially unlimited.  */

-  else if (max_count)
+  else if (max_count
+   && DECL_READ_PROFILE_P(edge->caller->decl)
+   && DECL_READ_PROFILE_P(edge->callee->decl))
 {
   int relbenefit = relative_time_benefit (callee_info, edge,  
time_growth);

   badness =
Index: gcc/predict.c
diff --git a/gcc/predict.c b/gcc/predict.c
index c12b45f..94af954 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -114,7 +114,8 @@ static inline bool
 maybe_hot_frequency_p (int freq)
 {
   struct cgraph_node *node = cgraph_get_node (current_function_decl);
-  if (!profile_info || !flag_branch_probabilities)
+  if (!profile_info || !flag_branch_probabilities
+  || !DECL_READ_PROFILE_P(current_function_decl))
 {
   if (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)
 return false;
@@ -162,6 +163,7 @@ bool
 cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
 {
   if (profile_info && flag_branch_probabilities
+  && DECL_READ_PROFILE_P(edge->caller->decl)
   && (edge->count
  <= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
 return false;
@@ -202,9 +204,11 @@ maybe_hot_edge_p (edge e)
 bool
 probably_never_executed_bb_p (const_basic_block bb)
 {
-  if (profile_info && flag_branch_probabilities)
+  if (profile_info && flag_branch_probabilities
+  && DECL_READ_PROFILE_P(current_function_decl))
 return ((bb->count + profile_info->runs / 2

Re: [branches/google/gcc-4_6_2-mobile] Backported r186168 from branches/google/gcc-4_6. (issue 5991052)

2012-04-05 Thread asharif

Added shenhan to the list of reviewers.

http://codereview.appspot.com/5991052/


Re: [google/gcc-4_6] Added dejagnu base line for x86_64-cros-linux-gnu. (issue 5990044)

2012-04-05 Thread asharif

On 2012/04/05 17:25:44, shenhan wrote:

Hi Jing and Ahmad,



This adds a new test base line for x86_64-cros-linux-gnu. Please take

a look.


Thanks,
Han


lgtm.

http://codereview.appspot.com/5990044/


Re: [branches/google/gcc-4_6_2-mobile] Backported r186168 from branches/google/gcc-4_6. (issue 5991052)

2012-04-05 Thread asharif

On 2012/04/05 21:56:19, asharif wrote:

Added shenhan to the list of reviewers.


I'm abandoning this CL in favor of a new one which will be a bulk
integrate from branches/google/gcc-4_6 to
branches/google/gcc-4_6_2-mobile.

Sorry about the noise.

http://codereview.appspot.com/5991052/


Re: Added better handling of outdated profile data. (issue 5989046)

2012-04-10 Thread asharif

On 2012/04/05 18:53:28, asharif wrote:

Jan, please take a look and provide some feedback.



Thanks,


Ping?

http://codereview.appspot.com/5989046/


Re: Added better handling of outdated profile data. (issue 5989046)

2012-04-24 Thread asharif
Ping?

Here is the formatted ChangeLog in case you want a summary of what I did:

* gcc/ipa-inline.c (edge_badness): Make sure profile is valid before
using it to compute badness.
* gcc/predict.c (maybe_hot_frequency_p): Ditto.
(cgraph_maybe_hot_edge_p): Ditto.
(maybe_hot_edge_p): Ditto.
(probably_never_executed_bb_p): Ditto.
(compute_function_frequency): Ditto.
* gcc/profile.c (compute_branch_probabilities): Return without setting
the profile read flag if get_exec_counts returns NULL.
* gcc/tree.h: Added macro for accessing profile status.

The patch is in the original email and on the codereview issue
(http://codereview.appspot.com/5989046/).


Merged r182417 from branches/google/gcc-4_6. (issue 5491078)

2011-12-19 Thread asharif

Reviewers: xur, jingyu, shenhan, bjanakiraman_google.com,

Message:
This merges xur's patch to our mobile release branch. LGTM and I will
submit it.



Please review this at http://codereview.appspot.com/5491078/

Affected files:
   Mgcc-4_6-mobile
  M gcc-4_6-mobile/gcc/ChangeLog.google-4_6
  M gcc-4_6-mobile/gcc/libgcov.c


2011-12-19   Ahmad Sharif  

* gcc-4_6-mobile:
* gcc-4_6-mobile/gcc/ChangeLog.google-4_6:
* gcc-4_6-mobile/gcc/libgcov.c:

Index: gcc-4_6-mobile
===
--- gcc-4_6-mobile  (revision 17)
+++ gcc-4_6-mobile  (working copy)

Property changes on: gcc-4_6-mobile
___
Modified: svn:mergeinfo
   Merged /branches/google/gcc-4_6:r182417
Index: gcc-4_6-mobile/gcc/ChangeLog.google-4_6
===
--- gcc-4_6-mobile/gcc/ChangeLog.google-4_6 (revision 182489)
+++ gcc-4_6-mobile/gcc/ChangeLog.google-4_6 (working copy)
@@ -1,3 +1,10 @@
+2011-12-16   Rong Xu  
+   Backport r182416 from google/main.
+
+   2011-12-16   Rong Xu  
+
+   * libgcc/libgcov.c (gcov_merge_gcda_file): reset summary_pos.
+
 2011-12-05  Jing Yu  

Backport r171347 and r181549 from trunk.
Index: gcc-4_6-mobile/gcc/libgcov.c
===
--- gcc-4_6-mobile/gcc/libgcov.c(revision 182489)
+++ gcc-4_6-mobile/gcc/libgcov.c(working copy)
@@ -810,6 +810,7 @@
   gcov_unsigned_t tag, length;

   eof_pos = 0;
+  summary_pos = 0;

   tag = gcov_read_unsigned ();
   if (tag)




Added -fstack-protector-strong option to gcc. (issue 5496077)

2011-12-19 Thread asharif

Reviewers: Diego Novillo, shenhan, jingyu, bjanakiraman_google.com,

Message:
Please review this on behalf of shenhan@.



Please review this at http://codereview.appspot.com/5496077/

Affected files:
  M gcc-4_6-mobile/gcc/ChangeLog.google-4_6
  M gcc-4_6-mobile/gcc/cfgexpand.c
  M gcc-4_6-mobile/gcc/common.opt
  M gcc-4_6-mobile/gcc/testsuite/ChangeLog.google-4_6
  A gcc-4_6-mobile/gcc/testsuite/g++.dg/fstack-protector-strong.C
  A gcc-4_6-mobile/gcc/testsuite/gcc.dg/fstack-protector-strong.c




Backport r180979 from branches/google/gcc-4_6. (issue 5501051)

2011-12-20 Thread asharif

Reviewers: xur, bjanakiraman_google.com, jingyu,

Message:
Please review this backport.



Please review this at http://codereview.appspot.com/5501051/

Affected files:
   Mgcc-4_6-mobile
  M gcc-4_6-mobile/gcc/ChangeLog.google-4_6
  M gcc-4_6-mobile/gcc/common.opt
  M gcc-4_6-mobile/gcc/coverage.c
  M gcc-4_6-mobile/gcc/flag-types.h
  M gcc-4_6-mobile/gcc/mcf.c
  M gcc-4_6-mobile/gcc/opts.c
  M gcc-4_6-mobile/gcc/profile.c
  M gcc-4_6-mobile/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
  M gcc-4_6-mobile/gcc/testsuite/gcc.dg/pr26570.c
  M gcc-4_6-mobile/gcc/testsuite/gcc.dg/pr32773.c
  M gcc-4_6-mobile/gcc/testsuite/gcc.dg/pr40209.c
  M gcc-4_6-mobile/gcc/tree-profile.c
  M gcc-4_6-mobile/gcc/value-prof.c




Re: Backport r180979 from branches/google/gcc-4_6. (issue 5501051)

2011-12-20 Thread asharif

Adding shenhan.

http://codereview.appspot.com/5501051/


Merged r183086 and r183143 from branches/google/gcc-4_6. (issue 5541046)

2012-01-12 Thread asharif

Reviewers: xur, shenhan, jingyu,

Message:
This merges in the fix for ICE when using PGO when building Chrome.



Please review this at http://codereview.appspot.com/5541046/

Affected files:
   M.
  M gcc/ChangeLog.google-4_6
  M gcc/profile.c


Index: .
===
--- .   (revision 183143)
+++ .   (working copy)

Property changes on: .
___
Modified: svn:mergeinfo
   Merged /branches/google/gcc-4_6:r183086,183143
Index: gcc/ChangeLog.google-4_6
===
--- gcc/ChangeLog.google-4_6(revision 183143)
+++ gcc/ChangeLog.google-4_6(working copy)
@@ -1,3 +1,16 @@
+2012-01-12   Rong Xu  
+   Backport r183142 from google/main
+
+   * gcc/profile.c (compute_value_histograms): ignore the
+   histrogram when the counters not found in gcda file.
+
+2012-01-10  Rong Xu  
+
+   Backport r183081 from google/main
+
+   * gcc/profile.c (compute_value_histograms): handle the
+   case when INDIR_CALL counters not available in gcda files.
+
 2011-12-19  Han Shen  
Add a new option "-fstack-protector-strong".
* cfgexpand.c (expand_used_vars): Add logic handling
Index: gcc/profile.c
===
--- gcc/profile.c   (revision 183143)
+++ gcc/profile.c   (working copy)
@@ -790,9 +790,14 @@
   gcov_type *histogram_counts[GCOV_N_VALUE_COUNTERS];
   gcov_type *act_count[GCOV_N_VALUE_COUNTERS];
   gcov_type *aact_count;
+  bool warned[GCOV_N_VALUE_COUNTERS];
+  static const char *const ctr_names[] = GCOV_COUNTER_NAMES;

   for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++)
-n_histogram_counters[t] = 0;
+{
+  n_histogram_counters[t] = 0;
+  warned[t] = 0;
+}

   for (i = 0; i < VEC_length (histogram_value, values); i++)
 {
@@ -828,6 +833,19 @@
   t = (int) hist->type;

   aact_count = act_count[t];
+  /* If cannot find the counters in gcda file, skip and give
+ a warning.  */
+  if (aact_count == 0)
+{
+  if (!warned[t] && flag_opt_info >= OPT_INFO_MIN)
+warning (0, "cannot find %s counters in function %s.",
+ ctr_names[COUNTER_FOR_HIST_TYPE(t)],
+ IDENTIFIER_POINTER (
+   DECL_ASSEMBLER_NAME (current_function_decl)));
+  hist->n_counters = 0;
+  warned[t] = true;
+  continue;
+}
   act_count[t] += hist->n_counters;

   gimple_add_histogram_value (cfun, stmt, hist);




Re: Merged r183086 and r183143 from branches/google/gcc-4_6 into branches/google/gcc-4_6-mobile (issue 5541046)

2012-01-12 Thread asharif

On 2012/01/12 23:16:03, asharif1 wrote:

This merges in the fix for ICE when using PGO when building Chrome.


+reviewer: dnovillo.

Updated the patch description.

http://codereview.appspot.com/5541046/


Re: Merged r183086 and r183143 from branches/google/gcc-4_6 into branches/google/gcc-4_6-mobile (issue 5541046)

2012-01-12 Thread asharif

Please take a look.

http://codereview.appspot.com/5541046/


Re: [PATCH] Add check before potentially dividing by 0

2011-03-15 Thread asharif
I have seen an ICE in 4.4.3 when a corrupted profile file causes a
division by 0 in gcc. This is the equivalent code in trunk and this
check should help fix it.
Thoughts?

2011-03-15  Ahmad Sharif  

       * predict.c (probably_never_executed_bb_p): Add check to see
       whether profile_info->runs is equal to 0 before doing the division.
Index: predict.c
===
--- predict.c (revision 171019)
+++ predict.c (working copy)
@@ -200,7 +200,7 @@
 bool
 probably_never_executed_bb_p (const_basic_block bb)
 {
-  if (profile_info && flag_branch_probabilities)
+  if (profile_info && flag_branch_probabilities && profile_info->runs != 0)
     return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0;
   if ((!profile_info || !flag_branch_probabilities)
       && cgraph_node (current_function_decl)->frequency ==
NODE_FREQUENCY_UNLIKELY_EXECUTED)