Re: Perforate fnspec attribute strings

2020-10-02 Thread Richard Biener
On Fri, 2 Oct 2020, Jan Hubicka wrote:

> Hi,
> as discussed this patch makes return value and arg specifiers to be 2
> characters long and updates (I hope) all fnspec strings.
> I also enabled part of the verification (just accepting the fortran bug
> with 'R' and 'W' in return value specifiers) to get some evidence that
> the update is complete.
> 
> Bootstrapped/regtested x86_64-linux, OK?

OK.

Richard.

> gcc/ChangeLog:
> 
> 2020-10-02  Jan Hubicka  
> 
>   * attr-fnspec.h: Update documentation.
>   (attr_fnsec::return_desc_size): Set to 2
>   (attr_fnsec::arg_desc_size): Set to 2
>   * builtin-attrs.def (STR1): Update fnspec.
>   * internal-fn.def (UBSAN_NULL): Update fnspec.
>   (UBSAN_VPTR): Update fnspec.
>   (UBSAN_PTR): Update fnspec.
>   (ASAN_CHECK): Update fnspec.
>   (GOACC_DIM_SIZE): Remove fnspec.
>   (GOACC_DIM_POS): Remove fnspec.
>   * tree-ssa-alias.c (attr_fnspec::verify): Update verification.
> 
> gcc/fortran/ChangeLog:
> 
> 2020-10-02  Jan Hubicka  
> 
>   * trans-decl.c (gfc_build_library_function_decl_with_spec): Verify
>   fnspec.
>   (gfc_build_intrinsic_function_decls): Update fnspecs.
>   (gfc_build_builtin_function_decls): Update fnspecs.
>   * trans-io.c (gfc_build_io_library_fndecls): Update fnspecs.
>   * trans-types.c (create_fn_spec): Update fnspecs.
> 
> 
> diff --git a/gcc/attr-fnspec.h b/gcc/attr-fnspec.h
> index 607c0cf0f54..921bb48ae6a 100644
> --- a/gcc/attr-fnspec.h
> +++ b/gcc/attr-fnspec.h
> @@ -25,15 +25,22 @@
>   '1'...'4'  specifies number of argument function returns (as in memset)
>   'm' specifies that returned value is noalias (as in malloc)
>   '.' specifies that nothing is known.
> +   character 1  specifies additional function properties
> + ' 'specifies that nothing is known
>  
> -   character 1+i specifies properties of argument number i as follows:
> +   character 2+2i specifies properties of argument number i as follows:
>   'x' or 'X' specifies that parameter is unused.
>   'r' or 'R' specifies that parameter is only read and memory pointed to 
> is
>   never dereferenced.
>   'w' or 'W' specifies that parameter is only written to.
>   '.' specifies that nothing is known.
> The uppercase letter in addition specifies that parameter
> -   is non-escaping.  */
> +   is non-escaping. 
> +
> +   character 3+2i specifies additional properties of argument number i
> +   as follows:
> + ' 'nothing is known
> + */
>  
>  #ifndef ATTR_FNSPEC_H
>  #define ATTR_FNSPEC_H
> @@ -46,9 +53,9 @@ private:
>/* length of the fn spec string.  */
>const unsigned len;
>/* Number of characters specifying return value.  */
> -  const unsigned int return_desc_size = 1;
> +  const unsigned int return_desc_size = 2;
>/* Number of characters specifying size.  */
> -  const unsigned int arg_desc_size = 1;
> +  const unsigned int arg_desc_size = 2;
>  
>/* Return start of specifier of arg i.  */
>unsigned int arg_idx (int i)
> diff --git a/gcc/builtin-attrs.def b/gcc/builtin-attrs.def
> index 3239311b5a4..778bc8a43a1 100644
> --- a/gcc/builtin-attrs.def
> +++ b/gcc/builtin-attrs.def
> @@ -66,7 +66,7 @@ DEF_ATTR_FOR_INT (6)
>DEF_ATTR_STRING (ATTR_##ENUM, VALUE)   \
>DEF_ATTR_TREE_LIST (ATTR_LIST_##ENUM, ATTR_NULL,   \
> ATTR_##ENUM, ATTR_NULL)
> -DEF_ATTR_FOR_STRING (STR1, "1")
> +DEF_ATTR_FOR_STRING (STR1, "1 ")
>  #undef DEF_ATTR_FOR_STRING
>  
>  /* Construct a tree for a list of two integers.  */
> diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
> index 2be9df40d2c..5940a1fd10c 100644
> --- a/gcc/fortran/trans-decl.c
> +++ b/gcc/fortran/trans-decl.c
> @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "gomp-constants.h"
>  #include "gimplify.h"
>  #include "omp-general.h"
> +#include "attr-fnspec.h"
>  
>  #define MAX_LABEL_VALUE 9
>  
> @@ -3306,6 +3307,11 @@ gfc_build_library_function_decl_with_spec (tree name, 
> const char *spec,
>tree ret;
>va_list args;
>va_start (args, nargs);
> +  if (flag_checking)
> +{
> +  attr_fnspec fnspec (spec, strlen (spec));
> +  fnspec.verify ();
> +}
>ret = build_library_function_decl_1 (name, spec, rettype, nargs, args);
>va_end (args);
>return ret;
> @@ -3325,144 +3331,144 @@ gfc_build_intrinsic_function_decls (void)
>  
>/* String functions.  */
>gfor_fndecl_compare_string = gfc_build_library_function_decl_with_spec (
> - get_identifier (PREFIX("compare_string")), "..R.R",
> + get_identifier (PREFIX("compare_string")), ". . R . R ",
>   integer_type_node, 4, gfc_charlen_type_node, pchar1_type_node,
>   gfc_charlen_type_node, pchar1_type_node);
>DECL_PURE_P (gfor_fndecl_compare_string) = 1;
>TREE_NOTHROW (gfor_fndecl_compare_string) = 1;
>  
>gfor_fndecl_concat_string = 

Perforate fnspec attribute strings

2020-10-02 Thread Jan Hubicka
Hi,
as discussed this patch makes return value and arg specifiers to be 2
characters long and updates (I hope) all fnspec strings.
I also enabled part of the verification (just accepting the fortran bug
with 'R' and 'W' in return value specifiers) to get some evidence that
the update is complete.

Bootstrapped/regtested x86_64-linux, OK?

gcc/ChangeLog:

2020-10-02  Jan Hubicka  

* attr-fnspec.h: Update documentation.
(attr_fnsec::return_desc_size): Set to 2
(attr_fnsec::arg_desc_size): Set to 2
* builtin-attrs.def (STR1): Update fnspec.
* internal-fn.def (UBSAN_NULL): Update fnspec.
(UBSAN_VPTR): Update fnspec.
(UBSAN_PTR): Update fnspec.
(ASAN_CHECK): Update fnspec.
(GOACC_DIM_SIZE): Remove fnspec.
(GOACC_DIM_POS): Remove fnspec.
* tree-ssa-alias.c (attr_fnspec::verify): Update verification.

gcc/fortran/ChangeLog:

2020-10-02  Jan Hubicka  

* trans-decl.c (gfc_build_library_function_decl_with_spec): Verify
fnspec.
(gfc_build_intrinsic_function_decls): Update fnspecs.
(gfc_build_builtin_function_decls): Update fnspecs.
* trans-io.c (gfc_build_io_library_fndecls): Update fnspecs.
* trans-types.c (create_fn_spec): Update fnspecs.


diff --git a/gcc/attr-fnspec.h b/gcc/attr-fnspec.h
index 607c0cf0f54..921bb48ae6a 100644
--- a/gcc/attr-fnspec.h
+++ b/gcc/attr-fnspec.h
@@ -25,15 +25,22 @@
  '1'...'4'  specifies number of argument function returns (as in memset)
  'm'   specifies that returned value is noalias (as in malloc)
  '.'   specifies that nothing is known.
+   character 1  specifies additional function properties
+ ' 'specifies that nothing is known
 
-   character 1+i specifies properties of argument number i as follows:
+   character 2+2i specifies properties of argument number i as follows:
  'x' or 'X' specifies that parameter is unused.
  'r' or 'R' specifies that parameter is only read and memory pointed to is
never dereferenced.
  'w' or 'W' specifies that parameter is only written to.
  '.'   specifies that nothing is known.
The uppercase letter in addition specifies that parameter
-   is non-escaping.  */
+   is non-escaping. 
+
+   character 3+2i specifies additional properties of argument number i
+   as follows:
+ ' 'nothing is known
+ */
 
 #ifndef ATTR_FNSPEC_H
 #define ATTR_FNSPEC_H
@@ -46,9 +53,9 @@ private:
   /* length of the fn spec string.  */
   const unsigned len;
   /* Number of characters specifying return value.  */
-  const unsigned int return_desc_size = 1;
+  const unsigned int return_desc_size = 2;
   /* Number of characters specifying size.  */
-  const unsigned int arg_desc_size = 1;
+  const unsigned int arg_desc_size = 2;
 
   /* Return start of specifier of arg i.  */
   unsigned int arg_idx (int i)
diff --git a/gcc/builtin-attrs.def b/gcc/builtin-attrs.def
index 3239311b5a4..778bc8a43a1 100644
--- a/gcc/builtin-attrs.def
+++ b/gcc/builtin-attrs.def
@@ -66,7 +66,7 @@ DEF_ATTR_FOR_INT (6)
   DEF_ATTR_STRING (ATTR_##ENUM, VALUE) \
   DEF_ATTR_TREE_LIST (ATTR_LIST_##ENUM, ATTR_NULL, \
  ATTR_##ENUM, ATTR_NULL)
-DEF_ATTR_FOR_STRING (STR1, "1")
+DEF_ATTR_FOR_STRING (STR1, "1 ")
 #undef DEF_ATTR_FOR_STRING
 
 /* Construct a tree for a list of two integers.  */
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 2be9df40d2c..5940a1fd10c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gomp-constants.h"
 #include "gimplify.h"
 #include "omp-general.h"
+#include "attr-fnspec.h"
 
 #define MAX_LABEL_VALUE 9
 
@@ -3306,6 +3307,11 @@ gfc_build_library_function_decl_with_spec (tree name, 
const char *spec,
   tree ret;
   va_list args;
   va_start (args, nargs);
+  if (flag_checking)
+{
+  attr_fnspec fnspec (spec, strlen (spec));
+  fnspec.verify ();
+}
   ret = build_library_function_decl_1 (name, spec, rettype, nargs, args);
   va_end (args);
   return ret;
@@ -3325,144 +3331,144 @@ gfc_build_intrinsic_function_decls (void)
 
   /* String functions.  */
   gfor_fndecl_compare_string = gfc_build_library_function_decl_with_spec (
-   get_identifier (PREFIX("compare_string")), "..R.R",
+   get_identifier (PREFIX("compare_string")), ". . R . R ",
integer_type_node, 4, gfc_charlen_type_node, pchar1_type_node,
gfc_charlen_type_node, pchar1_type_node);
   DECL_PURE_P (gfor_fndecl_compare_string) = 1;
   TREE_NOTHROW (gfor_fndecl_compare_string) = 1;
 
   gfor_fndecl_concat_string = gfc_build_library_function_decl_with_spec (
-   get_identifier (PREFIX("concat_string")), "..W.R.R",
+   get_identifier (PREFIX("concat_string")), ". . W . R . R ",
void_type_node, 6, gfc_charlen_type_node, pchar1_type_node,
gfc_charlen_type_node, pchar1_type_node,