[PATCH] D95122: [Libcalls, Attrs] Annotate libcalls with noundef

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 08:14:14 PST 2021


aqjune added a comment.

Okay, I think the situation is a bit complex. :/
Conceptually, for library functions that can be introduced by optimizations, noundef cannot be attached unless it is proven to be noundef; it can make the program more undefined due to the existence of partially undefined pointers.
A problem is that sometimes it isn't clear whether a library function is introduced by optimizations or not. ExpandMemCmp can introduce memcmp and MemCpyOptimizer can introduce memset/memcpy, so they shouldn't have noundef attached in general. But, for other functions (except fns like printf that have a side-effect), I don't think it is clear.

I think a safer way is to make clang frontend attach noundef to the pointer argument of memcmp/memset/memcpy/.... calls when emitting them. Does it have the same optimization power in practice, or still SimplifyLibCalls allows more optimizations?


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

https://reviews.llvm.org/D95122



More information about the llvm-commits mailing list