diff --git a/flang/include/flang/Optimizer/Dialect/FIRType.h b/flang/include/flang/Optimizer/Dialect/FIRType.h --- a/flang/include/flang/Optimizer/Dialect/FIRType.h +++ b/flang/include/flang/Optimizer/Dialect/FIRType.h @@ -280,12 +280,6 @@ /// e.g. !fir.box> bool isBoxedRecordType(mlir::Type ty); -/// Return true iff `ty` is a !fir.ref> type. -bool isRefBoxType(mlir::Type ty); - -/// Return true iff `ty` is !fir.box type. -bool isOpaqueDescType(mlir::Type ty); - /// Return true iff `ty` is the type of an polymorphic entity or /// value. bool isPolymorphicType(mlir::Type ty); diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -2718,7 +2718,7 @@ // course base_addr might need to be updated. if (lhsType && lhsType->IsUnlimitedPolymorphic()) { mlir::Value lhs = genExprMutableBox(loc, assign.lhs).getAddr(); - mlir::Value rhs = genExprMutableBox(loc, assign.rhs).getAddr(); + mlir::Value rhs = fir::getBase(genExprBox(loc, assign.rhs, stmtCtx)); Fortran::lower::genPointerAssociate(*builder, loc, lhs, rhs); return; } diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -938,8 +938,7 @@ (inType.isa() && outType.isa()) || (fir::isa_complex(inType) && fir::isa_complex(outType)) || (fir::isBoxedRecordType(inType) && fir::isPolymorphicType(outType)) || - (fir::isPolymorphicType(inType) && fir::isPolymorphicType(outType)) || - (fir::isRefBoxType(inType) && fir::isOpaqueDescType(outType))) + (fir::isPolymorphicType(inType) && fir::isPolymorphicType(outType))) return mlir::success(); llvm::errs() << inType << " / " << outType << "\n"; return emitOpError("invalid type conversion"); diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -274,19 +274,6 @@ return false; } -bool isRefBoxType(mlir::Type ty) { - if (auto refTy = ty.dyn_cast()) - return refTy.getEleTy().isa(); - return false; -} - -bool isOpaqueDescType(mlir::Type ty) { - if (auto boxTy = ty.dyn_cast()) - if (boxTy.getEleTy().isa()) - return true; - return false; -} - static bool isAssumedType(mlir::Type ty) { if (auto boxTy = ty.dyn_cast()) { if (boxTy.getEleTy().isa()) diff --git a/flang/test/Lower/polymorphic.f90 b/flang/test/Lower/polymorphic.f90 --- a/flang/test/Lower/polymorphic.f90 +++ b/flang/test/Lower/polymorphic.f90 @@ -141,9 +141,11 @@ ! CHECK: %[[P:.*]] = fir.alloca !fir.class>> {bindc_name = "p", uniq_name = "_QMpolymorphic_testFassociate_up_pointerEp"} ! CHECK: %[[FIELD_RP:.*]] = fir.field_index rp, !fir.type<_QMpolymorphic_testTr1{rp:!fir.box>>}> ! CHECK: %[[COORD_RP:.*]] = fir.coordinate_of %[[ARG0]], %[[FIELD_RP]] : (!fir.class>>}>>, !fir.field) -> !fir.ref>>> +! CHECK: %[[LOAD_RP:.*]] = fir.load %[[COORD_RP]] : !fir.ref>>> +! CHECK: %[[REBOX_RP:.*]] = fir.rebox %[[LOAD_RP]](%{{.*}}) : (!fir.box>>, !fir.shift<1>) -> !fir.box> ! CHECK: %[[CONV_P:.*]] = fir.convert %[[P]] : (!fir.ref>>>) -> !fir.ref> -! CHECK: %[[CONV_RP:.*]] = fir.convert %[[COORD_RP]] : (!fir.ref>>>) -> !fir.box -! CHECK: %{{.*}} = fir.call @_FortranAPointerAssociate(%[[CONV_P]], %[[CONV_RP]]) {{.*}} : (!fir.ref>, !fir.box) -> none +! CHECK: %[[RP_BOX_NONE:.*]] = fir.convert %[[REBOX_RP]] : (!fir.box>) -> !fir.box +! CHECK: %{{.*}} = fir.call @_FortranAPointerAssociate(%[[CONV_P]], %[[RP_BOX_NONE]]) {{.*}} : (!fir.ref>, !fir.box) -> none ! CHECK: return ! Test that the fir.dispatch operation is created with the correct pass object