[llvm-commits] [PATCH] extend analysis passes to treat malloc calls the same as MallocInst (patch #2)
Eli Friedman
eli.friedman at gmail.com
Fri Sep 18 11:41:38 PDT 2009
On Fri, Sep 18, 2009 at 8:55 AM, Victor Hernandez <vhernandez at apple.com> wrote:
> How is this?
> @@ -111,6 +112,12 @@
> AccessTy = AI->getType()->getElementType();
> else
> return false;
> + } else if (const CallInst* CI = extractMallocCall(V)) {
> + if (!isArrayMalloc(V))
> + // The size is the argument to the malloc call.
> + if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(1)))
> + return (C->getZExtValue() < Size);
> + return false;
> } else if (const Argument *A = dyn_cast<Argument>(V)) {
> if (A->hasByValAttr())
> AccessTy = cast<PointerType>(A->getType())->getElementType();
Looks fine.
-Eli
More information about the llvm-commits
mailing list