public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR108330-ipa-hash-checking)] hash: do not insert deleted value to a hash_set
@ 2023-01-09  9:04 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2023-01-09  9:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6c37b3ddf4d7ba07c5b5ae20f22ec1663eecec4f

commit 6c37b3ddf4d7ba07c5b5ae20f22ec1663eecec4f
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jan 9 09:51:01 2023 +0100

    hash: do not insert deleted value to a hash_set
    
            PR lto/108330
    
    gcc/ChangeLog:
    
            * lto-cgraph.cc (compute_ltrans_boundary): Do not insert
            NULL (deleleted value) to a hash_set.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/ipa/pr108830.C: New test.

Diff:
---
 gcc/lto-cgraph.cc                   |  3 ++-
 gcc/testsuite/g++.dg/ipa/pr108830.C | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc
index eef5ea1d061..805c7855eb3 100644
--- a/gcc/lto-cgraph.cc
+++ b/gcc/lto-cgraph.cc
@@ -918,7 +918,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
 	      vec <cgraph_node *>targets
 		= possible_polymorphic_call_targets
 		    (edge, &final, &cache_token);
-	      if (!reachable_call_targets.add (cache_token))
+	      if (cache_token != NULL
+		  && !reachable_call_targets.add (cache_token))
 		{
 		  for (i = 0; i < targets.length (); i++)
 		    {
diff --git a/gcc/testsuite/g++.dg/ipa/pr108830.C b/gcc/testsuite/g++.dg/ipa/pr108830.C
new file mode 100644
index 00000000000..96656f67e4f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr108830.C
@@ -0,0 +1,20 @@
+// PR lto/108330
+// { dg-do compile }
+
+class A {
+      virtual unsigned long m_fn1() const;
+        virtual int &m_fn2(unsigned long) const;
+};
+class C : A {
+public:
+      int &m_fn2(unsigned long) const;
+        unsigned long m_fn1() const;
+};
+class B {
+      void m_fn3(const A &, const int &, const C &, int &) const;
+};
+void B::m_fn3(const A &, const int &, const C &, int &) const {
+      C &a(a);
+        for (long b = 0; a.m_fn1(); b++)
+	      a.m_fn2(0);
+}

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

* [gcc(refs/users/marxin/heads/PR108330-ipa-hash-checking)] hash: do not insert deleted value to a hash_set
@ 2023-01-09  8:57 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2023-01-09  8:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:29d7f7735240509d2d2a34961a9f2d5ba3debbbc

commit 29d7f7735240509d2d2a34961a9f2d5ba3debbbc
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jan 9 09:51:01 2023 +0100

    hash: do not insert deleted value to a hash_set
    
            PR lto/108330
    
    gcc/ChangeLog:
    
            * lto-cgraph.cc (compute_ltrans_boundary): Do not insert
            NULL (deleleted value) to a hash_set.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/lto/pr108330_0.C: New test.

Diff:
---
 gcc/lto-cgraph.cc                     |  3 ++-
 gcc/testsuite/g++.dg/lto/pr108330_0.C | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc
index eef5ea1d061..805c7855eb3 100644
--- a/gcc/lto-cgraph.cc
+++ b/gcc/lto-cgraph.cc
@@ -918,7 +918,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
 	      vec <cgraph_node *>targets
 		= possible_polymorphic_call_targets
 		    (edge, &final, &cache_token);
-	      if (!reachable_call_targets.add (cache_token))
+	      if (cache_token != NULL
+		  && !reachable_call_targets.add (cache_token))
 		{
 		  for (i = 0; i < targets.length (); i++)
 		    {
diff --git a/gcc/testsuite/g++.dg/lto/pr108330_0.C b/gcc/testsuite/g++.dg/lto/pr108330_0.C
new file mode 100644
index 00000000000..96656f67e4f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr108330_0.C
@@ -0,0 +1,20 @@
+// PR lto/108330
+// { dg-do compile }
+
+class A {
+      virtual unsigned long m_fn1() const;
+        virtual int &m_fn2(unsigned long) const;
+};
+class C : A {
+public:
+      int &m_fn2(unsigned long) const;
+        unsigned long m_fn1() const;
+};
+class B {
+      void m_fn3(const A &, const int &, const C &, int &) const;
+};
+void B::m_fn3(const A &, const int &, const C &, int &) const {
+      C &a(a);
+        for (long b = 0; a.m_fn1(); b++)
+	      a.m_fn2(0);
+}

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

end of thread, other threads:[~2023-01-09  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09  9:04 [gcc(refs/users/marxin/heads/PR108330-ipa-hash-checking)] hash: do not insert deleted value to a hash_set Martin Liska
  -- strict thread matches above, loose matches on Subject: below --
2023-01-09  8:57 Martin Liska

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