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

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 11 03:22:40 PDT 2018


nlopes added inline comments.


================
Comment at: docs/LangRef.rst:7941
+program where the memory location is known to be dereferenceable;
+otherwise, the behavior is undefined.
 
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D47854





More information about the llvm-commits mailing list