https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/196603
>From 677512ff120953dc2a9cf53dd73bcaeb6f2ecb0d Mon Sep 17 00:00:00 2001 From: Vitaly Buka <[email protected]> Date: Fri, 8 May 2026 11:24:25 -0700 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.7 --- clang/lib/CodeGen/CGCall.cpp | 2 +- llvm/include/llvm/ABI/FunctionInfo.h | 2 +- llvm/lib/ABI/FunctionInfo.cpp | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 1cafe364c4c42..a2b9c945788ee 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -843,7 +843,7 @@ void CodeGenModule::computeABIInfoUsingLib(CGFunctionInfo &FI) { if (Required.allowsOptionalArgs()) NumRequired = Required.getNumRequiredArgs(); - llvm::abi::FunctionInfo *AbiFI = llvm::abi::FunctionInfo::create( + auto AbiFI = llvm::abi::FunctionInfo::create( FI.getCallingConvention(), AbiMapper->convertType(FI.getReturnType()), MappedArgTypes, NumRequired); diff --git a/llvm/include/llvm/ABI/FunctionInfo.h b/llvm/include/llvm/ABI/FunctionInfo.h index 7f7b6a44ba6ad..0ebd0700836e2 100644 --- a/llvm/include/llvm/ABI/FunctionInfo.h +++ b/llvm/include/llvm/ABI/FunctionInfo.h @@ -234,7 +234,7 @@ class FunctionInfo final : private TrailingObjects<FunctionInfo, ArgEntry> { unsigned arg_size() const { return NumArgs; } - static FunctionInfo * + static std::unique_ptr<FunctionInfo> create(CallingConv::ID CC, const Type *ReturnType, ArrayRef<const Type *> ArgTypes, std::optional<unsigned> NumRequired = std::nullopt); diff --git a/llvm/lib/ABI/FunctionInfo.cpp b/llvm/lib/ABI/FunctionInfo.cpp index f89d90c74ea03..7096392135ce8 100644 --- a/llvm/lib/ABI/FunctionInfo.cpp +++ b/llvm/lib/ABI/FunctionInfo.cpp @@ -12,16 +12,17 @@ using namespace llvm; using namespace llvm::abi; -FunctionInfo *FunctionInfo::create(CallingConv::ID CC, const Type *ReturnType, - ArrayRef<const Type *> ArgTypes, - std::optional<unsigned> NumRequired) { +std::unique_ptr<FunctionInfo> +FunctionInfo::create(CallingConv::ID CC, const Type *ReturnType, + ArrayRef<const Type *> ArgTypes, + std::optional<unsigned> NumRequired) { assert(!NumRequired || *NumRequired <= ArgTypes.size()); void *Buffer = operator new(totalSizeToAlloc<ArgEntry>(ArgTypes.size())); - FunctionInfo *FI = - new (Buffer) FunctionInfo(CC, ReturnType, ArgTypes.size(), NumRequired); + std::unique_ptr<FunctionInfo> FI( + new (Buffer) FunctionInfo(CC, ReturnType, ArgTypes.size(), NumRequired)); ArgEntry *Args = FI->getTrailingObjects(); for (unsigned I = 0; I < ArgTypes.size(); ++I) >From 300c7b00f0dd6f7ce63ca48e3b919d9332a23e9d Mon Sep 17 00:00:00 2001 From: Vitaly Buka <[email protected]> Date: Fri, 8 May 2026 12:54:14 -0700 Subject: [PATCH 2/2] address review comments: relocate comment to FunctionInfo::create() Created using spr 1.3.7 --- llvm/lib/ABI/FunctionInfo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/ABI/FunctionInfo.cpp b/llvm/lib/ABI/FunctionInfo.cpp index 7096392135ce8..54e62bc29e19d 100644 --- a/llvm/lib/ABI/FunctionInfo.cpp +++ b/llvm/lib/ABI/FunctionInfo.cpp @@ -21,6 +21,9 @@ FunctionInfo::create(CallingConv::ID CC, const Type *ReturnType, void *Buffer = operator new(totalSizeToAlloc<ArgEntry>(ArgTypes.size())); + // We can use standard std::unique_ptr here because FunctionInfo overloads + // the non-sized operator delete, which avoids sized deallocation issues + // when deallocating the custom-sized buffer containing trailing objects. std::unique_ptr<FunctionInfo> FI( new (Buffer) FunctionInfo(CC, ReturnType, ArgTypes.size(), NumRequired)); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
