[PATCH] Allow arg promotion in gimple_builtin_call_types_compatible_p (PR target/49244)

Richard Biener rguenther@suse.de
Mon May 2 19:02:00 GMT 2016


On May 2, 2016 6:29:55 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>Most of the builtins don't pass arguments in char/short types,
>except for some sync/atomic builtins, some sanitizer builtins and
>TM builtins.
>On targets where targetm.calls.promote_prototypes returns true (e.g.
>always
>on x86_64/i686), unfortunately this means that gimple_call_builtin_p
>often returns false for those, e.g. on __sync_fetch_and_add_2, because
>the second argument has been promoted to int from unsigned short.
>We actually expand those right, because we don't check that during
>expansion, but e.g. such atomics aren't instrumented with
>-fsanitize=thread
>because of this etc.
>
>The following patch allows those cases.  Bootstrapped/regtested on
>x86_64-linux and i686-linux, ok for trunk?

OK.

Thanks,
Richard.

>2016-05-02  Jakub Jelinek  <jakub@redhat.com>
>
>	PR target/49244
>	* gimple.c (gimple_builtin_call_types_compatible_p): Allow
>	char/short arguments promoted to int because of promote_prototypes.
>
>--- gcc/gimple.c.jj	2016-03-11 17:37:43.000000000 +0100
>+++ gcc/gimple.c	2016-05-02 12:20:16.490716014 +0200
>@@ -2486,7 +2486,16 @@ gimple_builtin_call_types_compatible_p (
>       if (!targs)
> 	return true;
>       tree arg = gimple_call_arg (stmt, i);
>-      if (!useless_type_conversion_p (TREE_VALUE (targs), TREE_TYPE
>(arg)))
>+      tree type = TREE_VALUE (targs);
>+      if (!useless_type_conversion_p (type, TREE_TYPE (arg))
>+	  /* char/short integral arguments are promoted to int
>+	     by several frontends if targetm.calls.promote_prototypes
>+	     is true.  Allow such promotion too.  */
>+	  && !(INTEGRAL_TYPE_P (type)
>+	       && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
>+	       && targetm.calls.promote_prototypes (TREE_TYPE (fndecl))
>+	       && useless_type_conversion_p (integer_type_node,
>+					     TREE_TYPE (arg))))
> 	return false;
>       targs = TREE_CHAIN (targs);
>     }
>
>
>	Jakub




More information about the Gcc-patches mailing list