[clang] [llvm] [clang] Integrate LLVMABI for function call ABI lowering (PR #194460)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 03:49:24 PDT 2026


================
@@ -876,6 +920,31 @@ const CGFunctionInfo &CodeGenTypes::arrangeLLVMFunctionInfo(
     computeSPIRKernelABIInfo(CGM, *FI);
   } else if (info.getCC() == CC_Swift || info.getCC() == CC_SwiftAsync) {
     swiftcall::computeABIInfo(CGM, *FI);
+  } else if (UseLLVMABI) {
+    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();
+    unsigned ArgIdx = 0;
+    for (auto &CGArg : FI->arguments()) {
+      assert(ArgIdx < AbiArgs.size() && "ABI arg count mismatch");
----------------
nikic wrote:

Can replace the separate counter with `enumerate()`.

https://github.com/llvm/llvm-project/pull/194460


More information about the cfe-commits mailing list