[PATCH] D50039: [LibCalls] Added nonnull atribute to libc function args

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 26 11:59:23 PDT 2018


efriedma added a comment.

I'm still concerned that this doesn't really interact appropriately with -fno-delete-null-pointer-checks... specifically, the nonnull markings could cause unexpected optimizations.  I mean, it's sort of dubious to use -fno-delete-null-pointer-checks without -ffreestanding anyway, given that many C library APIs special-case null, but we should still try to make it work as well as we can.  I think we can solve that problem by changing how the nonnull markings are implemented: instead of marking the functions themselves as non-null, we should mark calls to those functions (as long as the calls are not in "null-pointer-is-valid" functions).

In terms of splitting the patch, yes, it probably makes sense to split into markings for char* pointers, and markings for other pointers.



================
Comment at: lib/Transforms/Utils/BuildLibCalls.cpp:272
     Changed |= setOnlyReadsMemory(F, 1);
+    Changed |= setArgNotNull(F, 1);
     return Changed;
----------------
For sprintf, I think we can mark both 0 and 1.


https://reviews.llvm.org/D50039





More information about the llvm-commits mailing list