[llvm-dev] invariant.load metadata semantics

Hal Finkel via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 25 13:13:25 PDT 2016


----- Original Message -----
> From: "Sanjoy Das" <sanjoy at playingwithpointers.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "Geoff Berry" <gberry at codeaurora.org>, "llvm-dev" <llvm-dev at lists.llvm.org>
> Sent: Thursday, August 25, 2016 3:11:27 PM
> Subject: Re: [llvm-dev] invariant.load metadata semantics
> 
> 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;
>    clobber();
>    int k2 = *ptr; // invariant
> 
> ==>
> 
>    int k = *ptr;
>    clobber();
>    int k2 = k;
> 
> since clobber(), given what you said, could have legitimately changed
> the contents of ptr.

I agree this is undesirable; see my second suggestion ;)

 -Hal

> 
> -- Sanjoy
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-dev mailing list