[PATCH] Clarify wording in the LangRef around !invariant.load

Andrew Trick atrick at apple.com
Thu Nov 20 22:11:15 PST 2014


> On Nov 20, 2014, at 7:17 PM, hfinkel at anl.gov wrote:
> 
>> which can be assumed unchanged by any store.
> 
> First, "unchanged by any store" seems redundant (and over-specific); "unchanged" would be fine.
> 
> However, this leaves open the question of when and for how long? Does it imply invariance only during the execution of the function? or must it have the same value during every invocation? At what point does the invariance start?

I think the !invariant.load must imply invariance of the data once the pointer value is available and dereferenceable. i.e. the invariance holds wherever the load can safely execute.

Each invariant load that is dominated by another from the same address must get the same value. That implies that every invocation gets the same value. The key observation that makes this fly is that we can't legitimately compare addresses across objects lifetimes. i.e. If we initialize an object, then mark it invariant, we can't overwrite, then reinitialize that memory and compare addresses. Doing so would break the model. I actually think there is a semantic hole here, but it is something the frontend will just need to live with by using !invariant.load metadata carefully.

-Andy

> 
> ================
> Comment at: docs/LangRef.rst:5216
> @@ -5215,1 +5215,3 @@
> +the location is known dereferenceable along a particular execution
> +path that it's value is henceforth unchanging.  
> 
> ----------------
> it's -> its
> 
> http://reviews.llvm.org/D6346
> 
> 





More information about the llvm-commits mailing list