[clang] [CIR] Emit classic's attributes for a non-byval indirect argument (PR #222445)

Adam Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 13:02:11 PDT 2026


================
@@ -214,30 +214,35 @@ mlir::ArrayAttr updateArgAttrs(mlir::MLIRContext *ctx,
       attrs.set(attrName, builder.getUnitAttr());
       newArgAttrs.push_back(attrs.getDictionary(ctx));
     } else if (ac.kind == ArgKind::Indirect) {
-      // byval: caller-allocated copy; callee receives pointer to copy.
-      // byref: callee receives pointer to the caller's original storage.
-      // Both use llvm.align(A).  The ownership flag differs: llvm.byval(T)
-      // vs llvm.byref(T).  Both are typed attributes carrying the pointee
-      // type T (the pre-rewrite arg type); T is recorded explicitly because
-      // it cannot be recovered from the opaque LLVM pointer after lowering.
+      // byval hands the callee its own copy.  Without byval it gets a pointer
+      // to the caller's own object.  Both state llvm.align and llvm.noundef,
+      // which constrains the pointer operand, not the pointee's contents.
       //
-      // byval also gets llvm.noundef: the caller's original must be defined
-      // or UB has already occurred, and the copy inherits that.
+      // llvm.byval(T) records the pre-rewrite arg type because the opaque
+      // LLVM pointer cannot carry it.  llvm.nofreeobj holds because a
----------------
adams381 wrote:

It was trying to say that.  I've rewritten it to try and be more clear.


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


More information about the cfe-commits mailing list