public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* GGC, GTY: Tighten up a few things re 'reorder' option and strings
@ 2023-07-05 16:14 Thomas Schwinge
  2023-07-06  6:04 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Schwinge @ 2023-07-05 16:14 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

Hi!

OK to push the attached
"GGC, GTY: Tighten up a few things re 'reorder' option and strings"?


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-GGC-GTY-Tighten-up-a-few-things-re-reorder-option-an.patch --]
[-- Type: text/x-diff, Size: 2758 bytes --]

From 8751deeb7afdc8ece6a0645c8404f615144b1bd4 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 5 Jul 2023 15:34:56 +0200
Subject: [PATCH] GGC, GTY: Tighten up a few things re 'reorder' option and
 strings

..., 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 | 18 ++++++++++++++----
 gcc/stringpool.cc |  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/ggc-common.cc b/gcc/ggc-common.cc
index 173ab64cb73..bed7a9d4d02 100644
--- a/gcc/ggc-common.cc
+++ b/gcc/ggc-common.cc
@@ -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))
diff --git a/gcc/stringpool.cc b/gcc/stringpool.cc
index 46aff39d7d5..8658e6ab52a 100644
--- a/gcc/stringpool.cc
+++ b/gcc/stringpool.cc
@@ -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.  */
-- 
2.34.1


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

* Re: GGC, GTY: Tighten up a few things re 'reorder' option and strings
  2023-07-05 16:14 GGC, GTY: Tighten up a few things re 'reorder' option and strings Thomas Schwinge
@ 2023-07-06  6:04 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-07-06  6:04 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches

On Wed, Jul 5, 2023 at 6:16 PM Thomas Schwinge <thomas@codesourcery.com> wrote:
>
> Hi!
>
> OK to push the attached
> "GGC, GTY: Tighten up a few things re 'reorder' option and strings"?

OK.

>
> Grüße
>  Thomas
>
>
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

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

end of thread, other threads:[~2023-07-06  6:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 16:14 GGC, GTY: Tighten up a few things re 'reorder' option and strings Thomas Schwinge
2023-07-06  6:04 ` Richard Biener

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).