public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add --enable-valgrind-annotations
@ 2014-03-18 13:55 Richard Biener
  2014-04-28 13:54 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2014-03-18 13:55 UTC (permalink / raw)
  To: gcc-patches


This is another patch (well, I've polished it a bit) that was sitting
in my local tree for some time.  I've not enabled the ggc-common.c
code (I merely want to get rid of the false possitives).

Queued for 4.10 unless I'm told otherwise.

Richard.

2014-03-18  Richard Biener  <rguenther@suse.de>

	* configure.ac: Do valgrind header checks unconditionally.
	Add --enable-valgrind-annotations.
	* system.h: Guard valgrind header inclusion with
	ENABLE_VALGRIND_ANNOTATIONS instead of ENABLE_VALGRIND_CHECKING.
	* alloc-pool.c (pool_alloc, pool_free): Use
	ENABLE_VALGRIND_ANNOTATIONS instead of ENABLE_VALGRIND_CHECKING
	to guard possibly dead code.
	* config.in: Regenerated.
	* configure: Likewise.

Index: gcc/configure.ac
===================================================================
*** gcc/configure.ac	(revision 208642)
--- gcc/configure.ac	(working copy)
*************** dnl # an if statement.  This was the sou
*** 512,538 ****
  dnl # in converting to autoconf 2.5x!
  AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
  
! if test x$ac_valgrind_checking != x ; then
!   # It is certainly possible that there's valgrind but no valgrind.h.
!   # GCC relies on making annotations so we must have both.
!   AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
!   AC_PREPROC_IFELSE([AC_LANG_SOURCE(
!     [[#include <valgrind/memcheck.h>
  #ifndef VALGRIND_DISCARD
  #error VALGRIND_DISCARD not defined
  #endif]])],
    [gcc_cv_header_valgrind_memcheck_h=yes],
    [gcc_cv_header_valgrind_memcheck_h=no])
!   AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
!   AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
!   AC_PREPROC_IFELSE([AC_LANG_SOURCE(
!     [[#include <memcheck.h>
  #ifndef VALGRIND_DISCARD
  #error VALGRIND_DISCARD not defined
  #endif]])],
    [gcc_cv_header_memcheck_h=yes],
    [gcc_cv_header_memcheck_h=no])
!   AC_MSG_RESULT($gcc_cv_header_memcheck_h)
    AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
  	[$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
    if test "x$valgrind_path" = "x" \
--- 512,547 ----
  dnl # in converting to autoconf 2.5x!
  AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
  
! # It is certainly possible that there's valgrind but no valgrind.h.
! # GCC relies on making annotations so we must have both.
! AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
! AC_PREPROC_IFELSE([AC_LANG_SOURCE(
!   [[#include <valgrind/memcheck.h>
  #ifndef VALGRIND_DISCARD
  #error VALGRIND_DISCARD not defined
  #endif]])],
    [gcc_cv_header_valgrind_memcheck_h=yes],
    [gcc_cv_header_valgrind_memcheck_h=no])
! AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
! AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
! AC_PREPROC_IFELSE([AC_LANG_SOURCE(
!   [[#include <memcheck.h>
  #ifndef VALGRIND_DISCARD
  #error VALGRIND_DISCARD not defined
  #endif]])],
    [gcc_cv_header_memcheck_h=yes],
    [gcc_cv_header_memcheck_h=no])
! AC_MSG_RESULT($gcc_cv_header_memcheck_h)
! if test $gcc_cv_header_valgrind_memcheck_h = yes; then
!   AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
! 	[Define if valgrind's valgrind/memcheck.h header is installed.])
! fi
! if test $gcc_cv_header_memcheck_h = yes; then
!   AC_DEFINE(HAVE_MEMCHECK_H, 1,
! 	[Define if valgrind's memcheck.h header is installed.])
! fi
! 
! if test x$ac_valgrind_checking != x ; then
    AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
  	[$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
    if test "x$valgrind_path" = "x" \
*************** if test x$ac_valgrind_checking != x ; th
*** 546,559 ****
    AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
  [Define if you want to run subprograms and generated programs
     through valgrind (a memory checker).  This is extremely expensive.])
-   if test $gcc_cv_header_valgrind_memcheck_h = yes; then
-     AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
- 	[Define if valgrind's valgrind/memcheck.h header is installed.])
-   fi
-   if test $gcc_cv_header_memcheck_h = yes; then
-     AC_DEFINE(HAVE_MEMCHECK_H, 1,
- 	[Define if valgrind's memcheck.h header is installed.])
-   fi
  fi
  AC_SUBST(valgrind_path_defines)
  AC_SUBST(valgrind_command)
--- 555,560 ----
*************** gather_stats=`if test $enable_gather_det
*** 592,597 ****
--- 593,613 ----
  AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
  [Define to enable detailed memory allocation stats gathering.])
  
+ AC_ARG_ENABLE(valgrind-annotations,
+ [AS_HELP_STRING([--enable-valgrind-annotations],
+ 		[enable valgrind runtime interaction])], [],
+ [enable_valgrind_annotations=no])
+ if test x$enable_valgrind_annotations != xno \
+     || test x$ac_valgrind_checking != x; then
+   if (test $have_valgrind_h = no \
+       && test $gcc_cv_header_memcheck_h = no \
+       && test $gcc_cv_header_valgrind_memcheck_h = no); then
+     AC_MSG_ERROR([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
+   fi
+   AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
+ [Define to get calls to the valgrind runtime enabled.])
+ fi
+ 
  # -------------------------------
  # Miscenalleous configure options
  # -------------------------------
Index: gcc/system.h
===================================================================
*** gcc/system.h	(revision 208642)
--- gcc/system.h	(working copy)
*************** helper_const_non_const_cast (const char
*** 1025,1031 ****
  #endif
  #endif
  
! #ifdef ENABLE_VALGRIND_CHECKING
  # ifdef HAVE_VALGRIND_MEMCHECK_H
  #  include <valgrind/memcheck.h>
  # elif defined HAVE_MEMCHECK_H
--- 1025,1031 ----
  #endif
  #endif
  
! #ifdef ENABLE_VALGRIND_ANNOTATIONS
  # ifdef HAVE_VALGRIND_MEMCHECK_H
  #  include <valgrind/memcheck.h>
  # elif defined HAVE_MEMCHECK_H
Index: gcc/alloc-pool.c
===================================================================
*** gcc/alloc-pool.c	(revision 208642)
--- gcc/alloc-pool.c	(working copy)
*************** void *
*** 250,256 ****
  pool_alloc (alloc_pool pool)
  {
    alloc_pool_list header;
! #ifdef ENABLE_VALGRIND_CHECKING
    int size;
  #endif
  
--- 250,256 ----
  pool_alloc (alloc_pool pool)
  {
    alloc_pool_list header;
! #ifdef ENABLE_VALGRIND_ANNOTATIONS
    int size;
  #endif
  
*************** pool_alloc (alloc_pool pool)
*** 265,271 ****
      }
  
    gcc_checking_assert (pool);
! #ifdef ENABLE_VALGRIND_CHECKING
    size = pool->elt_size - offsetof (allocation_object, u.data);
  #endif
  
--- 265,271 ----
      }
  
    gcc_checking_assert (pool);
! #ifdef ENABLE_VALGRIND_ANNOTATIONS
    size = pool->elt_size - offsetof (allocation_object, u.data);
  #endif
  
*************** void
*** 334,340 ****
  pool_free (alloc_pool pool, void *ptr)
  {
    alloc_pool_list header;
! #if defined(ENABLE_VALGRIND_CHECKING) || defined(ENABLE_CHECKING)
    int size;
    size = pool->elt_size - offsetof (allocation_object, u.data);
  #endif
--- 334,340 ----
  pool_free (alloc_pool pool, void *ptr)
  {
    alloc_pool_list header;
! #if defined(ENABLE_VALGRIND_ANNOTATIONS) || defined(ENABLE_CHECKING)
    int size;
    size = pool->elt_size - offsetof (allocation_object, u.data);
  #endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add --enable-valgrind-annotations
  2014-03-18 13:55 [PATCH] Add --enable-valgrind-annotations Richard Biener
@ 2014-04-28 13:54 ` Richard Biener
  2014-04-28 14:15   ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2014-04-28 13:54 UTC (permalink / raw)
  To: Richard Biener, Jakub Jelinek; +Cc: GCC Patches

On Tue, Mar 18, 2014 at 2:51 PM, Richard Biener <rguenther@suse.de> wrote:
>
> This is another patch (well, I've polished it a bit) that was sitting
> in my local tree for some time.  I've not enabled the ggc-common.c
> code (I merely want to get rid of the false possitives).
>
> Queued for 4.10 unless I'm told otherwise.

There were no comments sofar - thus, ok for trunk?

Thanks,
Richard.

> Richard.
>
> 2014-03-18  Richard Biener  <rguenther@suse.de>
>
>         * configure.ac: Do valgrind header checks unconditionally.
>         Add --enable-valgrind-annotations.
>         * system.h: Guard valgrind header inclusion with
>         ENABLE_VALGRIND_ANNOTATIONS instead of ENABLE_VALGRIND_CHECKING.
>         * alloc-pool.c (pool_alloc, pool_free): Use
>         ENABLE_VALGRIND_ANNOTATIONS instead of ENABLE_VALGRIND_CHECKING
>         to guard possibly dead code.
>         * config.in: Regenerated.
>         * configure: Likewise.
>
> Index: gcc/configure.ac
> ===================================================================
> *** gcc/configure.ac    (revision 208642)
> --- gcc/configure.ac    (working copy)
> *************** dnl # an if statement.  This was the sou
> *** 512,538 ****
>   dnl # in converting to autoconf 2.5x!
>   AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
>
> ! if test x$ac_valgrind_checking != x ; then
> !   # It is certainly possible that there's valgrind but no valgrind.h.
> !   # GCC relies on making annotations so we must have both.
> !   AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
> !   AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> !     [[#include <valgrind/memcheck.h>
>   #ifndef VALGRIND_DISCARD
>   #error VALGRIND_DISCARD not defined
>   #endif]])],
>     [gcc_cv_header_valgrind_memcheck_h=yes],
>     [gcc_cv_header_valgrind_memcheck_h=no])
> !   AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
> !   AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
> !   AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> !     [[#include <memcheck.h>
>   #ifndef VALGRIND_DISCARD
>   #error VALGRIND_DISCARD not defined
>   #endif]])],
>     [gcc_cv_header_memcheck_h=yes],
>     [gcc_cv_header_memcheck_h=no])
> !   AC_MSG_RESULT($gcc_cv_header_memcheck_h)
>     AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
>         [$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
>     if test "x$valgrind_path" = "x" \
> --- 512,547 ----
>   dnl # in converting to autoconf 2.5x!
>   AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
>
> ! # It is certainly possible that there's valgrind but no valgrind.h.
> ! # GCC relies on making annotations so we must have both.
> ! AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>)
> ! AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> !   [[#include <valgrind/memcheck.h>
>   #ifndef VALGRIND_DISCARD
>   #error VALGRIND_DISCARD not defined
>   #endif]])],
>     [gcc_cv_header_valgrind_memcheck_h=yes],
>     [gcc_cv_header_valgrind_memcheck_h=no])
> ! AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h)
> ! AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>)
> ! AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> !   [[#include <memcheck.h>
>   #ifndef VALGRIND_DISCARD
>   #error VALGRIND_DISCARD not defined
>   #endif]])],
>     [gcc_cv_header_memcheck_h=yes],
>     [gcc_cv_header_memcheck_h=no])
> ! AC_MSG_RESULT($gcc_cv_header_memcheck_h)
> ! if test $gcc_cv_header_valgrind_memcheck_h = yes; then
> !   AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
> !       [Define if valgrind's valgrind/memcheck.h header is installed.])
> ! fi
> ! if test $gcc_cv_header_memcheck_h = yes; then
> !   AC_DEFINE(HAVE_MEMCHECK_H, 1,
> !       [Define if valgrind's memcheck.h header is installed.])
> ! fi
> !
> ! if test x$ac_valgrind_checking != x ; then
>     AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
>         [$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
>     if test "x$valgrind_path" = "x" \
> *************** if test x$ac_valgrind_checking != x ; th
> *** 546,559 ****
>     AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
>   [Define if you want to run subprograms and generated programs
>      through valgrind (a memory checker).  This is extremely expensive.])
> -   if test $gcc_cv_header_valgrind_memcheck_h = yes; then
> -     AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
> -       [Define if valgrind's valgrind/memcheck.h header is installed.])
> -   fi
> -   if test $gcc_cv_header_memcheck_h = yes; then
> -     AC_DEFINE(HAVE_MEMCHECK_H, 1,
> -       [Define if valgrind's memcheck.h header is installed.])
> -   fi
>   fi
>   AC_SUBST(valgrind_path_defines)
>   AC_SUBST(valgrind_command)
> --- 555,560 ----
> *************** gather_stats=`if test $enable_gather_det
> *** 592,597 ****
> --- 593,613 ----
>   AC_DEFINE_UNQUOTED(GATHER_STATISTICS, $gather_stats,
>   [Define to enable detailed memory allocation stats gathering.])
>
> + AC_ARG_ENABLE(valgrind-annotations,
> + [AS_HELP_STRING([--enable-valgrind-annotations],
> +               [enable valgrind runtime interaction])], [],
> + [enable_valgrind_annotations=no])
> + if test x$enable_valgrind_annotations != xno \
> +     || test x$ac_valgrind_checking != x; then
> +   if (test $have_valgrind_h = no \
> +       && test $gcc_cv_header_memcheck_h = no \
> +       && test $gcc_cv_header_valgrind_memcheck_h = no); then
> +     AC_MSG_ERROR([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
> +   fi
> +   AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
> + [Define to get calls to the valgrind runtime enabled.])
> + fi
> +
>   # -------------------------------
>   # Miscenalleous configure options
>   # -------------------------------
> Index: gcc/system.h
> ===================================================================
> *** gcc/system.h        (revision 208642)
> --- gcc/system.h        (working copy)
> *************** helper_const_non_const_cast (const char
> *** 1025,1031 ****
>   #endif
>   #endif
>
> ! #ifdef ENABLE_VALGRIND_CHECKING
>   # ifdef HAVE_VALGRIND_MEMCHECK_H
>   #  include <valgrind/memcheck.h>
>   # elif defined HAVE_MEMCHECK_H
> --- 1025,1031 ----
>   #endif
>   #endif
>
> ! #ifdef ENABLE_VALGRIND_ANNOTATIONS
>   # ifdef HAVE_VALGRIND_MEMCHECK_H
>   #  include <valgrind/memcheck.h>
>   # elif defined HAVE_MEMCHECK_H
> Index: gcc/alloc-pool.c
> ===================================================================
> *** gcc/alloc-pool.c    (revision 208642)
> --- gcc/alloc-pool.c    (working copy)
> *************** void *
> *** 250,256 ****
>   pool_alloc (alloc_pool pool)
>   {
>     alloc_pool_list header;
> ! #ifdef ENABLE_VALGRIND_CHECKING
>     int size;
>   #endif
>
> --- 250,256 ----
>   pool_alloc (alloc_pool pool)
>   {
>     alloc_pool_list header;
> ! #ifdef ENABLE_VALGRIND_ANNOTATIONS
>     int size;
>   #endif
>
> *************** pool_alloc (alloc_pool pool)
> *** 265,271 ****
>       }
>
>     gcc_checking_assert (pool);
> ! #ifdef ENABLE_VALGRIND_CHECKING
>     size = pool->elt_size - offsetof (allocation_object, u.data);
>   #endif
>
> --- 265,271 ----
>       }
>
>     gcc_checking_assert (pool);
> ! #ifdef ENABLE_VALGRIND_ANNOTATIONS
>     size = pool->elt_size - offsetof (allocation_object, u.data);
>   #endif
>
> *************** void
> *** 334,340 ****
>   pool_free (alloc_pool pool, void *ptr)
>   {
>     alloc_pool_list header;
> ! #if defined(ENABLE_VALGRIND_CHECKING) || defined(ENABLE_CHECKING)
>     int size;
>     size = pool->elt_size - offsetof (allocation_object, u.data);
>   #endif
> --- 334,340 ----
>   pool_free (alloc_pool pool, void *ptr)
>   {
>     alloc_pool_list header;
> ! #if defined(ENABLE_VALGRIND_ANNOTATIONS) || defined(ENABLE_CHECKING)
>     int size;
>     size = pool->elt_size - offsetof (allocation_object, u.data);
>   #endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add --enable-valgrind-annotations
  2014-04-28 13:54 ` Richard Biener
@ 2014-04-28 14:15   ` Jakub Jelinek
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2014-04-28 14:15 UTC (permalink / raw)
  To: Richard Biener; +Cc: Richard Biener, GCC Patches

On Mon, Apr 28, 2014 at 03:47:17PM +0200, Richard Biener wrote:
> On Tue, Mar 18, 2014 at 2:51 PM, Richard Biener <rguenther@suse.de> wrote:
> >
> > This is another patch (well, I've polished it a bit) that was sitting
> > in my local tree for some time.  I've not enabled the ggc-common.c
> > code (I merely want to get rid of the false possitives).
> >
> > Queued for 4.10 unless I'm told otherwise.
> 
> There were no comments sofar - thus, ok for trunk?

Ok.
> > 2014-03-18  Richard Biener  <rguenther@suse.de>
> >
> >         * configure.ac: Do valgrind header checks unconditionally.
> >         Add --enable-valgrind-annotations.
> >         * system.h: Guard valgrind header inclusion with
> >         ENABLE_VALGRIND_ANNOTATIONS instead of ENABLE_VALGRIND_CHECKING.
> >         * alloc-pool.c (pool_alloc, pool_free): Use
> >         ENABLE_VALGRIND_ANNOTATIONS instead of ENABLE_VALGRIND_CHECKING
> >         to guard possibly dead code.
> >         * config.in: Regenerated.
> >         * configure: Likewise.

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-28 13:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-18 13:55 [PATCH] Add --enable-valgrind-annotations Richard Biener
2014-04-28 13:54 ` Richard Biener
2014-04-28 14:15   ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).