[PATCH] D50039: [LibCalls] Added nonnull atribute to libc function args
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 31 13:59:47 PDT 2018
xbolva00 added a subscriber: rsmith.
xbolva00 added a comment.
In https://reviews.llvm.org/D50039#1183214, @efriedma wrote:
> I don't think we can reasonably do this for the functions which take a pointer+size pair; see http://lists.llvm.org/pipermail/cfe-dev/2017-January/052066.html etc. Maybe we can mark specific calls where we know the size is nonzero.
>
> Not sure how this should interact with -fno-delete-null-pointer-checks; maybe we can make that work "correctly" by just doing all our nonnull marking on individual calls, even for the functions which take null-terminated strings.
so @rsmith 's list is what we want to follow for this type of transformation?
ISO C:
memcpy, memmove, memset, memcmp, memchr, memrchr
strncpy [param 1 only], strncat [param 1 only], strncmp
Extensions:
strndup, memccpy, mempcpy, strnlen, bcopy, bzero, bcmp, memfrob,
strncasecmp, strncasecmp_l [not parameter 4], stpncpy
Side note: GCC has no problem to optimize/remove condition (maybe we have already ubsan checker for 0/null for mem* functions, or maybe is under development, I saw it somewhere)
int foo(void *p, int n) {
memset(p, 0, n);
if (!p)
abort();
return 1;
}
Repository:
rL LLVM
https://reviews.llvm.org/D50039
More information about the llvm-commits
mailing list