[clang] [CIR] Add support for __builtin_assume_aligned (PR #152152)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 6 10:06:59 PDT 2025


================
@@ -460,6 +460,28 @@ mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+mlir::LogicalResult CIRToLLVMAssumeAlignedOpLowering::matchAndRewrite(
+    cir::AssumeAlignedOp op, OpAdaptor adaptor,
+    mlir::ConversionPatternRewriter &rewriter) const {
+  SmallVector<mlir::Value, 3> opBundleArgs{adaptor.getPointer()};
+
+  auto alignment = rewriter.create<mlir::LLVM::ConstantOp>(
+      op.getLoc(), rewriter.getI64Type(), op.getAlignment());
----------------
andykaylor wrote:

I was hoping that using the adaptor would save a round trip on the attribute creation (because `getAlignment()` returns a literal value which is then converted back to an attribute by the `ConstantOp` builder), but after closer inspection it doesn't look like it does. However, I think maybe using `getAlignmentAttr()` with either `op` or `adaptor` would work.

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


More information about the cfe-commits mailing list