[clang] [CIR] Add pass_object_size hidden parameter support (PR #191482)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 13:55:31 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()));
----------------
andykaylor wrote:

Does `prefix.push_back(cgt.getASTContext().getCanonicalSizeType());` work? I think this code was updated in classic codegen, and I'd like to see us match the update. The `getContext` vs. `getASTContext` is just a difference in naming that we did to avoid ambiguity of AST vs. LLVM vs. MLIR context accessors. It gets the same underlying object.

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


More information about the cfe-commits mailing list