[clang] [CIR] Add pass_object_size hidden parameter support (PR #191482)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 28 09:21:28 PDT 2026
================
@@ -708,20 +708,26 @@ static CanQual<FunctionProtoType> getFormalType(const CXXMethodDecl *md) {
.getAs<FunctionProtoType>();
}
-/// Adds the formal parameters in FPT to the given prefix. If any parameter in
-/// FPT has pass_object_size_attrs, then we'll add parameters for those, too.
+/// Adds the formal parameters in FPT to the given prefix. If any parameter in
+/// FPT has pass_object_size attrs, then we'll add parameters for those, too.
/// TODO(cir): this should be shared with LLVM codegen
static void appendParameterTypes(const CIRGenTypes &cgt,
SmallVectorImpl<CanQualType> &prefix,
CanQual<FunctionProtoType> fpt) {
- assert(!cir::MissingFeatures::opCallExtParameterInfo());
// Fast path: don't touch param info if we don't need to.
if (!fpt->hasExtParameterInfos()) {
prefix.append(fpt->param_type_begin(), fpt->param_type_end());
return;
}
- cgt.getCGModule().errorNYI("appendParameterTypes: hasExtParameterInfos");
+ prefix.reserve(prefix.size() + fpt->getNumParams());
+ auto extInfos = fpt->getExtParameterInfos();
+ for (unsigned i = 0, e = fpt->getNumParams(); i != e; ++i) {
+ prefix.push_back(fpt->getParamType(i));
+ if (extInfos[i].hasPassObjectSize())
+ prefix.push_back(cgt.getASTContext().getCanonicalType(
+ cgt.getASTContext().getSizeType()));
----------------
adams381 wrote:
Yes, that's what we use now: `cgt.getASTContext().getCanonicalSizeType()`. Matches classic codegen's `CGT.getContext().getCanonicalSizeType()` (our accessor is named `getASTContext()` to avoid ambiguity with MLIR/LLVM contexts).
https://github.com/llvm/llvm-project/pull/191482
More information about the cfe-commits
mailing list