/// Tests if a function is a call or invoke to a library function that
/// reallocates memory (e.g., realloc).
-bool isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI);
+bool isReallocLikeFn(const Function *F);
/// If this is a call to a realloc function, return the reallocated operand.
-Value *getReallocatedOperand(const CallBase *CB, const TargetLibraryInfo *TLI);
+Value *getReallocatedOperand(const CallBase *CB);
//===----------------------------------------------------------------------===//
// free Call Utility Functions.
/// Tests if a functions is a call or invoke to a library function that
/// reallocates memory (e.g., realloc).
-bool llvm::isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI) {
+bool llvm::isReallocLikeFn(const Function *F) {
return checkFnAllocKind(F, AllocFnKind::Realloc);
}
-Value *llvm::getReallocatedOperand(const CallBase *CB,
- const TargetLibraryInfo *TLI) {
+Value *llvm::getReallocatedOperand(const CallBase *CB) {
if (checkFnAllocKind(CB, AllocFnKind::Realloc))
return CB->getArgOperandWithAttribute(Attribute::AllocatedPointer);
return nullptr;
continue;
}
- if (getReallocatedOperand(cast<CallBase>(I), &TLI) == PI &&
+ if (getReallocatedOperand(cast<CallBase>(I)) == PI &&
getAllocationFamily(I, &TLI) == Family) {
assert(Family);
Users.emplace_back(I);
// realloc() entirely.
CallInst *CI = dyn_cast<CallInst>(Op);
if (CI && CI->hasOneUse())
- if (Value *ReallocatedOp = getReallocatedOperand(CI, &TLI))
+ if (Value *ReallocatedOp = getReallocatedOperand(CI))
return eraseInstFromFunction(*replaceInstUsesWith(*CI, ReallocatedOp));
// If we optimize for code size, try to move the call to free before the null
}
// We have to do this step after AllocKind has been inferred on functions so
// we can reliably identify free-like and realloc-like functions.
- if (!isLibFreeFunction(&F, TheLibFunc) && !isReallocLikeFn(&F, &TLI))
+ if (!isLibFreeFunction(&F, TheLibFunc) && !isReallocLikeFn(&F))
Changed |= setDoesNotFreeMemory(F);
return Changed;
}