On Thu, Nov 12, 2020 at 11:39:07AM +0100, Jan Hubicka wrote: > > On Thu, Nov 12, 2020 at 11:29:21AM +0100, Jan Hubicka wrote: > > > > If OEP_ADDRESS is used also on non-addressable stuff, just to compare > > > > that two COMPONENT_REFs access the same memory, then just comparing > > > > DECL_BIT_FIELD_REPRESENTATIVE is not sufficient, you could have: > > > > struct S { int c; int a : 7, b : 1; }; > > > > struct T { int c; int a : 7, b : 1; }; > > > > and compare s->a vs. t->b with OEP_ADDRESS and the offsets of their > > > > DECL_BIT_FIELD_REPRESENATIVE is the same, yet we don't want to say > > > > the two bit-fields are the same. > > > > > > You are right, I was just thinking of that. I suppose it indeed makes > > > more sense to assert that there are no bitfields here and in the AO > > > comparsion take care of stripping the last bitfield reference and > > > handling it specially? > > > > Or just compare DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET of the fields > > rather than their DECL_BIT_FIELD_REPRESENTATIVE? > > I think I will need to compare bitfields specially at the ao_ref_compare > side anyway to distinguish > > struct S { int c; int a : 5, b : 1; }; > struct T { int c; int a : 5, b : 3; }; > > s->b and t->b. Those have same base address (bitwise) but still we do > not want to consider them equal.
How is that different from: struct S { long long d; int e; }; struct T { long long d; long long e; }; s->e vs. t->e ? One thing is comparison of the address (as it is comparing DECL_FIELD_BIT_OFFSET too, it is essentially bit-address), and another thing (unlrelated to OEP_ADDRESS comparisons) is if you need to ensure the access has the same size, in that case you just compare the bit size of the access... Jakub