https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68758

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> Is your gcc configured with --enable-valgrind-annotations ?

Hello Jakub.

So the problem is that even though the configure option was passed to
configure, valgrind discard magic is done just in case
ENABLE_VALGRIND_CHECKING, as added in:
https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00044.html

I would consider it better to guard the valgrind code in case
ENABLE_VALGRIND_ANNOTATIONS:

diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index c919ba8..9b291aa 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -492,7 +492,7 @@ gt_pch_save (FILE *f)

   ggc_pch_prepare_write (state.d, state.f);

-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
   vec<char> vbits = vNULL;
 #endif

@@ -504,7 +504,7 @@ gt_pch_save (FILE *f)
          this_object_size = state.ptrs[i]->size;
          this_object = XRESIZEVAR (char, this_object, this_object_size);
        }
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
       /* obj might contain uninitialized bytes, e.g. in the trailing
         padding of the object.  Avoid warnings by making the memory
         temporarily defined and then restoring previous state.  */
@@ -561,7 +561,7 @@ gt_pch_save (FILE *f)
                            state.ptrs[i]->note_ptr_fn == gt_pch_p_S);
       if (state.ptrs[i]->note_ptr_fn != gt_pch_p_S)
        memcpy (state.ptrs[i]->obj, this_object, state.ptrs[i]->size);
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
       if (__builtin_expect (get_vbits == 1, 0))
        {
          (void) VALGRIND_SET_VBITS (state.ptrs[i]->obj, vbits.address (),
@@ -575,7 +575,7 @@ gt_pch_save (FILE *f)
        }
 #endif
     }
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
   vbits.release ();
 #endif


Using the patch, the issue has gone.
What do you think about it?

Martin

Reply via email to