[BuildLibCalls][NFC] Remove redundant attribute list from emitCalloc

Additionally with this patch aligned DSE which is the only user of emitCalloc.

Differential Revision: https://reviews.llvm.org/D103523
This commit is contained in:
Dawid Jurczak 2021-08-05 13:01:07 +02:00
parent 95800da914
commit 06206a8cd1
3 changed files with 9 additions and 10 deletions

View File

@ -205,8 +205,8 @@ namespace llvm {
const TargetLibraryInfo *TLI);
/// Emit a call to the calloc function.
Value *emitCalloc(Value *Num, Value *Size, const AttributeList &Attrs,
IRBuilderBase &B, const TargetLibraryInfo &TLI);
Value *emitCalloc(Value *Num, Value *Size, IRBuilderBase &B,
const TargetLibraryInfo &TLI);
}
#endif

View File

@ -1856,10 +1856,9 @@ struct DSEState {
memoryIsNotModifiedBetween(Malloc, MemSet, BatchAA, DL, &DT)) {
IRBuilder<> IRB(Malloc);
const auto &DL = Malloc->getModule()->getDataLayout();
AttributeList EmptyList;
if (auto *Calloc = emitCalloc(
ConstantInt::get(IRB.getIntPtrTy(DL), 1),
Malloc->getArgOperand(0), EmptyList, IRB, TLI)) {
if (auto *Calloc =
emitCalloc(ConstantInt::get(IRB.getIntPtrTy(DL), 1),
Malloc->getArgOperand(0), IRB, TLI)) {
MemorySSAUpdater Updater(&MSSA);
auto *LastDef = cast<MemoryDef>(
Updater.getMemorySSA()->getMemoryAccess(Malloc));

View File

@ -1655,8 +1655,8 @@ Value *llvm::emitMalloc(Value *Num, IRBuilderBase &B, const DataLayout &DL,
return CI;
}
Value *llvm::emitCalloc(Value *Num, Value *Size, const AttributeList &Attrs,
IRBuilderBase &B, const TargetLibraryInfo &TLI) {
Value *llvm::emitCalloc(Value *Num, Value *Size, IRBuilderBase &B,
const TargetLibraryInfo &TLI) {
if (!TLI.has(LibFunc_calloc))
return nullptr;
@ -1664,8 +1664,8 @@ Value *llvm::emitCalloc(Value *Num, Value *Size, const AttributeList &Attrs,
StringRef CallocName = TLI.getName(LibFunc_calloc);
const DataLayout &DL = M->getDataLayout();
IntegerType *PtrType = DL.getIntPtrType((B.GetInsertBlock()->getContext()));
FunctionCallee Calloc = M->getOrInsertFunction(
CallocName, Attrs, B.getInt8PtrTy(), PtrType, PtrType);
FunctionCallee Calloc =
M->getOrInsertFunction(CallocName, B.getInt8PtrTy(), PtrType, PtrType);
inferLibFuncAttributes(M, CallocName, TLI);
CallInst *CI = B.CreateCall(Calloc, {Num, Size}, CallocName);