[1/4] rtl-ssa: Fix null deref in first_any_insn_use

Message ID 20231024103000.3334790-2-richard.sandiford@arm.com
State Accepted
Headers
Series [1/4] rtl-ssa: Fix null deref in first_any_insn_use |

Checks

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

Commit Message

Richard Sandiford Oct. 24, 2023, 10:29 a.m. UTC
  first_any_insn_use implicitly (but contrary to its documentation)
assumed that there was at least one use.

gcc/
	* rtl-ssa/member-fns.inl (first_any_insn_use): Handle null
	m_first_use.
---
 gcc/rtl-ssa/member-fns.inl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/gcc/rtl-ssa/member-fns.inl b/gcc/rtl-ssa/member-fns.inl
index c127fab8b98..3fdca14e0ef 100644
--- a/gcc/rtl-ssa/member-fns.inl
+++ b/gcc/rtl-ssa/member-fns.inl
@@ -215,7 +215,7 @@  set_info::last_nondebug_insn_use () const
 inline use_info *
 set_info::first_any_insn_use () const
 {
-  if (m_first_use->is_in_any_insn ())
+  if (m_first_use && m_first_use->is_in_any_insn ())
     return m_first_use;
   return nullptr;
 }