]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
GGC, GTY: Tighten up a few things re 'reorder' option and strings
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 5 Jul 2023 13:34:56 +0000 (15:34 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 6 Jul 2023 09:59:08 +0000 (11:59 +0200)
..., which doesn't make sense in combination.

This, again, is primarily preparational for another change.

gcc/
* ggc-common.cc (gt_pch_note_reorder, gt_pch_save): Tighten up a
few things re 'reorder' option and strings.
* stringpool.cc (gt_pch_p_S): This is now 'gcc_unreachable'.

gcc/ggc-common.cc
gcc/stringpool.cc

index 173ab64cb73a7a2598e13d01ffb322e13ffc6381..bed7a9d4d021301f1592f15a6b63e104ff8e5c6d 100644 (file)
@@ -314,6 +314,9 @@ gt_pch_note_reorder (void *obj, void *note_ptr_cookie,
   data = (struct ptr_data *)
     saving_htab->find_with_hash (obj, POINTER_HASH (obj));
   gcc_assert (data && data->note_ptr_cookie == note_ptr_cookie);
+  /* The GTY 'reorder' option doesn't make sense if we don't walk pointers,
+     such as for strings.  */
+  gcc_checking_assert (data->note_ptr_fn != gt_pch_p_S);
 
   data->reorder_fn = reorder_fn;
 }
@@ -636,12 +639,19 @@ gt_pch_save (FILE *f)
        state.ptrs[i]->reorder_fn (state.ptrs[i]->obj,
                                   state.ptrs[i]->note_ptr_cookie,
                                   relocate_ptrs, &state);
-      state.ptrs[i]->note_ptr_fn (state.ptrs[i]->obj,
-                                 state.ptrs[i]->note_ptr_cookie,
-                                 relocate_ptrs, &state);
+      gt_note_pointers note_ptr_fn = state.ptrs[i]->note_ptr_fn;
+      gcc_checking_assert (note_ptr_fn != NULL);
+      /* 'gt_pch_p_S' enables certain special handling, but otherwise
+     corresponds to no 'note_ptr_fn'.  */
+      if (note_ptr_fn == gt_pch_p_S)
+       note_ptr_fn = NULL;
+      if (note_ptr_fn != NULL)
+       note_ptr_fn (state.ptrs[i]->obj, state.ptrs[i]->note_ptr_cookie,
+                    relocate_ptrs, &state);
       ggc_pch_write_object (state.d, state.f, state.ptrs[i]->obj,
                            state.ptrs[i]->new_addr, state.ptrs[i]->size);
-      if (state.ptrs[i]->note_ptr_fn != gt_pch_p_S)
+      if (state.ptrs[i]->reorder_fn != NULL
+         || note_ptr_fn != NULL)
        memcpy (state.ptrs[i]->obj, this_object, state.ptrs[i]->size);
 #if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
       if (UNLIKELY (get_vbits == 1))
index 46aff39d7d51c306ade62dc75b22fe806cd9a3e0..8658e6ab52a9260cb5208c895b7bd0fe87a7c373 100644 (file)
@@ -185,6 +185,7 @@ gt_pch_p_S (void *obj ATTRIBUTE_UNUSED, void *x ATTRIBUTE_UNUSED,
            gt_pointer_operator op ATTRIBUTE_UNUSED,
            void *cookie ATTRIBUTE_UNUSED)
 {
+  gcc_unreachable ();
 }
 
 /* PCH pointer-walking routine for strings.  */