From cb348b9b45025393ec5b28eac8bb6773a9b603f6 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 3 May 2012 22:08:19 +0000 Subject: remove calls to calloc if the allocated memory is not used (it was already being done for malloc) fix a few typos found by Chad in my previous commit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156110 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/MemoryBuiltins.cpp | 4 ++-- lib/Transforms/InstCombine/InstCombineCalls.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp index 347a7ea..9695ae1 100644 --- a/lib/Analysis/MemoryBuiltins.cpp +++ b/lib/Analysis/MemoryBuiltins.cpp @@ -182,7 +182,7 @@ Value *llvm::getMallocArraySize(CallInst *CI, const TargetData *TD, //===----------------------------------------------------------------------===// -// clloc Call Utility Functions. +// calloc Call Utility Functions. // static bool isCallocCall(const CallInst *CI) { @@ -197,7 +197,7 @@ static bool isCallocCall(const CallInst *CI) { // Check malloc prototype. // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin - // attribute will exist. + // attribute exists. FunctionType *FTy = Callee->getFunctionType(); return FTy->getReturnType() == Type::getInt8PtrTy(FTy->getContext()) && FTy->getNumParams() == 2 && diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 4196ca6..5fdb57b 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -172,7 +172,7 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) { Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (isFreeCall(&CI)) return visitFree(CI); - if (isMalloc(&CI)) + if (extractMallocCall(&CI) || extractCallocCall(&CI)) return visitMalloc(CI); // If the caller function is nounwind, mark the call as nounwind, even if the -- cgit v1.1