[PATCH][debug] Handle debug references to skipped params

Jakub Jelinek jakub@redhat.com
Sun Jul 8 12:22:00 GMT 2018


On Sun, Jul 08, 2018 at 11:22:41AM +0200, Tom de Vries wrote:
> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -5141,6 +5141,10 @@ expand_debug_source_expr (tree exp)
>  
>    switch (TREE_CODE (exp))
>      {
> +    case VAR_DECL:
> +      if (DECL_ABSTRACT_ORIGIN (exp))
> +	return expand_debug_source_expr (DECL_ABSTRACT_ORIGIN (exp));
> +      break;
>      case PARM_DECL:
>        {
>  	mode = DECL_MODE (exp);

This is ok.

> diff --git a/gcc/testsuite/gcc.dg/vla-1.c b/gcc/testsuite/gcc.dg/vla-1.c
> new file mode 100644
> index 00000000000..0c19feffd2b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vla-1.c
> @@ -0,0 +1,25 @@
> +/* { dg-do compile } */
> +/* { dg-options "-g -O3 -fdump-tree-optimized" } */
> +
> +
> +/* One debug source bind is generated for the parameter, and two to describe the
> +   sizes of a and b.  */
> +/* { dg-final { scan-tree-dump-times " s=> i" 3 "optimized" } } */

I think you at least need explicit
-fvar-tracking-assignments -fno-selective-scheduling -fno-selective-scheduling2
and perhaps some guard to ignore the test on nvptx which disables
-fvar-tracking unconditionally?

> diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
> index 427ef959740..6fbd8c3ca61 100644
> --- a/gcc/tree-inline.c
> +++ b/gcc/tree-inline.c
> @@ -208,7 +208,9 @@ remap_ssa_name (tree name, copy_body_data *id)
>  	  n = id->decl_map->get (val);
>  	  if (n != NULL)
>  	    val = *n;
> -	  if (TREE_CODE (val) != PARM_DECL)
> +	  if (TREE_CODE (val) != PARM_DECL
> +	      && !(TREE_CODE (val) == VAR_DECL
> +		   && DECL_ABSTRACT_ORIGIN (val)))
>  	    {
>  	      processing_debug_stmt = -1;
>  	      return name;

Please use VAR_P macro.

	Jakub



More information about the Gcc-patches mailing list