From 82cfee8b4f52dd0caedcf4792de6f9a51ffe2d7f Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 13:12:04 +0200 Subject: [PATCH] [CIR] Make PoisonAttr use AttrBuilderWithInferredContext --- clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 13 ++++++++++--- clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index b9ef9ea872b7..133858aa88a3 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -268,13 +268,20 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> { //===----------------------------------------------------------------------===// def PoisonAttr : CIR_Attr<"Poison", "poison", [TypedAttrInterface]> { - let summary = "Represent an poison constant"; + let summary = "Represent a typed poison constant"; let description = [{ - The PoisonAttr represents an poison constant, corresponding to LLVM's notion - of poison. + The PoisonAttr represents a typed poison constant, corresponding to LLVM's + notion of poison. }]; let parameters = (ins AttributeSelfTypeParameter<"">:$type); + + let builders = [ + AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{ + return $_get(type.getContext(), type); + }]> + ]; + let assemblyFormat = [{}]; } diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp index 630e10bcabb8..7b852db212ec 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp @@ -2201,8 +2201,8 @@ static void vecExtendIntValue(CIRGenFunction &cgf, cir::VectorType argVTy, // it before inserting. arg = builder.createIntCast(arg, eltTy); mlir::Value zero = builder.getConstInt(loc, cgf.SizeTy, 0); - mlir::Value poison = builder.create( - loc, builder.getAttr(eltTy)); + mlir::Value poison = + builder.create(loc, cir::PoisonAttr::get(eltTy)); arg = builder.create( loc, builder.create(loc, argVTy, poison), arg, zero); }