public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] Return NULL from gimple_call_return_type if no return available.
@ 2021-06-23 15:03 Aldy Hernandez
  2021-06-23 18:37 ` Richard Biener
  0 siblings, 1 reply; 15+ messages in thread
From: Aldy Hernandez @ 2021-06-23 15:03 UTC (permalink / raw)
  To: GCC patches

The call to gimple_call_fntype() in gimple_call_return_type() may return
NULL, which causes the TREE_TYPE(lhs) to ICE.  I think it would be best to
return NULL (or void_type_node) rather than aborting.

I'm running into this because fold_using_range::range_of_call, calls
gimple_call_return_type which may ICE for builtins with no LHS.  Instead
of special casing things in range_of_call, perhaps it's best to plug the
source.

Does this sound reasonable?

gcc/ChangeLog:

	* gimple.h (gimple_call_return_type): Return NULL when no type
	and no lhs is available.
---
 gcc/gimple.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index e7dc2a45a13..2a01fe631ec 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3182,7 +3182,10 @@ gimple_call_return_type (const gcall *gs)
   tree type = gimple_call_fntype (gs);
 
   if (type == NULL_TREE)
-    return TREE_TYPE (gimple_call_lhs (gs));
+    {
+      tree lhs = gimple_call_lhs (gs);
+      return lhs ? TREE_TYPE (lhs) : NULL_TREE;
+    }
 
   /* The type returned by a function is the type of its
      function type.  */
-- 
2.31.1


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

end of thread, other threads:[~2021-07-16  7:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 15:03 [RFC] Return NULL from gimple_call_return_type if no return available Aldy Hernandez
2021-06-23 18:37 ` Richard Biener
2021-06-23 19:25   ` Andrew MacLeod
2021-06-24  9:07     ` Richard Biener
2021-06-24 13:31       ` Andrew MacLeod
2021-06-24 13:45         ` Jakub Jelinek
2021-06-24 13:55           ` Andrew MacLeod
2021-07-15 11:05             ` Aldy Hernandez
2021-07-15 13:06               ` Richard Biener
2021-07-15 13:16                 ` Aldy Hernandez
2021-07-15 13:21                   ` Richard Biener
2021-07-15 13:23                     ` Richard Biener
2021-07-15 13:26                       ` Richard Biener
2021-07-15 19:59                 ` [COMMITTED] Add gimple_range_type for statements Andrew MacLeod
2021-07-16  7:07                   ` 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).