[llvm] [polly] [IRBuilder] Remove unused AllocTy argument (PR #222667)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 07:11:02 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Nikita Popov (nikic)
<details>
<summary>Changes</summary>
This argument is not used at all. The size is explicitly passed in a separate argument.
---
Full diff: https://github.com/llvm/llvm-project/pull/222667.diff
6 Files Affected:
- (modified) llvm/examples/BrainF/BrainF.cpp (+1-2)
- (modified) llvm/include/llvm/IR/IRBuilder.h (+6-8)
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+2-2)
- (modified) llvm/lib/IR/Core.cpp (+3-4)
- (modified) llvm/lib/IR/IRBuilder.cpp (+6-7)
- (modified) polly/lib/CodeGen/IslNodeBuilder.cpp (+1-2)
``````````diff
diff --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp
index 14e135eb464c8..f4c7804dc8109 100644
--- a/llvm/examples/BrainF/BrainF.cpp
+++ b/llvm/examples/BrainF/BrainF.cpp
@@ -91,8 +91,7 @@ void BrainF::header(LLVMContext& C) {
Type* IntPtrTy = IntegerType::getInt32Ty(C);
Type* Int8Ty = IntegerType::getInt8Ty(C);
Constant* allocsize = ConstantInt::get(IntPtrTy, 1);
- ptr_arr = builder->CreateMalloc(IntPtrTy, Int8Ty, allocsize, val_mem, nullptr,
- "arr");
+ ptr_arr = builder->CreateMalloc(IntPtrTy, allocsize, val_mem, nullptr, "arr");
//call void @llvm.memset.p0i8.i32(i8 *%arr, i8 0, i32 %d, i1 0)
{
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 8e1089a9770b0..8b5fa73c9c3e9 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -633,20 +633,18 @@ class IRBuilderBase {
Ptr, Val, getInt64(Size), Align(Alignment), ElementSize, AAInfo);
}
- LLVM_ABI CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy,
- Value *AllocSize, Value *ArraySize,
+ LLVM_ABI CallInst *CreateMalloc(Type *IntPtrTy, Value *AllocSize,
+ Value *ArraySize,
ArrayRef<OperandBundleDef> OpB,
Function *MallocF = nullptr,
const Twine &Name = "");
/// CreateMalloc - Generate the IR for a call to malloc:
- /// 1. Compute the malloc call's argument as the specified type's size,
- /// possibly multiplied by the array size if the array size is not
- /// constant 1.
+ /// 1. Compute the malloc call's argument as AllocSize, possibly multiplied
+ /// by the array size if the array size is not constant 1.
/// 2. Call malloc with that argument.
- LLVM_ABI CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy,
- Value *AllocSize, Value *ArraySize,
- Function *MallocF = nullptr,
+ LLVM_ABI CallInst *CreateMalloc(Type *IntPtrTy, Value *AllocSize,
+ Value *ArraySize, Function *MallocF = nullptr,
const Twine &Name = "");
/// Generate the IR for a call to the builtin free function.
LLVM_ABI CallInst *CreateFree(Value *Source,
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 1a9ed6d9f69ea..6d9b9fc4fcea6 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -5553,8 +5553,8 @@ Error OpenMPIRBuilder::emitScanBasedDirectiveDeclsIR(
Type *IntPtrTy = Builder.getInt32Ty();
Constant *Allocsize = ConstantExpr::getSizeOf(ScanVarsType[i]);
Allocsize = ConstantExpr::getTruncOrBitCast(Allocsize, IntPtrTy);
- Value *Buff = Builder.CreateMalloc(IntPtrTy, ScanVarsType[i], Allocsize,
- AllocSpan, nullptr, "arr");
+ Value *Buff =
+ Builder.CreateMalloc(IntPtrTy, Allocsize, AllocSpan, nullptr, "arr");
Builder.CreateStore(Buff, (*(ScanRedInfo->ScanBuffPtrs))[ScanVars[i]]);
}
return Error::success();
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index d1ee8411e392c..26ce1ecee760d 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -4009,8 +4009,7 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
- return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, nullptr,
- nullptr, Name));
+ return wrap(unwrap(B)->CreateMalloc(ITy, AllocSize, nullptr, nullptr, Name));
}
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
@@ -4018,8 +4017,8 @@ LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
- return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, unwrap(Val),
- nullptr, Name));
+ return wrap(
+ unwrap(B)->CreateMalloc(ITy, AllocSize, unwrap(Val), nullptr, Name));
}
LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 21fc73b9c084e..52cb9daba6582 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -346,8 +346,8 @@ static bool isConstantOne(const Value *Val) {
return CVal && CVal->isOne();
}
-CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy, Type *AllocTy,
- Value *AllocSize, Value *ArraySize,
+CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy, Value *AllocSize,
+ Value *ArraySize,
ArrayRef<OperandBundleDef> OpB,
Function *MallocF, const Twine &Name) {
// malloc(type) becomes:
@@ -389,12 +389,11 @@ CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy, Type *AllocTy,
return MCall;
}
-CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy, Type *AllocTy,
- Value *AllocSize, Value *ArraySize,
- Function *MallocF, const Twine &Name) {
+CallInst *IRBuilderBase::CreateMalloc(Type *IntPtrTy, Value *AllocSize,
+ Value *ArraySize, Function *MallocF,
+ const Twine &Name) {
- return CreateMalloc(IntPtrTy, AllocTy, AllocSize, ArraySize, {}, MallocF,
- Name);
+ return CreateMalloc(IntPtrTy, AllocSize, ArraySize, {}, MallocF, Name);
}
/// CreateFree - Generate the IR for a call to the builtin free function.
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index 50de49b37a6c2..50027f898b174 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -1423,8 +1423,7 @@ void IslNodeBuilder::allocateNewArrays(BBPair StartExitBlocks) {
Builder.SetInsertPoint(StartBlock,
StartBlock->getTerminator()->getIterator());
auto *CreatedArray = Builder.CreateMalloc(
- IntPtrTy, SAI->getElementType(),
- ConstantInt::get(Type::getInt64Ty(Ctx), Size),
+ IntPtrTy, ConstantInt::get(Type::getInt64Ty(Ctx), Size),
ConstantInt::get(Type::getInt64Ty(Ctx), ArraySizeInt), nullptr,
SAI->getName());
``````````
</details>
https://github.com/llvm/llvm-project/pull/222667
More information about the llvm-commits
mailing list