RFC: VTA alias set discrepancy

Richard Guenther richard.guenther@gmail.com
Thu Mar 18 16:43:00 GMT 2010


On Thu, Mar 18, 2010 at 4:33 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> On Thu, Mar 18, 2010 at 04:08:13PM +0100, Jakub Jelinek wrote:
>> Hi!
>>
>> 1) as cfgexpand.c will need to call the same function, the new routine
>> shouldn't live in dwarf2out.c, instead varasm.c or cfgexpand.c
>> 2) I wouldn't do this conditionally on flag_compare_debug, make_decl_rtl
>> doesn't need to be called at all in -g0 case and I think we should better
>> avoid having any aliasing changes.
>
> Fixed.
>
> Like this?
>
>        * output.h: Declare make_decl_rtl_for_debug.
>        * varasm.c (make_decl_rtl_for_debug): New.
>        * dwarf2out.c (rtl_for_decl_location): Call it.
>
> Index: testsuite/gfortran.dg/assign-debug.f90
> ===================================================================
> --- testsuite/gfortran.dg/assign-debug.f90      (revision 0)
> +++ testsuite/gfortran.dg/assign-debug.f90      (revision 0)
> @@ -0,0 +1,8 @@
> +! { dg-do compile }
> +! { dg-options "-fcompare-debug -O2" }
> +      program test
> +      integer i
> +      common i
> +      assign 2000 to i  ! { dg-warning "Deleted feature: ASSIGN statement" }
> +2000  continue
> +      end
> Index: dwarf2out.c
> ===================================================================
> --- dwarf2out.c (revision 157481)
> +++ dwarf2out.c (working copy)
> @@ -15770,10 +15770,7 @@ rtl_for_decl_location (tree decl)
>       && !DECL_HARD_REGISTER (decl)
>       && DECL_MODE (decl) != VOIDmode)
>     {
> -      rtl = DECL_RTL (decl);
> -      /* Reset DECL_RTL back, as various parts of the compiler expects
> -        DECL_RTL set meaning it is actually going to be output.  */
> -      SET_DECL_RTL (decl, NULL);
> +      rtl = make_decl_rtl_for_debug (decl);
>       if (!MEM_P (rtl)
>          || GET_CODE (XEXP (rtl, 0)) != SYMBOL_REF
>          || SYMBOL_REF_DECL (XEXP (rtl, 0)) != decl)
> Index: varasm.c
> ===================================================================
> --- varasm.c    (revision 157481)
> +++ varasm.c    (working copy)
> @@ -1476,6 +1476,35 @@ make_decl_rtl (tree decl)
>   if (flag_mudflap && TREE_CODE (decl) == VAR_DECL)
>     mudflap_enqueue_decl (decl);
>  }
> +
> +/* Like make_decl_rtl, but inhibit creation of new alias sets when
> +   calling make_decl_rtl.  Also, reset DECL_RTL before returning the
> +   rtl.  */
> +
> +rtx
> +make_decl_rtl_for_debug (tree decl)
> +{
> +  unsigned int save_aliasing_flag;
> +  rtx rtl;

While existing callers are under !DECL_RTL_SET_P it is not obvious
that that is true here, so please add

  if (DECL_RTL_SET_P (decl))
    return DECL_RTL (decl);

here.

Please also adjust cfgexpand.c:expand_debug_expr (just see
where we do SET_DECL_RTL (.., NULL)).

Ok with that changes.

Thanks,
Richard.

> +  /* Kludge alert!  Somewhere down the call chain, make_decl_rtl will
> +     call new_alias_set.  If running with -fcompare-debug, sometimes
> +     we do not want to create alias sets that will throw the alias
> +     numbers off in the comparison dumps.  So... clearing
> +     flag_strict_aliasing will keep new_alias_set() from creating a
> +     new set.  */
> +  save_aliasing_flag = flag_strict_aliasing;
> +  flag_strict_aliasing = 0;
> +
> +  rtl = DECL_RTL (decl);
> +  /* Reset DECL_RTL back, as various parts of the compiler expects
> +     DECL_RTL set meaning it is actually going to be output.  */
> +  SET_DECL_RTL (decl, NULL);
> +
> +  flag_strict_aliasing = save_aliasing_flag;
> +
> +  return rtl;
> +}
>
>  /* Output a string of literal assembler code
>    for an `asm' keyword used between functions.  */
> Index: output.h
> ===================================================================
> --- output.h    (revision 157481)
> +++ output.h    (working copy)
> @@ -318,6 +318,10 @@ extern bool initializer_constant_valid_f
>    ALIGN is the alignment in bits that may be assumed for the data.  */
>  extern void output_constant (tree, unsigned HOST_WIDE_INT, unsigned int);
>
> +extern rtx make_decl_rtl_for_debug (tree);
> +
> +/* End of functions in varasm.c.  */
> +
>  /* When outputting delayed branch sequences, this rtx holds the
>    sequence being output.  It is null when no delayed branch
>    sequence is being output, so it can be used as a test in the
>



More information about the Gcc-patches mailing list