[llvm-dev] invariant.load metadata semantics

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 25 13:11:27 PDT 2016

Hi Hal,

Hal Finkel via llvm-dev wrote:
 > I agree.
 > Regarding the proposed text, I find the "since it became
 > dereferenceable" phrase ambiguous. Further, I think we can say something
 > stronger: Storing into a location previously loaded using a load tagged
 > with !invariant.load is undefined behavior.

That prevents doing the optimization Geoff suggested:

   int k = *ptr;
   int k2 = *ptr; // invariant


   int k = *ptr;
   int k2 = k;

since clobber(), given what you said, could have legitimately changed
the contents of ptr.

-- Sanjoy

More information about the llvm-dev mailing list