[PATCH] D124633: [SimplifyLibCalls] Pointers passed to libcalls must point to valid objects

Martin Sebor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 11:35:34 PDT 2022


msebor added a comment.

Just to confirm your understanding of what GCC does: it relies on attribute `nonnull` on function (and function pointer) declarations to eliminate redundant null pointer tests subsequent to calls to such functions (with `-fdelete-null-pointer-checks`).



================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:155
 static void annotateNonNullNoUndefBasedOnAccess(CallInst *CI,
-                                         ArrayRef<unsigned> ArgNos) {
+                                         ArrayRef<unsigned> ArgNos, bool MinDereferenceableBytes = 1) {
   Function *F = CI->getCaller();
----------------
It seems that for a `bool` the default ought  to `true` rather than 1 (ditto for the actual argument at the call sites); a better name for the argument would also reflect the fact it's a toggle rather than a count.

But I wonder if changing the last argument to something like `Value *MinBytes = nullptr` and computing the Boolean result from it here would be a way to simplify the code and avoid having to do that at the call site.


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

https://reviews.llvm.org/D124633



More information about the llvm-commits mailing list