[PATCH] D86643: [LangRef] Memset/memcpy/memmove can take undef/poison pointer if the size is 0

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 12:07:54 PDT 2020


jdoerfert added inline comments.


================
Comment at: llvm/docs/LangRef.rst:1161
+    specified alignment, behavior is undefined. ``undef`` and ``poison``
+    pointers have alignment 1.
 
----------------
efriedma wrote:
> aqjune wrote:
> > aqjune wrote:
> > > jdoerfert wrote:
> > > > Unsure if this is needed TBH. Might be confusing.
> > > Would it be better if I move this next to `However, they must still be appropriately aligned.` for a better context?
> > This sentence was added to clarify this case:
> > ```
> > ptr = poison
> > memset(ptr align 1, 0, 0) // UB?
> > ```
> > Since `memset(ptr, 0, 0)` is equivalent to `memset(ptr align 1, 0, 0)`, making the latter non-UB seemed natural to me.
> I think I would rather state it more like "`align 1` has no effect on non-byval arguments", rather than explicitly refer to undef values.  The practical effect is the same, and I think it makes it easier to understand the expected semantics.
Right, everything has an implicit `align 1` anyway, at least that was my thinking so far. So `align 1` is a "no-op" on any pointer value. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86643



More information about the llvm-commits mailing list