[PATCH] D47854: [LangRef] Clarify semantics of load metadata.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 11 03:37:09 PDT 2018


hfinkel added inline comments.


================
Comment at: docs/LangRef.rst:7941
+program where the memory location is known to be dereferenceable;
+otherwise, the behavior is undefined.
 
----------------
nlopes wrote:
> aqjune wrote:
> > Hello, I have a minor question - is undefined behavior raised at the point when the load is executed? I wonder whether load with !invariant.load can be hoisted out of a loop (as in Nuno's example), even if the loaded value is actually not invariant.
> The way the sentence is written implies that !invariant.load needs to be stripped on hoisting. I grepped around and I saw very few cases where it is used. But I guess we cannot change the semantics to be "it has the same value always" since that would mean that memory region is constant instead, and that's not what we want.
> So, I guess UB is fine, but we need to strip it on hoisting.
> But I guess we cannot change the semantics to be "it has the same value always" since that would mean that memory region is constant instead, and that's not what we want.

Are you sure? I'm under the impression that this is used to indicate things like loads from constant memories on GPUs. I think that we should support hoisting without stripping for this. Granted, however, it means that there can't be any control dependencies on the validity of the metadata. If we have both kinds of use cases, then we'll need to introduce some way to distinguish them.



Repository:
  rL LLVM

https://reviews.llvm.org/D47854





More information about the llvm-commits mailing list