diff options
| author | Victor Hernandez <vhernandez@apple.com> | 2009-11-03 20:39:35 +0000 | 
|---|---|---|
| committer | Victor Hernandez <vhernandez@apple.com> | 2009-11-03 20:39:35 +0000 | 
| commit | 3318858efd1311b90be4be8cd01b2022d7420769 (patch) | |
| tree | 1fdbba8c6c836f5cc1c8235e7f0141fdb635a916 /llvm/lib/Analysis/MemoryBuiltins.cpp | |
| parent | 7ad36166594cdd5908255395220387a33b84f3bd (diff) | |
| download | llvm-3318858efd1311b90be4be8cd01b2022d7420769.zip llvm-3318858efd1311b90be4be8cd01b2022d7420769.tar.gz llvm-3318858efd1311b90be4be8cd01b2022d7420769.tar.bz2  | |
Changes requested (avoid getFunction(), avoid Type creation via isVoidTy(), and avoid redundant isFreeCall cases) in feedback to r85176
llvm-svn: 85936
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
| -rw-r--r-- | llvm/lib/Analysis/MemoryBuiltins.cpp | 21 | 
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index 47a70d1..e710350 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -33,16 +33,14 @@ static bool isMallocCall(const CallInst *CI) {    if (!CI)      return false; -  const Module *M = CI->getParent()->getParent()->getParent(); -  Function *MallocFunc = M->getFunction("malloc"); - -  if (CI->getOperand(0) != MallocFunc) +  Function *Callee = CI->getCalledFunction(); +  if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "malloc")      return false;    // Check malloc prototype.    // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin     // attribute will exist. -  const FunctionType *FTy = MallocFunc->getFunctionType(); +  const FunctionType *FTy = Callee->getFunctionType();    if (FTy->getNumParams() != 1)      return false;    if (IntegerType *ITy = dyn_cast<IntegerType>(FTy->param_begin()->get())) { @@ -260,22 +258,19 @@ bool llvm::isFreeCall(const Value *I) {    const CallInst *CI = dyn_cast<CallInst>(I);    if (!CI)      return false; - -  const Module *M = CI->getParent()->getParent()->getParent(); -  Function *FreeFunc = M->getFunction("free"); - -  if (CI->getOperand(0) != FreeFunc) +  Function *Callee = CI->getCalledFunction(); +  if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "free")      return false;    // Check free prototype.    // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin     // attribute will exist. -  const FunctionType *FTy = FreeFunc->getFunctionType(); -  if (FTy->getReturnType() != Type::getVoidTy(M->getContext())) +  const FunctionType *FTy = Callee->getFunctionType(); +  if (!FTy->getReturnType()->isVoidTy())      return false;    if (FTy->getNumParams() != 1)      return false; -  if (FTy->param_begin()->get() != Type::getInt8PtrTy(M->getContext())) +  if (FTy->param_begin()->get() != Type::getInt8PtrTy(Callee->getContext()))      return false;    return true;  | 
