[llvm-dev] invariant.load metadata semantics

Caldarale, Charles R via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 25 14:08:12 PDT 2016


> From: Daniel Berlin [mailto:dberlin at dberlin.org] 
> Subject: Re: [llvm-dev] invariant.load metadata semantics

> > This would seem to limit the usefulness of the invariant attribute.  I would expect invariant 
> > to indicate that loads reachable from the one marked invariant are guaranteed to read the same 
> > value, but that prior ones are not. 

> Define "reachable".

> Do you mean there is any path from the load to the new load?

Yes.

> If so, what about loop backedges?

Depends on the details of the desired semantic definition.  The conservative approach would be to drop the invariance; could also declare the situation to be UB and perhaps catch it in the verifier.
 
> > This would allow updates to be made to the location of interest up to the point of declared 
> > invariance, but not after.

> This has the same problem.

> for loop:
>  store a
>  load a !invariant.load

> Legal or not if we can prove the loop iterates >1 time?
> What does it mean?

See above.  My (slight) preference is to treat it as UB, but that might be a bit strong, considering this is metadata.

 - Chuck



More information about the llvm-dev mailing list