[clang] [CIR] Use allocation size for argument dereferenceable attribute (PR #235138)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 19:54:24 PDT 2026


================
@@ -293,9 +293,12 @@ mlir::ArrayAttr updateArgAttrs(mlir::MLIRContext *ctx, mlir::ModuleOp module,
           attrs.set(mlir::LLVM::LLVMDialect::getDeadOnReturnAttrName(),
                     builder.getI64IntegerAttr(static_cast<int64_t>(
                         llvm::DeadOnReturnInfo().toIntValue())));
+        // The object spans its allocation size, which is larger than its
+        // size for a vector whose size is not a power of two.
         attrs.set(mlir::LLVM::LLVMDialect::getDereferenceableAttrName(),
-                  builder.getI64IntegerAttr(
-                      dl.getTypeSize(pointeeTy).getFixedValue()));
+                  builder.getI64IntegerAttr(cir::CIRDataLayout(module)
----------------
bcardosolopes wrote:

nit: this builds a `CIRDataLayout` for every indirect argument. `CIRABIRewriteContext` already has one (`cirDataLayout`). Can you pass it in instead of `module`?

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


More information about the cfe-commits mailing list