[PATCH] D66651: Annotate return values of allocation functions with dereferenceable_or_null
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 09:43:14 PDT 2019
jdoerfert added a comment.
Two last comments from my side.
================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:4183
+ if (!CI)
+ return;
+ ConstantInt *Op0C = dyn_cast<ConstantInt>(CI->getOperand(0));
----------------
What is wrong with invoke?
================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:4187
+ ? nullptr
+ : dyn_cast<ConstantInt>(CI->getOperand(1));
+ if (isMallocLikeFn(CI, TLI) && Op0C && !Op0C->isNullValue()) {
----------------
You can "speed things up" if you check Op0C and Op1C for null first (early exit). At least one has to be nonnull and its value as well. Also below, the isXXXX check is more expensive so we should first check the operands.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66651/new/
https://reviews.llvm.org/D66651
More information about the llvm-commits
mailing list