diff mbox series

Unbreak Ada bootstrap (was Re: [PATCH PR/82546] tree node size)

Message ID 20171017192946.GB14653@tucnak
State New
Headers show
Series Unbreak Ada bootstrap (was Re: [PATCH PR/82546] tree node size) | expand

Commit Message

Jakub Jelinek Oct. 17, 2017, 7:29 p.m. UTC
Hi!

On Fri, Oct 13, 2017 at 02:29:40PM -0400, Nathan Sidwell wrote:
> [Although I filed this as a middle-end bug, it's really a core infra bug,
> not sure who the best reviewer is]

> 2017-10-13  Nathan Sidwell  <nathan@acm.org>
> 
> 	PR middle-end/82546
> 	gcc/
> 	* tree.c (tree_code_size): Reformat.  Punt to lang hook for unknown
> 	TYPE nodes.

This change broke Ada bootstrap, because the FE doesn't have any tree_size
langhook, but has one language specific tcc_type tree -
UNCONSTRAINED_ARRAY_TYPE.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-10-17  Jakub Jelinek  <jakub@redhat.com>

	* langhooks.h (struct lang_hooks): Document that tree_size langhook
	may be also called on tcc_type nodes.
	* langhooks.c (lhd_tree_size): Likewise.

	* gcc-interface/misc.c (gnat_tree_size): New function.
	(LANG_HOOKS_TREE_SIZE): Redefine.



	Jakub

Comments

Richard Biener Oct. 17, 2017, 8:06 p.m. UTC | #1
On October 17, 2017 9:29:46 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>On Fri, Oct 13, 2017 at 02:29:40PM -0400, Nathan Sidwell wrote:
>> [Although I filed this as a middle-end bug, it's really a core infra
>bug,
>> not sure who the best reviewer is]
>
>> 2017-10-13  Nathan Sidwell  <nathan@acm.org>
>> 
>> 	PR middle-end/82546
>> 	gcc/
>> 	* tree.c (tree_code_size): Reformat.  Punt to lang hook for unknown
>> 	TYPE nodes.
>
>This change broke Ada bootstrap, because the FE doesn't have any
>tree_size
>langhook, but has one language specific tcc_type tree -
>UNCONSTRAINED_ARRAY_TYPE.
>
>Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk?

OK. 

Richard. 

>2017-10-17  Jakub Jelinek  <jakub@redhat.com>
>
>	* langhooks.h (struct lang_hooks): Document that tree_size langhook
>	may be also called on tcc_type nodes.
>	* langhooks.c (lhd_tree_size): Likewise.
>
>	* gcc-interface/misc.c (gnat_tree_size): New function.
>	(LANG_HOOKS_TREE_SIZE): Redefine.
>
>--- gcc/langhooks.h.jj	2017-09-12 17:20:17.000000000 +0200
>+++ gcc/langhooks.h	2017-10-17 19:49:29.277324006 +0200
>@@ -307,10 +307,10 @@ struct lang_hooks
>   /* Remove any parts of the tree that are used only by the FE. */
>   void (*free_lang_data) (tree);
> 
>-  /* Determines the size of any language-specific tcc_constant or
>-     tcc_exceptional nodes.  Since it is called from make_node, the
>-     only information available is the tree code.  Expected to die
>-     on unrecognized codes.  */
>+  /* Determines the size of any language-specific tcc_constant,
>+     tcc_exceptional or tcc_type nodes.  Since it is called from
>+     make_node, the only information available is the tree code.
>+     Expected to die on unrecognized codes.  */
>   size_t (*tree_size) (enum tree_code);
> 
>   /* Return the language mask used for converting argv into a sequence
>--- gcc/langhooks.c.jj	2017-05-21 15:46:13.000000000 +0200
>+++ gcc/langhooks.c	2017-10-17 19:47:13.973960166 +0200
>@@ -266,8 +266,8 @@ lhd_gimplify_expr (tree *expr_p ATTRIBUT
> }
> 
> /* lang_hooks.tree_size: Determine the size of a tree with code C,
>-   which is a language-specific tree code in category tcc_constant or
>-   tcc_exceptional.  The default expects never to be called.  */
>+   which is a language-specific tree code in category tcc_constant,
>+   tcc_exceptional or tcc_type.  The default expects never to be
>called.  */
> size_t
> lhd_tree_size (enum tree_code c ATTRIBUTE_UNUSED)
> {
>--- gcc/ada/gcc-interface/misc.c.jj	2017-08-31 23:47:18.000000000 +0200
>+++ gcc/ada/gcc-interface/misc.c	2017-10-17 19:48:39.715923329 +0200
>@@ -343,6 +343,23 @@ internal_error_function (diagnostic_cont
>   Compiler_Abort (sp, sp_loc, true);
> }
> 
>+/* lang_hooks.tree_size: Determine the size of a tree with code C,
>+   which is a language-specific tree code in category tcc_constant,
>+   tcc_exceptional or tcc_type.  The default expects never to be
>called.  */
>+
>+static size_t
>+gnat_tree_size (enum tree_code code)
>+{
>+  gcc_checking_assert (code >= NUM_TREE_CODES);
>+  switch (code)
>+    {
>+    case UNCONSTRAINED_ARRAY_TYPE:
>+      return sizeof (tree_type_non_common);
>+    default:
>+      gcc_unreachable ();
>+    }
>+}
>+
>/* Perform all the initialization steps that are language-specific.  */
> 
> static bool
>@@ -1387,6 +1404,8 @@ get_lang_specific (tree node)
> #define LANG_HOOKS_NAME			"GNU Ada"
> #undef  LANG_HOOKS_IDENTIFIER_SIZE
> #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct tree_identifier)
>+#undef  LANG_HOOKS_TREE_SIZE
>+#define LANG_HOOKS_TREE_SIZE		gnat_tree_size
> #undef  LANG_HOOKS_INIT
> #define LANG_HOOKS_INIT			gnat_init
> #undef  LANG_HOOKS_OPTION_LANG_MASK
>
>
>	Jakub
Eric Botcazou Oct. 17, 2017, 8:12 p.m. UTC | #2
> This change broke Ada bootstrap, because the FE doesn't have any tree_size
> langhook, but has one language specific tcc_type tree -
> UNCONSTRAINED_ARRAY_TYPE.

There should be a requirement to test all languages for this kind of changes.

> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
> 
> 2017-10-17  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* langhooks.h (struct lang_hooks): Document that tree_size langhook
> 	may be also called on tcc_type nodes.
> 	* langhooks.c (lhd_tree_size): Likewise.
> 
> 	* gcc-interface/misc.c (gnat_tree_size): New function.
> 	(LANG_HOOKS_TREE_SIZE): Redefine.

OK, thanks.
diff mbox series

Patch

--- gcc/langhooks.h.jj	2017-09-12 17:20:17.000000000 +0200
+++ gcc/langhooks.h	2017-10-17 19:49:29.277324006 +0200
@@ -307,10 +307,10 @@  struct lang_hooks
   /* Remove any parts of the tree that are used only by the FE. */
   void (*free_lang_data) (tree);
 
-  /* Determines the size of any language-specific tcc_constant or
-     tcc_exceptional nodes.  Since it is called from make_node, the
-     only information available is the tree code.  Expected to die
-     on unrecognized codes.  */
+  /* Determines the size of any language-specific tcc_constant,
+     tcc_exceptional or tcc_type nodes.  Since it is called from
+     make_node, the only information available is the tree code.
+     Expected to die on unrecognized codes.  */
   size_t (*tree_size) (enum tree_code);
 
   /* Return the language mask used for converting argv into a sequence
--- gcc/langhooks.c.jj	2017-05-21 15:46:13.000000000 +0200
+++ gcc/langhooks.c	2017-10-17 19:47:13.973960166 +0200
@@ -266,8 +266,8 @@  lhd_gimplify_expr (tree *expr_p ATTRIBUT
 }
 
 /* lang_hooks.tree_size: Determine the size of a tree with code C,
-   which is a language-specific tree code in category tcc_constant or
-   tcc_exceptional.  The default expects never to be called.  */
+   which is a language-specific tree code in category tcc_constant,
+   tcc_exceptional or tcc_type.  The default expects never to be called.  */
 size_t
 lhd_tree_size (enum tree_code c ATTRIBUTE_UNUSED)
 {
--- gcc/ada/gcc-interface/misc.c.jj	2017-08-31 23:47:18.000000000 +0200
+++ gcc/ada/gcc-interface/misc.c	2017-10-17 19:48:39.715923329 +0200
@@ -343,6 +343,23 @@  internal_error_function (diagnostic_cont
   Compiler_Abort (sp, sp_loc, true);
 }
 
+/* lang_hooks.tree_size: Determine the size of a tree with code C,
+   which is a language-specific tree code in category tcc_constant,
+   tcc_exceptional or tcc_type.  The default expects never to be called.  */
+
+static size_t
+gnat_tree_size (enum tree_code code)
+{
+  gcc_checking_assert (code >= NUM_TREE_CODES);
+  switch (code)
+    {
+    case UNCONSTRAINED_ARRAY_TYPE:
+      return sizeof (tree_type_non_common);
+    default:
+      gcc_unreachable ();
+    }
+}
+
 /* Perform all the initialization steps that are language-specific.  */
 
 static bool
@@ -1387,6 +1404,8 @@  get_lang_specific (tree node)
 #define LANG_HOOKS_NAME			"GNU Ada"
 #undef  LANG_HOOKS_IDENTIFIER_SIZE
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct tree_identifier)
+#undef  LANG_HOOKS_TREE_SIZE
+#define LANG_HOOKS_TREE_SIZE		gnat_tree_size
 #undef  LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT			gnat_init
 #undef  LANG_HOOKS_OPTION_LANG_MASK