[PATCH] D95238: [LangRef] Update memory access ops to raise UB if ptrs are not well defined

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 24 18:06:36 PST 2021


aqjune added inline comments.


================
Comment at: llvm/docs/LangRef.rst:12697
+If ``<len>`` is 0, the pointers may be NULL, dangling, ``undef``, or ``poison``
 pointers. However, they must still be appropriately aligned.
+If ``<len>`` is not a well-defined value, the behavior is undefined.
----------------
jdoerfert wrote:
> Partially related: I never understood the alignment thing. `undef` and `poison` are not aligned. Violating `align` should result in a `poison` value, which we had in the first place. We should check why this is her.
Initially, the constraint of alignment was introduced by D57600 after the discussion at https://bugs.llvm.org/show_bug.cgi?id=38583 .

Then, the semantics of passing undef/poison pointers to memcpy/memset was clarified by D86643.
At that point, violation of align attribute was still undefined behavior.

Then, D90529 updated the semantics of align to return poison instead.
Now, align attribute has no effect if the size is zero (unless noundef is there too).

I fixed the sentences here to be modular w.r.t. the semantics of attributes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95238/new/

https://reviews.llvm.org/D95238



More information about the llvm-commits mailing list