This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch ping
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: Jan Hubicka <jh at suse dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 26 Jul 2017 19:31:03 +0200
- Subject: Re: Patch ping
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5583285D0
- References: <20170725094050.GR2123@tucnak> <alpine.LSU.2.20.1707261222220.10808@zhemvz.fhfr.qr> <20170726134715.GW2123@tucnak> <alpine.LSU.2.20.1707261609580.10808@zhemvz.fhfr.qr>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jul 26, 2017 at 04:13:30PM +0200, Richard Biener wrote:
> > > You don't seem to use 'size' anywhere.
> >
> > size I thought about but then decided not to do anything with it.
> > There are two cases, one is where there is no ADDR_EXPR and it actually
> > a memory reference.
> > In that case in theory the size could be used, but it would need
> > to be used only for the positive offsets, so like:
> > if (off > 0) {
> > if (ptr + off + size < ptr)
> > runtime_fail;
> > } else if (ptr + off > ptr)
> > runtime_fail;
> > but when it is actually a memory reference, I suppose it will fail
> > at runtime anyway when performing such an access, so I think it is
> > unnecessary. And for the ADDR_EXPR case, the size is irrelevant, we
> > are just taking address of the start of the object.
> >
> > > You fail to allow other handled components -- for no good reason?
> >
> > I was trying to have a quick bail out. What other handled components might
> > be relevant? I guess IMAGPART_EXPR. For say BIT_FIELD_REF I don't think
> > I can
> > tree ptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
>
> REALPART/IMAGPART_EXPR, yes. You can't address BIT_FIELD_REF
> apart those on byte boundary (&vector[4] is eventually folded to
> a BIT_FIELD_REF). Similar for VIEW_CONVERT_EXPR, but you are
> only building the address on the base?
>
> > > You fail to handle
> > > &MEM[ptr + CST] a canonical gimple invariant way of ptr +p CST,
> > > the early out bitpos == 0 will cause non-instrumentation here.
> >
> > Guess I could use:
> > if ((offset == NULL_TREE
> > && bitpos == 0
> > && (TREE_CODE (inner) != MEM_REF
> > || integer_zerop (TREE_OPERAND (inner, 1))))
> > The rest of the code will handle it.
>
> Yeah.
>
> >
> > > (I'd just round down in the case of bitpos % BITS_PER_UNIT != 0)
> >
> > But then the
> > tree ptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
> > won't work again.
>
> Hmm. So instead of building the address on the original tree you
> could build the difference based on what get_inner_reference returns
> in bitpos/offset?
I'm building both addresses and subtracting them to get the offset.
I guess the other option is to compute just the address of the base
(i.e. base_addr), and add offset (if non-NULL) plus bitpos / BITS_PER_UNIT
plus offset from the MEM_REF (if any). In that case it would probably
handle any handled_component_p and bitfields too.
Jakub