[clang] [llvm] [clang] Integrate LLVMABI for function call ABI lowering (PR #194460)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 01:10:54 PDT 2026
================
@@ -876,6 +915,29 @@ const CGFunctionInfo &CodeGenTypes::arrangeLLVMFunctionInfo(
computeSPIRKernelABIInfo(CGM, *FI);
} else if (info.getCC() == CC_Swift || info.getCC() == CC_SwiftAsync) {
swiftcall::computeABIInfo(CGM, *FI);
+ } else if (CGM.shouldUseLLVMABILowering()) {
+ SmallVector<const llvm::abi::Type *, 8> MappedArgTypes;
+ MappedArgTypes.reserve(argTypes.size());
+ for (CanQualType ArgType : argTypes)
+ MappedArgTypes.push_back(AbiMapper.convertType(ArgType));
+
+ std::optional<unsigned> NumRequired;
+ if (required.allowsOptionalArgs())
+ NumRequired = required.getNumRequiredArgs();
+
+ llvm::abi::FunctionInfo *AbiFI = llvm::abi::FunctionInfo::create(
+ CC, AbiMapper.convertType(resultType), MappedArgTypes, NumRequired);
+
+ CGM.getLLVMABITargetInfo(AbiMapper.getTypeBuilder()).computeInfo(*AbiFI);
+
+ FI->getReturnInfo() =
+ convertABIArgInfo(AbiFI->getReturnInfo(), FI->getReturnType());
+
+ auto AbiArgs = AbiFI->arguments();
+ for (auto [ArgIdx, CGArg] : llvm::enumerate(FI->arguments())) {
----------------
nikic wrote:
I guess even cleaner would be something like `auto &[Arg, AbiArg] : llvm::zip(FI->arguments(), AbiFI->arguments())`, it that works.
https://github.com/llvm/llvm-project/pull/194460
More information about the cfe-commits
mailing list