[02/13] varpool: do not add NULL vnodes to referenced

Message ID orwn6dfpia.fsf@lxoliva.fsfla.org
State Accepted
Headers
Series [01/13] scoped tables: insert before further lookups |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Alexandre Oliva Dec. 27, 2022, 4:18 a.m. UTC
  Avoid adding NULL vnodes to referenced tables.

Regstrapped on x86_64-linux-gnu.  Ok to install?


for  gcc/ChangeLog

	* varpool.c (symbol_table::remove_unreferenced_decls): Do not
	add NULL vnodes to referenced table.
---
 gcc/varpool.cc |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Jeff Law Dec. 27, 2022, 3:14 p.m. UTC | #1
On 12/26/22 21:18, Alexandre Oliva via Gcc-patches wrote:
> 
> Avoid adding NULL vnodes to referenced tables.
> 
> Regstrapped on x86_64-linux-gnu.  Ok to install?
> 
> 
> for  gcc/ChangeLog
> 
> 	* varpool.c (symbol_table::remove_unreferenced_decls): Do not
> 	add NULL vnodes to referenced table.
OK
jeff
  

Patch

diff --git a/gcc/varpool.cc b/gcc/varpool.cc
index bfd17f1250cc0..ccbd6e50f4b01 100644
--- a/gcc/varpool.cc
+++ b/gcc/varpool.cc
@@ -680,10 +680,12 @@  symbol_table::remove_unreferenced_decls (void)
 	    enqueue_node (vnode, &first);
 	  else
 	    {
-	      referenced.add (vnode);
+	      if (vnode)
+		referenced.add (vnode);
 	      while (vnode && vnode->alias && vnode->definition)
 		{
 		  vnode = vnode->get_alias_target ();
+		  gcc_checking_assert (vnode);
 	          referenced.add (vnode);
 		}
 	    }