[LLVMdev] Upcoming Changes/Additions to Scoped-NoAlias metadata

Raul Silvera rsilvera at google.com
Tue Nov 18 19:09:40 PST 2014


>
>
> I preserve them only weakly... I don't want full barriers; in fact, I plan
> to add InstCombine code to combine calls to @llvm.noalias (it will also
> take a list of scopes, not just one, so this is possible). The goal is to
> have as few barriers as possible.


Good.

> > Going further, logically the intrinsic should return a pointer to a
> > > new object, disjoint from all other live objects. It is not aliased
> > > to A, and is well defined even if it contains &A because A is not
> > > referenced in the scope.
> >
> > This is essentially what is done, but only for accesses in the scope
> > (or some sub-scope). I don't think the semantics allow for what
> > you're suggesting. The specific language from 6.7.3.1p4 says:
> >
> > [from C]
> > During each execution of B, let L be any lvalue that has &L based on
> > P. If L is used to
> > access the value of the object X that it designates, ...,
> > then the following requirements apply: ... Every other lvalue
> > used to access the value of X shall also have its address based on P.
> > [end from C]
> >
> > Where B is defined in 6.7.3.1p2 to be, essentially, the block in
> > which the relevant declaration appears. And we can really only
> > extrapolate from that to the other access in that block, and not to
> > the containing block.
> >
> >
> > Inside that block
> > (the lifetime of P) , it is safe to assume that X is
> > disjoint from an arbitrary live object
> >  A. It if was
> >
> > n't
> >  , either:
> > - A is independently referenced inside the block, so there is UB and
> > all bets are off.
> > - A is not independently referenced inside the blo ck,
> > so t here are no pairs of accesses to incorrectly reorder as all
> > accesses to A in
> >  the block are done through P. You just need to delimit the block
> >  with dataflow barriers
> > , summar iz
> > ing the effect of the block at entry/exit.
>
> Okay, I think I agree with you assuming that we put in entry/exit barriers
> to preserve the block boundaries. I'd specifically like to avoid that,
> however.
>

I'm not proposing full code motion barriers, only punctual dataflow
use/defs to signal entry/exit to the scope.

Logically, entering the scope transfers the pointed data into a new unique
block of memory, and puts its address on the restrict pointer. Exiting the
scope transfers it back. Of course you do not want to actually allocate a
new object and move the data, but you can use these semantics to define the
scope entry/exit intrinsics. Their contribution to dataflow is only limited
to the content of the address used to initialize the restricted pointer.
These would be lighter than the proposed intrinsic as they would not have
specialized control-flow ​restrictions.

This approach makes the restrict attribute effective against all live
variables without having to examine the extent of the scope to collect all
references, which is in general impractical. It also removes the need for
scope metadata, as there would be no need to name the scopes.

Anyway, this is just a general alternate design, since you were asking for
one. I'm sure still would take some time/effort to map it onto the LLVM
framework.

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141118/22a4994c/attachment.html>


More information about the llvm-dev mailing list