@@ -757,10 +757,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
757
757
});
758
758
}
759
759
760
- void copyVar (mlir::Location loc, mlir::Value dst,
761
- mlir::Value src) override final {
760
+ void copyVar (mlir::Location loc, mlir::Value dst, mlir::Value src,
761
+ fir::FortranVariableFlagsEnum attrs) override final {
762
+ bool isAllocatable =
763
+ bitEnumContainsAny (attrs, fir::FortranVariableFlagsEnum::allocatable);
764
+ bool isPointer =
765
+ bitEnumContainsAny (attrs, fir::FortranVariableFlagsEnum::pointer);
766
+
762
767
copyVarHLFIR (loc, Fortran::lower::SymbolBox::Intrinsic{dst},
763
- Fortran::lower::SymbolBox::Intrinsic{src});
768
+ Fortran::lower::SymbolBox::Intrinsic{src}, isAllocatable,
769
+ isPointer);
764
770
}
765
771
766
772
void copyHostAssociateVar (
@@ -1089,6 +1095,28 @@ class FirConverter : public Fortran::lower::AbstractConverter {
1089
1095
void copyVarHLFIR (mlir::Location loc, Fortran::lower::SymbolBox dst,
1090
1096
Fortran::lower::SymbolBox src) {
1091
1097
assert (lowerToHighLevelFIR ());
1098
+
1099
+ bool isBoxAllocatable = dst.match (
1100
+ [](const fir::MutableBoxValue &box) { return box.isAllocatable (); },
1101
+ [](const fir::FortranVariableOpInterface &box) {
1102
+ return fir::FortranVariableOpInterface (box).isAllocatable ();
1103
+ },
1104
+ [](const auto &box) { return false ; });
1105
+
1106
+ bool isBoxPointer = dst.match (
1107
+ [](const fir::MutableBoxValue &box) { return box.isPointer (); },
1108
+ [](const fir::FortranVariableOpInterface &box) {
1109
+ return fir::FortranVariableOpInterface (box).isPointer ();
1110
+ },
1111
+ [](const auto &box) { return false ; });
1112
+
1113
+ copyVarHLFIR (loc, dst, src, isBoxAllocatable, isBoxPointer);
1114
+ }
1115
+
1116
+ void copyVarHLFIR (mlir::Location loc, Fortran::lower::SymbolBox dst,
1117
+ Fortran::lower::SymbolBox src, bool isAllocatable,
1118
+ bool isPointer) {
1119
+ assert (lowerToHighLevelFIR ());
1092
1120
hlfir::Entity lhs{dst.getAddr ()};
1093
1121
hlfir::Entity rhs{src.getAddr ()};
1094
1122
// Temporary_lhs is set to true in hlfir.assign below to avoid user
@@ -1105,21 +1133,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
1105
1133
/* temporary_lhs=*/ true );
1106
1134
};
1107
1135
1108
- bool isBoxAllocatable = dst.match (
1109
- [](const fir::MutableBoxValue &box) { return box.isAllocatable (); },
1110
- [](const fir::FortranVariableOpInterface &box) {
1111
- return fir::FortranVariableOpInterface (box).isAllocatable ();
1112
- },
1113
- [](const auto &box) { return false ; });
1114
-
1115
- bool isBoxPointer = dst.match (
1116
- [](const fir::MutableBoxValue &box) { return box.isPointer (); },
1117
- [](const fir::FortranVariableOpInterface &box) {
1118
- return fir::FortranVariableOpInterface (box).isPointer ();
1119
- },
1120
- [](const auto &box) { return false ; });
1121
-
1122
- if (isBoxAllocatable) {
1136
+ if (isAllocatable) {
1123
1137
// Deep copy allocatable if it is allocated.
1124
1138
// Note that when allocated, the RHS is already allocated with the LHS
1125
1139
// shape for copy on entry in createHostAssociateVarClone.
@@ -1134,7 +1148,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
1134
1148
copyData (lhs, rhs);
1135
1149
})
1136
1150
.end ();
1137
- } else if (isBoxPointer ) {
1151
+ } else if (isPointer ) {
1138
1152
// Set LHS target to the target of RHS (do not copy the RHS
1139
1153
// target data into the LHS target storage).
1140
1154
auto loadVal = builder->create <fir::LoadOp>(loc, rhs);
0 commit comments