This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't eliminate used pointer typedefs from debuginfo as unused (PR debug/43190)


On Fri, 26 Feb 2010, Jakub Jelinek wrote:

> Hi!
> 
> I've been wondering why when debugging var-tracking I can't use
> (variable_tracking_info)(bb->aux) and have to instead use
> (struct variable_tracking_info_def *)(bb->aux).  Also, VTI (bb) doesn't
> work even when built with -g3.  The problem is that variable_tracking_info
> is a typedef to struct variable_tracking_info_def * and no variable nor
> field has such type.  It is used heavily in the source though for casts
> (through the VTI macro), but gcc does eliminate it as unused type anyway.
> The problem seems to be that used_types_insert skips through POINTER_TYPEs
> and to main variant of the type, while IMHO we want to stop when we find a
> named type and record that named type as used into the hash table.
> 
> This is a regression from say 3.2 which didn't do any unused type
> elimination from the debug info.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for
> trunk?

Ok.

Thanks,
Richard.

> 2010-02-26  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR debug/43190
> 	* function.c (used_types_insert): Don't skip through named pointer
> 	types.  Don't use TYPE_MAIN_VARIANT if the original type has a name
> 	and it is different from the main variant's type.
> 
> 	* c-c++-common/dwarf2/pr43190.c: New test.
> 
> --- gcc/function.c.jj	2010-01-22 18:47:21.000000000 +0100
> +++ gcc/function.c	2010-02-26 11:43:13.000000000 +0100
> @@ -5469,8 +5469,13 @@ void
>  used_types_insert (tree t)
>  {
>    while (POINTER_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
> -    t = TREE_TYPE (t);
> -  t = TYPE_MAIN_VARIANT (t);
> +    if (TYPE_NAME (t))
> +      break;
> +    else
> +      t = TREE_TYPE (t);
> +  if (TYPE_NAME (t) == NULL_TREE
> +      || TYPE_NAME (t) == TYPE_NAME (TYPE_MAIN_VARIANT (t)))
> +    t = TYPE_MAIN_VARIANT (t);
>    if (debug_info_level > DINFO_LEVEL_NONE)
>      {
>        if (cfun)
> --- gcc/testsuite/c-c++-common/dwarf2/pr43190.c.jj	2010-02-26 12:22:09.000000000 +0100
> +++ gcc/testsuite/c-c++-common/dwarf2/pr43190.c	2010-02-26 12:22:26.000000000 +0100
> @@ -0,0 +1,13 @@
> +/* PR debug/43190 */
> +/* { dg-options "-gdwarf-2 -dA" } */
> +/* { dg-final { scan-assembler "DW_TAG_structure_type\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"S\[^\\r\\n\]*DW_AT_name" } } */
> +/* { dg-final { scan-assembler "DW_TAG_typedef\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"T\[^\\r\\n\]*DW_AT_name" } } */
> +
> +typedef struct S { int i; } *T;
> +#define M(p) ((T) (p))
> +
> +void
> +foo (void *p)
> +{
> +  M (p)->i++;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]