Walk pointer_to and reference_to chain in free_lang_data

Richard Biener rguenther@suse.de
Thu Aug 23 12:20:00 GMT 2018


On Thu, 23 Aug 2018, Jan Hubicka wrote:

> Hi
> this patch takes care of gcov.  There are two oddities. First that gcov uses
> langhook to produce new records while asan gets around with make_node.
> I think both are middle-end types and in the direction of separating front-ends
> and middle-ends better the langhooks are not desirable.
> 
> The TYPE_STUB_DECL is produced by finish_builtin_struct.  This is function used
> just few times but I am not sure if we don't want debug info on some of the
> builtins, so I have added extra parameter.
> 
> config/darwin.c:  finish_builtin_struct (cfstring_type_node, "__builtin_CFString",
> config/i386/i386.c:  finish_builtin_struct (type, "__processor_model", field_chain, NULL_TREE);
> coverage.c:  finish_builtin_struct (ctr_info, "__gcov_ctr_info", fields, NULL_TREE, true);
> coverage.c:  finish_builtin_struct (type, "__gcov_fn_info", fields, NULL_TREE, true);
> coverage.c:  finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE, true);
> cp/decl.c:  finish_builtin_struct (t, "__ptrmemfunc_type", fields, ptr_type_node);
> cp/rtti.c:  finish_builtin_struct (pseudo_type, pseudo_name, fields, NULL_TREE);
> hsa-brig.c:  finish_builtin_struct (variable_info_type, "__hsa_variable_info", id_f2,
> hsa-brig.c:  finish_builtin_struct (kernel_info_type, "__hsa_kernel_info", id_f5,
> hsa-brig.c:  finish_builtin_struct (hsa_image_desc_type, "__hsa_image_desc", id_f5,
> hsa-gen.c:      finish_builtin_struct (*hsa_kernel_dispatch_type, "__hsa_kernel_dispatch",
> objc/objc-act.c:  /* NB: The finish_builtin_struct() routine expects FIELD_DECLs in
> objc/objc-act.c:  finish_builtin_struct (type, "__builtin_ObjCString",
> omp-expand.c:  finish_builtin_struct (grid_attr_trees->kernel_launch_attributes_type,
> stor-layout.c:finish_builtin_struct (tree type, const char *name, tree fields,
> stor-layout.h:extern void finish_builtin_struct (tree, const char *, tree, tree,
> 
> Perhaps we could make them all to just use identifier_node
> but I am honestly not sure :)

Given finish_builtin_struct uses BUILTINS_LOCATION for the TYPE_DECL
and dwarf2out.c does

    case TYPE_DECL:
      /* Don't emit stubs for types unless they are needed by other DIEs.  
*/
      if (TYPE_DECL_SUPPRESS_DEBUG (decl))
        return;

      /* Don't bother trying to generate any DIEs to represent any of the
         normal built-in types for the language we are compiling.  */
      if (DECL_IS_BUILTIN (decl))
        return;

making them just all IDENTIFIER_NODE is fine I think.  At least for
the debuginfo part it shouldn't make any difference ...

Richard.

> Bootstrapped/regtested x86_64-linux, OK?
> 
> Honza
> 
> 	* coverage.c (build_fn_info_type, build_info, coverage_obj_init):
> 	Use make_node to build record type and pass true to
> 	finish_builtin_struct.
> 	* stor-layout.c (finish_record_layout): Add nodebug parameter.
> 	* stor-layout.h (finish_builtin_struct): Likewise.
> Index: coverage.c
> ===================================================================
> --- coverage.c	(revision 263696)
> +++ coverage.c	(working copy)
> @@ -780,7 +780,7 @@ build_var (tree fn_decl, tree type, int
>  static void
>  build_fn_info_type (tree type, unsigned counters, tree gcov_info_type)
>  {
> -  tree ctr_info = lang_hooks.types.make_type (RECORD_TYPE);
> +  tree ctr_info = make_node (RECORD_TYPE);
>    tree field, fields;
>    tree array_type;
>  
> @@ -797,7 +797,7 @@ build_fn_info_type (tree type, unsigned
>    DECL_CHAIN (field) = fields;
>    fields = field;
>    
> -  finish_builtin_struct (ctr_info, "__gcov_ctr_info", fields, NULL_TREE);
> +  finish_builtin_struct (ctr_info, "__gcov_ctr_info", fields, NULL_TREE, true);
>  
>    /* key */
>    field = build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE,
> @@ -831,7 +831,7 @@ build_fn_info_type (tree type, unsigned
>    DECL_CHAIN (field) = fields;
>    fields = field;
>  
> -  finish_builtin_struct (type, "__gcov_fn_info", fields, NULL_TREE);
> +  finish_builtin_struct (type, "__gcov_fn_info", fields, NULL_TREE, true);
>  }
>  
>  /* Returns a CONSTRUCTOR for a gcov_fn_info.  DATA is
> @@ -963,7 +963,7 @@ build_info_type (tree type, tree fn_info
>    DECL_CHAIN (field) = fields;
>    fields = field;
>  
> -  finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE);
> +  finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE, true);
>  }
>  
>  /* Returns a CONSTRUCTOR for the gcov_info object.  INFO_TYPE is the
> @@ -1020,8 +1020,6 @@ build_info (tree info_type, tree fn_ary)
>  				      get_identifier (ctr_merge_functions[ix]),
>  				      TREE_TYPE (merge_fn_type));
>  	  DECL_EXTERNAL (merge_fn) = 1;
> -	  TREE_PUBLIC (merge_fn) = 1;
> -	  DECL_ARTIFICIAL (merge_fn) = 1;
>  	  TREE_NOTHROW (merge_fn) = 1;
>  	  /* Initialize assembler name so we can stream out. */
>  	  DECL_ASSEMBLER_NAME (merge_fn);
> @@ -1140,10 +1138,10 @@ coverage_obj_init (void)
>        n_counters++;
>    
>    /* Build the info and fn_info types.  These are mutually recursive.  */
> -  gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE);
> -  gcov_fn_info_type = lang_hooks.types.make_type (RECORD_TYPE);
> +  gcov_info_type = make_node (RECORD_TYPE);
> +  gcov_fn_info_type = make_node (RECORD_TYPE);
>    build_fn_info_type (gcov_fn_info_type, n_counters, gcov_info_type);
> -  gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE);
> +  gcov_info_type = make_node (RECORD_TYPE);
>    gcov_fn_info_ptr_type = build_pointer_type
>      (build_qualified_type (gcov_fn_info_type, TYPE_QUAL_CONST));
>    build_info_type (gcov_info_type, gcov_fn_info_ptr_type);
> Index: stor-layout.c
> ===================================================================
> --- stor-layout.c	(revision 263696)
> +++ stor-layout.c	(working copy)
> @@ -2224,13 +2224,14 @@ finish_record_layout (record_layout_info
>  
>  /* Finish processing a builtin RECORD_TYPE type TYPE.  It's name is
>     NAME, its fields are chained in reverse on FIELDS.
> +   If NODEBUG is set, do not produce TYPE_DECL and STUB.
>  
>     If ALIGN_TYPE is non-null, it is given the same alignment as
>     ALIGN_TYPE.  */
>  
>  void
>  finish_builtin_struct (tree type, const char *name, tree fields,
> -		       tree align_type)
> +		       tree align_type, bool nodebug)
>  {
>    tree tail, next;
>  
> @@ -2251,14 +2252,15 @@ finish_builtin_struct (tree type, const
>      }
>  
>    layout_type (type);
> -#if 0 /* not yet, should get fixed properly later */
> -  TYPE_NAME (type) = make_type_decl (get_identifier (name), type);
> -#else
> -  TYPE_NAME (type) = build_decl (BUILTINS_LOCATION,
> -				 TYPE_DECL, get_identifier (name), type);
> -#endif
> -  TYPE_STUB_DECL (type) = TYPE_NAME (type);
> -  layout_decl (TYPE_NAME (type), 0);
> +  if (nodebug)
> +    TYPE_NAME (type) = get_identifier (name);
> +  else
> +    {
> +      TYPE_NAME (type) = build_decl (BUILTINS_LOCATION,
> +				     TYPE_DECL, get_identifier (name), type);
> +      TYPE_STUB_DECL (type) = TYPE_NAME (type);
> +      layout_decl (TYPE_NAME (type), 0);
> +    }
>  }
>  
>  /* Calculate the mode, size, and alignment for TYPE.
> Index: stor-layout.h
> ===================================================================
> --- stor-layout.h	(revision 263696)
> +++ stor-layout.h	(working copy)
> @@ -43,7 +43,8 @@ extern void initialize_sizetypes (void);
>  
>  /* Finish up a builtin RECORD_TYPE. Give it a name and provide its
>     fields. Optionally specify an alignment, and then lay it out.  */
> -extern void finish_builtin_struct (tree, const char *, tree, tree);
> +extern void finish_builtin_struct (tree, const char *, tree, tree,
> +				   bool nodebug = false);
>  
>  /* Given a VAR_DECL, PARM_DECL, RESULT_DECL or FIELD_DECL node,
>     calculates the DECL_SIZE, DECL_SIZE_UNIT, DECL_ALIGN and DECL_MODE
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)



More information about the Gcc-patches mailing list