Hi!

For some data types like IEEE-128, we determine whether the type is available
at built-in function initialization time.  If it's not, then we don't provide
the function type for function instances that require the data type.  PR103622
observes that this can cause us to ICE when running the list of instances when
the target doesn't support the data type.

Ideally, we wouldn't even put such an instance in the list of instances that
an overload can map to, but to do that is much more complicated.  Instead,
this patch just ensures we don't dereference a NULL pointer when the situation
arises.

Tested the fix on a powerpc-e300c3-linux-gnu cross.  Bootstrapped and tested on
powerpc64le-linux-gnu with no regressions.  Is this okay for trunk?

Thanks!
Bill


2021-12-13  Bill Schmidt  <wschm...@linux.ibm.com>

gcc/
        PR target/103622
        * config/rs6000/rs6000-c.c (altivec_resolve_new_overloaded_builtin):
        Skip over instances with undefined function types.
---
 gcc/config/rs6000/rs6000-c.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index 8e83d97e72f..fc4cc929884 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -2943,6 +2943,12 @@ altivec_resolve_new_overloaded_builtin (location_t loc, 
tree fndecl,
 
        for (; instance != NULL; instance = instance->next)
          {
+           /* It is possible for an instance to require a data type that isn't
+              defined on this target, in which case instance->fntype will be
+              NULL.  */
+           if (!instance->fntype)
+             continue;
+
            bool mismatch = false;
            tree nextparm = TYPE_ARG_TYPES (instance->fntype);
 
-- 
2.27.0


Reply via email to