File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -816,6 +816,15 @@ struct ConvertOpConversion : public fir::FIROpConversion<fir::ConvertOp> {
816816 mlir::ConversionPatternRewriter &rewriter) const override {
817817 auto fromFirTy = convert.getValue ().getType ();
818818 auto toFirTy = convert.getRes ().getType ();
819+
820+ // Let more specialized conversions (e.g. FIR to memref
821+ // converters) handle fir.convert when either side is a memref. This
822+ // avoids interfering with descriptor-based flows such as fir.box /
823+ // fir.box_addr and keeps this pattern focused on value conversions.
824+ if (mlir::isa<mlir::MemRefType>(fromFirTy) ||
825+ mlir::isa<mlir::MemRefType>(toFirTy))
826+ return mlir::failure ();
827+
819828 auto fromTy = convertType (fromFirTy);
820829 auto toTy = convertType (toFirTy);
821830 mlir::Value op0 = adaptor.getOperands ()[0 ];
Original file line number Diff line number Diff line change 1+ // RUN: not fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s -o - 2>&1 | FileCheck %s
2+
3+ // This test ensures that the FIR CodeGen ConvertOpConversion
4+ // rejects fir.convert when either the source or the destination
5+ // type is a memref (i.e. it fails to legalize those ops).
6+
7+ module {
8+ // CHECK: error: failed to legalize operation 'fir.convert'
9+ func.func @memref_to_ref_convert (%arg0: memref <f32 >) {
10+ %0 = fir.convert %arg0 : (memref <f32 >) -> !fir.ref <f32 >
11+ return
12+ }
13+ }
14+
15+
You can’t perform that action at this time.
0 commit comments