[PATCH] D66651: Annotate return values of allocation functions with dereferenceable_or_null
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 07:59:41 PDT 2019
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.
================
Comment at: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp:4200
+ Call.getContext(), Op1C->getZExtValue()));
+ } else if (isCallocLikeFn(&Call, TLI) && Op0C && Op1C) {
+ bool Overflow;
----------------
xbolva00 wrote:
> xbolva00 wrote:
> > jdoerfert wrote:
> > > What if one is NULL but the other not? Will `getWithDereferenceableOrNullBytes(0)` do the right thing?
> > Maybe isNullValue confused you. isNullValue means just CstInt->getValue() == 0.
> >
> > if Op0C is NULL -> no calloc annotation
> > if Op1C is NULL -> no calloc annotation
> >
> > if Op0C is '0' -> no annotation; see
> > if ((Op0C && Op0C->isNullValue()) || (Op1C && Op1C->isNullValue()))
> > return;
> >
> > Same for Op1C.
> I will add a comment like
>
> // Bail out if the allocation size is zero.
> if ((Op0C && Op0C->isNullValue()) || (Op1C && Op1C->isNullValue()))
> return;
Aha, I know what do you mean.
Hmm, it could work for calloc case - I will look on it.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66651/new/
https://reviews.llvm.org/D66651
More information about the llvm-commits
mailing list