[llvm-dev] invariant.load metadata semantics
Sanjoy Das via llvm-dev
llvm-dev at lists.llvm.org
Thu Aug 25 16:13:04 PDT 2016
Hi Charles,
Caldarale, Charles R via llvm-dev wrote:
>> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of
Hal Finkel via llvm-dev
>> Subject: Re: [llvm-dev] invariant.load metadata semantics
>
>> Alternatively, we might phrase this as: The optimizer may assume
that all values loaded
>> from a location, where any of the loads are tagged with
!invariant.load, are identical.
>
> 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. This would allow updates to be made to the location of
interest up to the point of declared invariance, but not after.
That is a very defensible point, but depending on your use case you
consider these "initial" writes part of making the memory
dereferenceable. For instance, for us (JVM) loading array lengths
satisfy the requirements of invariant loads, and we bake in the length
of the array as part of the array's allocation routine. LLVM never
"sees" a store the the length field of an array.
However, I can imagine more complex use cases for which the above
approach won't work.
-- Sanjoy
More information about the llvm-dev
mailing list