[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 00:49:02 PDT 2025
================
@@ -871,20 +928,50 @@ const CGFunctionInfo &CodeGenTypes::arrangeLLVMFunctionInfo(
} else if (info.getCC() == CC_Swift || info.getCC() == CC_SwiftAsync) {
swiftcall::computeABIInfo(CGM, *FI);
} else {
- CGM.getABIInfo().computeInfo(*FI);
+ if (isBPF)
+ CGM.fetchABIInfo(TB).computeInfo(*tempFI);
+ else
+ CGM.getABIInfo().computeInfo(*FI);
}
// Loop over all of the computed argument and return value info. If any of
// them are direct or extend without a specified coerce type, specify the
// default now.
- ABIArgInfo &retInfo = FI->getReturnInfo();
- if (retInfo.canHaveCoerceToType() && retInfo.getCoerceToType() == nullptr)
- retInfo.setCoerceToType(ConvertType(FI->getReturnType()));
+ if (isBPF && tempFI) {
+
+ const auto &abiRetInfo = tempFI->getReturnInfo();
+ ABIArgInfo &cgRetInfo = FI->getReturnInfo();
+
+ cgRetInfo = convertABIArgInfo(abiRetInfo, FI->getReturnType());
+
+ unsigned numArgs = std::min(FI->arg_size(), tempFI->getNumArgs());
+ unsigned argIndex = 0;
+
+ for (auto &cgArg : FI->arguments()) {
+ if (argIndex >= numArgs)
+ break;
- for (auto &I : FI->arguments())
- if (I.info.canHaveCoerceToType() && I.info.getCoerceToType() == nullptr)
- I.info.setCoerceToType(ConvertType(I.type));
+ const auto &abiArgInfo = tempFI->getArgInfo(argIndex);
+ cgArg.info = convertABIArgInfo(abiArgInfo.ArgInfo, cgArg.type);
+ if (abiArgInfo.ArgInfo.isInReg())
+ cgArg.info.setInReg(true);
+
+ argIndex++;
+ }
+ } else {
+ // Non-BPF path: handle coerce types for direct/extend cases
+ ABIArgInfo &retInfo = FI->getReturnInfo();
+ if (retInfo.canHaveCoerceToType() && retInfo.getCoerceToType() == nullptr) {
+ retInfo.setCoerceToType(ConvertType(FI->getReturnType()));
+ }
+
+ for (auto &I : FI->arguments()) {
+ if (I.info.canHaveCoerceToType() && I.info.getCoerceToType() == nullptr) {
+ I.info.setCoerceToType(ConvertType(I.type));
+ }
+ }
----------------
nikic wrote:
Okay, this answers my question about why you need that CoercedType fallback.
https://github.com/llvm/llvm-project/pull/140112
More information about the llvm-commits
mailing list