[Mlir-commits] [mlir] [MLIR][LLVMIR] Preserve byval alignment in memcpy after inlining (PR #185433)

Christian Ulmann llvmlistbot at llvm.org
Mon Mar 9 08:36:32 PDT 2026


================
@@ -623,8 +623,19 @@ static Value handleByValArgumentInit(OpBuilder &builder, Location loc,
   Value copySize =
       LLVM::ConstantOp::create(builder, loc, builder.getI64Type(),
                                builder.getI64IntegerAttr(elementTypeSize));
+  // Preserve the alignment of the destination (alloca) in the memcpy's
+  // arg_attrs.
+  MLIRContext *ctx = builder.getContext();
+  NamedAttribute dstAlignAttr =
+      builder.getNamedAttr(LLVM::LLVMDialect::getAlignAttrName(),
+                           builder.getI64IntegerAttr(targetAlignment));
+  ArrayAttr argAttrs =
+      builder.getArrayAttr({DictionaryAttr::get(ctx, {dstAlignAttr})});
----------------
Dinistro wrote:

Nit: I suggest to use `builder.getDictionaryAttr` to avoid dealing with the context yourself. 

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


More information about the Mlir-commits mailing list