rs6000: Skip overload instances with uninitialized fntype (PR103622)

Message ID 59bd5fac-48d3-472f-1acb-b36bb11a34d7@linux.ibm.com
State New
Headers
Series rs6000: Skip overload instances with uninitialized fntype (PR103622) |

Commit Message

Li, Pan2 via Gcc-patches Dec. 13, 2021, 4:15 p.m. UTC
  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  <wschmidt@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(+)
  

Comments

Li, Pan2 via Gcc-patches Jan. 5, 2022, 7:43 p.m. UTC | #1
Hi!  I'd like to ping this patch, now that I'm back from break.

Thanks!
Bill

On 12/13/21 10:15 AM, Bill Schmidt wrote:
> 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  <wschmidt@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);
>
  
Segher Boessenkool Jan. 5, 2022, 8:50 p.m. UTC | #2
Happy new year Bill!

On Mon, Dec 13, 2021 at 10:15:46AM -0600, Bill Schmidt wrote:
> 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.

Okay for trunk.  Thanks!


Segher


> 	PR target/103622
> 	* config/rs6000/rs6000-c.c (altivec_resolve_new_overloaded_builtin):
> 	Skip over instances with undefined function types.
  

Patch

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