Re: [PATCH] [FIX] Remove object adjustment to preserve object attributes

2020-08-20 Thread Petro Karashchenko via Gcc-patches
Hello Ricard!

Thank you very much for your reply.
The case is that currently the "uncached" attribute is used to generate
special "cache bypass" instructions instead of regular one by ARC backend.
That decision is made based on the result of "lookup_attribute()" call for
a specified MEM_REF. For example
  if (TREE_CODE (addr) == MEM_REF)
{
  attrs = TYPE_ATTRIBUTES (TREE_TYPE (TREE_OPERAND (addr, 0)));
  if (lookup_attribute ("uncached", attrs))
return true;
  attrs = TYPE_ATTRIBUTES (TREE_TYPE (TREE_OPERAND (addr, 1)));
  if (lookup_attribute ("uncached", attrs))
return true;
}

That works pretty well for aligned types, but for unaligned/packed types
(also for example for array -X access) the expression is dropped. In my
test example with current code the "a1" will still inherit "uncached"
attribute because "adjust_object" will not be done, but "a2", "a3" and "a4"
will drop expression, hence "uncached" attribute can't be accessed.

Does that make sense?

Maybe we can clone/copy expression instead of dropping to preserve
"uncached" attribute?

Best Regards,
Petro Karashchenko

чт, 20 серп. 2020 о 11:01 Richard Sandiford 
пише:

> Petro Karashchenko via Gcc-patches  writes:
> > for bitfield MEMREFs
> >
> > [FIX] Propagate uncached type attributes to unaligned/packed types
>
> This doesn't look safe in general.  The current code was added
> to avoid wrong-code problems for accesses that step outside the
> bounds of the original MEM_EXPR.
>
> Could you explain in more detail what's going wrong in the testcase?
> It wasn't obvious why the code you're removing would trigger for that test.
>
> Thanks,
> Richard
>
> >
> > [ARC] Update tests
> >
> > gcc/
> > -xx-xx  Petro Karashchenko  
> >
> > * emit-rtl.c (adjust_address_1): Do not drop the object
> > if the new memory reference is outside the underlying
> > object to preserve object attributes that are needed
> > by some backend implementations. Remove adjust_object
> > parameter as it is not used anymore.
> > (adjust_automodify_address_1): Adjust according to
> > new adjust_address_1 prototype.
> > (replace_equiv_address_nv): Likewise.
> > * gcc/emit-rtl.h (adjust_address): Adjust according to
> > new adjust_address_1 prototype.
> > (adjust_address_nv): Likewise.
> > (adjust_bitfield_address): Likewise.
> > (adjust_bitfield_address_size): Likewise.
> > (adjust_bitfield_address_nv): Likewise.
> >
> > testsuite/
> > -xx-xx  Petro Karashchenko  
> >
> > * gcc.target/arc/uncached-9.c: New file.
> >
> > Problem description:
> > __attribute__((uncached)) is dropped for other than the first member of
> > "packed" or "unaligned" types.
> >
> > Tests:
> > Tested with ARC600 bases ASIC. The correct code is generated.
> >
> > From 1f8a824f8ed8c1452f2bdfc513716c63d5d12545 Mon Sep 17 00:00:00 2001
> > From: Petro Karashchenko 
> > Date: Sun, 16 Aug 2020 01:10:11 +0300
> > Subject: [PATCH] [FIX] Remove object adjustment to preserve object
> attributes
> >  for bitfield MEMREFs
> >
> > [FIX] Propagate uncached type attributes to unaligned/packed types
> >
> > [ARC] Update tests
> >
> > gcc/
> > -xx-xx  Petro Karashchenko  
> >
> > * emit-rtl.c (adjust_address_1): Do not drop the object
> > if the new memory reference is outside the underlying
> > object to preserve object attributes that are needed
> > by some backend implementations. Remove adjust_object
> > parameter as it is not used anymore.
> > (adjust_automodify_address_1): Adjust according to
> > new adjust_address_1 prototype.
> > (replace_equiv_address_nv): Likewise.
> > * gcc/emit-rtl.h (adjust_address): Adjust according to
> > new adjust_address_1 prototype.
> > (adjust_address_nv): Likewise.
> > (adjust_bitfield_address): Likewise.
> > (adjust_bitfield_address_size): Likewise.
> > (adjust_bitfield_address_nv): Likewise.
> >
> > testsuite/
> > -xx-xx  Petro Karashchenko  
> >
> > * gcc.target/arc/uncached-9.c: New file.
> >
> > Signed-off-by: Petro Karashchenko 
> > ---
> >  gcc/emit-rtl.c| 28 +++
> >  gcc/emit-rtl.h  

[PATCH] [FIX] Remove object adjustment to preserve object attributes

2020-08-15 Thread Petro Karashchenko via Gcc-patches
for bitfield MEMREFs

[FIX] Propagate uncached type attributes to unaligned/packed types

[ARC] Update tests

gcc/
-xx-xx  Petro Karashchenko  

* emit-rtl.c (adjust_address_1): Do not drop the object
if the new memory reference is outside the underlying
object to preserve object attributes that are needed
by some backend implementations. Remove adjust_object
parameter as it is not used anymore.
(adjust_automodify_address_1): Adjust according to
new adjust_address_1 prototype.
(replace_equiv_address_nv): Likewise.
* gcc/emit-rtl.h (adjust_address): Adjust according to
new adjust_address_1 prototype.
(adjust_address_nv): Likewise.
(adjust_bitfield_address): Likewise.
(adjust_bitfield_address_size): Likewise.
(adjust_bitfield_address_nv): Likewise.

testsuite/
-xx-xx  Petro Karashchenko  

* gcc.target/arc/uncached-9.c: New file.

Problem description:
__attribute__((uncached)) is dropped for other than the first member of
"packed" or "unaligned" types.

Tests:
Tested with ARC600 bases ASIC. The correct code is generated.


0001-FIX-Remove-object-adjustment-to-preserve-object-attr.patch
Description: Binary data