Skip to content

Commit

Permalink
[MemoryBuiltins] Remove unused TLI parameters (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Dec 9, 2022
1 parent 9d72444 commit b3df1ce
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/MemoryBuiltins.h
Expand Up @@ -70,10 +70,10 @@ bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI);

/// 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.
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Analysis/MemoryBuiltins.cpp
Expand Up @@ -317,12 +317,11 @@ bool llvm::isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI) {

/// 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;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Expand Up @@ -2793,7 +2793,7 @@ static bool isAllocSiteRemovable(Instruction *AI,
continue;
}

if (getReallocatedOperand(cast<CallBase>(I), &TLI) == PI &&
if (getReallocatedOperand(cast<CallBase>(I)) == PI &&
getAllocationFamily(I, &TLI) == Family) {
assert(Family);
Users.emplace_back(I);
Expand Down Expand Up @@ -3037,7 +3037,7 @@ Instruction *InstCombinerImpl::visitFree(CallInst &FI, Value *Op) {
// 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
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/BuildLibCalls.cpp
Expand Up @@ -1228,7 +1228,7 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
}
// 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;
}
Expand Down

0 comments on commit b3df1ce

Please sign in to comment.