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

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 14:09:58 PDT 2026


================
@@ -2684,7 +2585,43 @@ mlir::Value CIRGenFunction::emitBuiltinObjectSize(const Expr *e, unsigned type,
                                                   cir::IntType resType,
                                                   mlir::Value emittedE,
                                                   bool isDynamic) {
-  assert(!cir::MissingFeatures::opCallImplicitObjectSizeArgs());
+  // If this is a pass_object_size parameter, load the implicit size arg.
+  //
+  // BOS type compatibility: a pass_object_size annotation with one type can
+  // satisfy a __builtin_object_size query with a different type when the
+  // annotated type is a safe approximation.  Type 0 (max, whole object) is
+  // an overestimate for type 1 (max, closest surrounding subobject), and
+  // type 3 (min, closest surrounding subobject) is an underestimate for
+  // type 2 (min, whole object).
+  enum BOSType {
+    MaxWholeObject = 0,
+    MaxSubobject = 1,
+    MinWholeObject = 2,
+    MinSubobject = 3,
+  };
+  if (auto *d = dyn_cast<DeclRefExpr>(e->IgnoreParenImpCasts())) {
----------------
adams381 wrote:

Done in 55be23ecfa65.

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


More information about the cfe-commits mailing list