Index: mlir/lib/Conversion/UBToLLVM/UBToLLVM.cpp =================================================================== --- mlir/lib/Conversion/UBToLLVM/UBToLLVM.cpp +++ mlir/lib/Conversion/UBToLLVM/UBToLLVM.cpp @@ -42,15 +42,16 @@ LogicalResult PoisonOpLowering::matchAndRewrite(ub::PoisonOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const { - Type origType = op.getType(); - if (!origType.isIntOrIndexOrFloat()) - return rewriter.notifyMatchFailure( - op, [&](Diagnostic &diag) { diag << "unsupported type " << origType; }); + if (!isa(op.getValue())) + return rewriter.notifyMatchFailure(op, [&](Diagnostic &diag) { + diag << "pattern can only convert op with '" + << ub::PoisonAttr::getMnemonic() << "' poison value"; + }); - Type resType = getTypeConverter()->convertType(origType); + Type resType = getTypeConverter()->convertType(op.getType()); if (!resType) return rewriter.notifyMatchFailure(op, [&](Diagnostic &diag) { - diag << "failed to convert result type " << origType; + diag << "failed to convert result type " << op.getType(); }); rewriter.replaceOpWithNewOp(op, resType); Index: mlir/test/Conversion/UBToLLVM/ub-to-llvm.mlir =================================================================== --- mlir/test/Conversion/UBToLLVM/ub-to-llvm.mlir +++ mlir/test/Conversion/UBToLLVM/ub-to-llvm.mlir @@ -12,5 +12,7 @@ %1 = ub.poison : i16 // CHECK: {{.*}} = llvm.mlir.poison : f64 %2 = ub.poison : f64 +// CHECK: {{.*}} = llvm.mlir.poison : !llvm.ptr + %3 = ub.poison : !llvm.ptr return }