[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
Thu May 5 08:53:19 PDT 2022


msebor added inline comments.


================
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();
----------------
msebor wrote:
> 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.
It occurs to me that since the function is also called when folding `wcslen` where the annotation refers to the number of wide characters,  using the word //byte// for the argument isn't entirely accurate.  It should probably be //element// instead (ditto in `annotateDereferenceableBytes`).


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

https://reviews.llvm.org/D124633



More information about the llvm-commits mailing list