public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2251] [Ada] Use GNAT encodings only when -fgnat-encodings=all is specified
@ 2021-07-12 12:52 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-12 12:52 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:58d32c72ca0156b0267a9b36b91b414cab8978f2

commit r12-2251-g58d32c72ca0156b0267a9b36b91b414cab8978f2
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Jun 4 18:22:17 2021 +0200

    [Ada] Use GNAT encodings only when -fgnat-encodings=all is specified
    
    gcc/ada/
    
            * gcc-interface/decl.c (gnat_to_gnu_entity) <discrete_type>: Add a
            parallel type only when -fgnat-encodings=all is specified.
            <E_Array_Type>: Use the PAT name and special suffixes only when
            -fgnat-encodings=all is specified.
            <E_Array_Subtype>: Build a special type for debugging purposes only
            when -fgnat-encodings=all is specified.  Add a parallel type or use
            the PAT name only when -fgnat-encodings=all is specified.
            <E_Record_Type>: Generate debug info for the inner record types only
            when -fgnat-encodings=all is specified.
            <E_Record_Subtype>: Use a debug type for an artificial subtype only
            except when -fgnat-encodings=all is specified.
            (elaborate_expression_1): Reset need_for_debug when possible only
            except when -fgnat-encodings=all is specified.
            (components_to_record): Use XV encodings for variable size only
            when -fgnat-encodings=all is specified.
            (associate_original_type_to_packed_array): Add a parallel type only
            when -fgnat-encodings=all is specified.
            * gcc-interface/misc.c (gnat_get_array_descr_info): Do not return
            full information only when -fgnat-encodings=all is specified.
            * gcc-interface/utils.c (make_packable_type): Add a parallel type
            only when -fgnat-encodings=all is specified.
            (maybe_pad_type): Make the inner type a debug type only except when
            -fgnat-encodings=all is specified.  Create an XVS type for variable
            size only when -fgnat-encodings=all is specified.
            (rest_of_record_type_compilation): Add a parallel type only when
            -fgnat-encodings=all is specified.

Diff:
---
 gcc/ada/gcc-interface/decl.c  | 54 +++++++++++++++++++++----------------------
 gcc/ada/gcc-interface/misc.c  |  6 ++---
 gcc/ada/gcc-interface/utils.c |  8 +++----
 3 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 8eb1e30d447..4b6479b2a04 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -1998,10 +1998,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	     so we use an intermediate step for standard DWARF.  */
 	  if (debug_info_p)
 	    {
-	      if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
-		SET_TYPE_DEBUG_TYPE (gnu_type, gnu_field_type);
-	      else if (DECL_PARALLEL_TYPE (t))
+	      if (gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 		add_parallel_type (gnu_type, DECL_PARALLEL_TYPE (t));
+	      else
+		SET_TYPE_DEBUG_TYPE (gnu_type, gnu_field_type);
 	    }
 	}
 
@@ -2210,11 +2210,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	   implementation type.  But, in any case, mark it as artificial so
 	   the debugger can skip it.  */
 	const Entity_Id gnat_name
-	  = Present (PAT) && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL
+	  = Present (PAT) && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL
 	    ? PAT
 	    : gnat_entity;
 	tree xup_name
-	  = gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL
+	  = gnat_encodings == DWARF_GNAT_ENCODINGS_ALL
 	    ? create_concat_name (gnat_name, "XUP")
 	    : gnu_entity_name;
 	create_type_decl (xup_name, gnu_fat_type, true, debug_info_p,
@@ -2420,11 +2420,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	   template at a negative offset, but this was somewhat of a kludge; we
 	   now shift thin pointer values explicitly but only those which have a
 	   TYPE_UNCONSTRAINED_ARRAY attached to the designated RECORD_TYPE.
-	   Note that GDB can handle standard DWARF information for them, so we
-	   don't have to name them as a GNAT encoding, except if specifically
-	   asked to.  */
+	   If the GNAT encodings are used, give it a name.  */
 	tree xut_name
-	  = (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+	  = (gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 	    ? create_concat_name (gnat_name, "XUT")
 	    : gnu_entity_name;
 	obj = build_unc_object_type (gnu_template_type, tem, xut_name,
@@ -2673,7 +2671,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 		       && TREE_CODE (TREE_TYPE (gnu_index_type))
 			  != INTEGER_TYPE)
 		   || TYPE_BIASED_REPRESENTATION_P (gnu_index_type))
-		  && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+		  && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 		need_index_type_struct = true;
 	    }
 
@@ -2850,7 +2848,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 		    gnu_entity_name = gnu_name;
 		}
 
-	      else if (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+	      else if (gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 		{
 		  tree gnu_base_decl
 		    = gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE,
@@ -2897,7 +2895,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	      save_gnu_tree (gnat_entity, NULL_TREE, false);
 
 	      /* Set the ___XP suffix for GNAT encodings.  */
-	      if (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+	      if (gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 		gnu_entity_name = DECL_NAME (TYPE_NAME (gnu_type));
 
 	      tree gnu_inner = gnu_type;
@@ -3372,14 +3370,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	      = build_subst_list (gnat_entity, gnat_parent_type, definition);
 
 	    /* Set the layout of the type to match that of the parent type,
-	       doing required substitutions.  If we are in minimal GNAT
-	       encodings mode, we don't need debug info for the inner record
+	       doing required substitutions.  Note that, if we do not use the
+	       GNAT encodings, we don't need debug info for the inner record
 	       types, as they will be part of the embedding variant record's
 	       debug info.  */
 	    copy_and_substitute_in_layout
 	      (gnat_entity, gnat_parent_type, gnu_type, gnu_parent_type,
 	       gnu_subst_list,
-	       debug_info_p && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL);
+	       debug_info_p && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL);
 	  }
 	else
 	  {
@@ -3518,11 +3516,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	      annotate_rep (gnat_entity, gnu_type);
 
 	      /* If debugging information is being written for the type and if
-		 we are asked to output such encodings, write a record that
+		 we are asked to output GNAT encodings, write a record that
 		 shows what we are a subtype of and also make a variable that
 		 indicates our size, if still variable.  */
 	      if (debug_info_p
-		  && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+		  && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 		{
 		  tree gnu_subtype_marker = make_node (RECORD_TYPE);
 		  tree gnu_unpad_base_name
@@ -3553,11 +3551,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 					 true, true, NULL, gnat_entity, false);
 		}
 
-	      /* Or else, if the subtype is artificial and encodings are not
-		 used, use the base record type as the debug type.  */
+	      /* Or else, if the subtype is artificial and GNAT encodings are
+		 not used, use the base record type as the debug type.  */
 	      else if (debug_info_p
 		       && artificial_p
-		       && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+		       && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
 		SET_TYPE_DEBUG_TYPE (gnu_type, gnu_unpad_base_type);
 	    }
 
@@ -6892,7 +6890,7 @@ elaborate_expression_1 (tree gnu_expr, Entity_Id gnat_entity, const char *s,
      we must be careful because we do not generate debug info for external
      variables so DECL_IGNORED_P is not stable across units.  */
   if (need_for_debug
-      && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL
+      && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL
       && (TREE_CONSTANT (gnu_expr)
 	  || (!expr_public_p
 	      && DECL_P (gnu_expr)
@@ -7777,7 +7775,7 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
 		      tree *p_gnu_rep_list)
 {
   const bool needs_xv_encodings
-    = debug_info && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL;
+    = debug_info && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL;
   bool all_rep_and_size = all_rep && TYPE_SIZE (gnu_record_type);
   bool variants_have_rep = all_rep;
   bool layout_with_rep = false;
@@ -10241,7 +10239,12 @@ associate_original_type_to_packed_array (tree gnu_type, Entity_Id gnat_entity)
 
   gcc_assert (TYPE_IMPL_PACKED_ARRAY_P (gnu_type));
 
-  if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+  if (gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
+    {
+      add_parallel_type (gnu_type, gnu_original_array_type);
+      return NULL_TREE;
+    }
+  else
     {
       SET_TYPE_ORIGINAL_PACKED_ARRAY (gnu_type, gnu_original_array_type);
 
@@ -10250,11 +10253,6 @@ associate_original_type_to_packed_array (tree gnu_type, Entity_Id gnat_entity)
 	original_name = DECL_NAME (original_name);
       return original_name;
     }
-  else
-    {
-      add_parallel_type (gnu_type, gnu_original_array_type);
-      return NULL_TREE;
-    }
 }
 
 /* Given a type T, a FIELD_DECL F, and a replacement value R, return an
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 72a2624b9da..186367ac6d1 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -806,7 +806,7 @@ gnat_get_array_descr_info (const_tree const_type,
   /* As well as array types embedded in a record type with their bounds.  */
   else if (TREE_CODE (type) == RECORD_TYPE
 	   && TYPE_CONTAINS_TEMPLATE_P (type)
-	   && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+	   && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
     {
       /* This will be our base object address.  Note that we assume that
 	 pointers to this will actually point to the array field (thin
@@ -901,7 +901,7 @@ gnat_get_array_descr_info (const_tree const_type,
 	  if (TYPE_CONTEXT (first_dimen)
 	      && TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE
 	      && CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (index_type))
-	      && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+	      && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 	    {
 	      info->dimen[i].lower_bound = NULL_TREE;
 	      info->dimen[i].upper_bound = NULL_TREE;
@@ -943,7 +943,7 @@ gnat_get_array_descr_info (const_tree const_type,
   info->associated = NULL_TREE;
   info->data_location = NULL_TREE;
 
-  if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+  if (gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
     {
       /* When arrays contain dynamically-sized elements, we usually wrap them
 	 in padding types, or we create constrained types for them.  Then, if
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 535f4ca7fba..846d20a8be7 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1277,7 +1277,7 @@ make_packable_type (tree type, bool in_record, unsigned int max_align)
 
   finish_record_type (new_type, nreverse (new_field_list), 2, false);
   relate_alias_sets (new_type, type, ALIAS_SET_COPY);
-  if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+  if (gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
     SET_TYPE_DEBUG_TYPE (new_type, TYPE_DEBUG_TYPE (type));
   else if (TYPE_STUB_DECL (type))
     SET_DECL_PARALLEL_TYPE (TYPE_STUB_DECL (new_type),
@@ -1610,7 +1610,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
     }
 
   /* Make the inner type the debug type of the padded type.  */
-  if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+  if (gnat_encodings != DWARF_GNAT_ENCODINGS_ALL)
     SET_TYPE_DEBUG_TYPE (record, maybe_debug_type (type));
 
   /* Unless debugging information isn't being written for the input type,
@@ -1645,7 +1645,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
       /* There is no need to show what we are a subtype of when outputting as
 	 few encodings as possible: regular debugging infomation makes this
 	 redundant.  */
-      if (gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+      if (gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
 	{
 	  tree marker = make_node (RECORD_TYPE);
 	  tree orig_name = TYPE_IDENTIFIER (type);
@@ -2274,7 +2274,7 @@ rest_of_record_type_compilation (tree record_type)
 
   /* If this record type is of variable size, make a parallel record type that
      will tell the debugger how the former is laid out (see exp_dbug.ads).  */
-  if (var_size && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
+  if (var_size && gnat_encodings == DWARF_GNAT_ENCODINGS_ALL)
     {
       tree new_record_type
 	= make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-12 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 12:52 [gcc r12-2251] [Ada] Use GNAT encodings only when -fgnat-encodings=all is specified Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).