diff options
author | Peter Klausler <pklausler@nvidia.com> | 2025-07-18 13:45:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-18 13:45:05 -0700 |
commit | 9e5b2fbe86ed9b303eff779fff012d6a96574f3d (patch) | |
tree | ac748ec98001396ec83cc30ce17a4366d4d82fc1 /flang/lib | |
parent | 680b8dd7073cce6606006ae723899444521aa496 (diff) | |
download | llvm-9e5b2fbe86ed9b303eff779fff012d6a96574f3d.zip llvm-9e5b2fbe86ed9b303eff779fff012d6a96574f3d.tar.gz llvm-9e5b2fbe86ed9b303eff779fff012d6a96574f3d.tar.bz2 |
[flang][runtime] Preserve type when remapping monomorphic pointers (#149427)
Pointer remappings unconditionally update the element byte size and
derived type of the pointer's descriptor. This is okay when the pointer
is polymorphic, but not when a pointer is associated with an extended
type.
To communicate this monomorphic case to the runtime, add a new entry
point so as to not break forward binary compatibility.
Diffstat (limited to 'flang/lib')
-rw-r--r-- | flang/lib/Lower/Bridge.cpp | 6 | ||||
-rw-r--r-- | flang/lib/Lower/Runtime.cpp | 15 |
2 files changed, 12 insertions, 9 deletions
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index 5f0783f..7ce397a 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -4703,8 +4703,10 @@ private: mlir::Value lhs = lhsMutableBox.getAddr(); mlir::Value rhs = fir::getBase(genExprBox(loc, assign.rhs, stmtCtx)); mlir::Value boundsDesc = createBoundArray(lbounds, ubounds, loc); - Fortran::lower::genPointerAssociateRemapping(*builder, loc, lhs, rhs, - boundsDesc); + Fortran::lower::genPointerAssociateRemapping( + *builder, loc, lhs, rhs, boundsDesc, + lhsType && rhsType && !lhsType->IsPolymorphic() && + rhsType->IsPolymorphic()); return; } if (!lowerToHighLevelFIR() && explicitIterationSpace()) { diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp index 5f73335..ae8bf0e 100644 --- a/flang/lib/Lower/Runtime.cpp +++ b/flang/lib/Lower/Runtime.cpp @@ -213,14 +213,15 @@ void Fortran::lower::genPointerAssociate(fir::FirOpBuilder &builder, builder.create<fir::CallOp>(loc, func, args); } -void Fortran::lower::genPointerAssociateRemapping(fir::FirOpBuilder &builder, - mlir::Location loc, - mlir::Value pointer, - mlir::Value target, - mlir::Value bounds) { +void Fortran::lower::genPointerAssociateRemapping( + fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value pointer, + mlir::Value target, mlir::Value bounds, bool isMonomorphic) { mlir::func::FuncOp func = - fir::runtime::getRuntimeFunc<mkRTKey(PointerAssociateRemapping)>(loc, - builder); + isMonomorphic + ? fir::runtime::getRuntimeFunc<mkRTKey( + PointerAssociateRemappingMonomorphic)>(loc, builder) + : fir::runtime::getRuntimeFunc<mkRTKey(PointerAssociateRemapping)>( + loc, builder); auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = |