public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] IPA ICF: make type cache a static field sem_item.
@ 2018-08-31 10:49 Martin Liška
  2018-08-31 11:32 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2018-08-31 10:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Florian Rommel

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

Hi.

As noticed here:
https://gcc.gnu.org/ml/gcc/2018-08/msg00004.html

There's ugly usage of a static variable in sem_item_optimizer
that's called from sem_item.

I believe logically the hash should live in sem_item.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Martin


gcc/ChangeLog:

2018-08-29  Martin Liska  <mliska@suse.cz>

	* ipa-icf.c (sem_item::add_type): Use
	sem_item::m_type_hash_cache.
	* ipa-icf.h: Move the cache from sem_item_optimizer
	to sem_item.
---
 gcc/ipa-icf.c | 6 ++++--
 gcc/ipa-icf.h | 6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)



[-- Attachment #2: 0001-IPA-ICF-make-type-cache-a-static-field-sem_item.patch --]
[-- Type: text/x-patch, Size: 1860 bytes --]

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 39b96ba13be..8a6a7a3f32f 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -227,6 +227,8 @@ void sem_item::set_hash (hashval_t hash)
   m_hash_set = true;
 }
 
+hash_map<const_tree, hashval_t> sem_item::m_type_hash_cache;
+
 /* Semantic function constructor that uses STACK as bitmap memory stack.  */
 
 sem_function::sem_function (bitmap_obstack *stack)
@@ -1587,7 +1589,7 @@ sem_item::add_type (const_tree type, inchash::hash &hstate)
 	  return;
 	}
 
-      hashval_t *val = optimizer->m_type_hash_cache.get (type);
+      hashval_t *val = m_type_hash_cache.get (type);
 
       if (!val)
 	{
@@ -1607,7 +1609,7 @@ sem_item::add_type (const_tree type, inchash::hash &hstate)
 	  hstate2.add_int (nf);
 	  hash = hstate2.end ();
 	  hstate.add_hwi (hash);
-	  optimizer->m_type_hash_cache.put (type, hash);
+	  m_type_hash_cache.put (type, hash);
 	}
       else
         hstate.add_hwi (*val);
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index 622aebc00c0..a64b3852efb 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -281,6 +281,9 @@ private:
   /* Initialize internal data structures. Bitmap STACK is used for
      bitmap memory allocation process.  */
   void setup (bitmap_obstack *stack);
+
+  /* Because types can be arbitrarily large, avoid quadratic bottleneck.  */
+  static hash_map<const_tree, hashval_t> m_type_hash_cache;
 }; // class sem_item
 
 class sem_function: public sem_item
@@ -524,9 +527,6 @@ public:
   /* Gets a congruence class group based on given HASH value and TYPE.  */
   congruence_class_group *get_group_by_hash (hashval_t hash,
       sem_item_type type);
-
-  /* Because types can be arbitrarily large, avoid quadratic bottleneck.  */
-  hash_map<const_tree, hashval_t> m_type_hash_cache;
 private:
 
   /* For each semantic item, append hash values of references.  */


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

* Re: [PATCH] IPA ICF: make type cache a static field sem_item.
  2018-08-31 10:49 [PATCH] IPA ICF: make type cache a static field sem_item Martin Liška
@ 2018-08-31 11:32 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-08-31 11:32 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches, flo

On Fri, Aug 31, 2018 at 12:49 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> As noticed here:
> https://gcc.gnu.org/ml/gcc/2018-08/msg00004.html
>
> There's ugly usage of a static variable in sem_item_optimizer
> that's called from sem_item.
>
> I believe logically the hash should live in sem_item.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?

OK.

> Martin
>
>
> gcc/ChangeLog:
>
> 2018-08-29  Martin Liska  <mliska@suse.cz>
>
>         * ipa-icf.c (sem_item::add_type): Use
>         sem_item::m_type_hash_cache.
>         * ipa-icf.h: Move the cache from sem_item_optimizer
>         to sem_item.
> ---
>  gcc/ipa-icf.c | 6 ++++--
>  gcc/ipa-icf.h | 6 +++---
>  2 files changed, 7 insertions(+), 5 deletions(-)
>
>

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

end of thread, other threads:[~2018-08-31 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 10:49 [PATCH] IPA ICF: make type cache a static field sem_item Martin Liška
2018-08-31 11:32 ` 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).