aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Clement <clementval@gmail.com>2023-02-08 17:55:38 +0100
committerValentin Clement <clementval@gmail.com>2023-02-08 17:56:15 +0100
commit6a63e21cf4e6a8499d90e2337eb545644646ee31 (patch)
tree7ecc8050ae0d6e7bf2aeb95380e2156beada537b
parentcb19b83baac1a204cb61e7fd7c8f22dac886ce39 (diff)
downloadllvm-6a63e21cf4e6a8499d90e2337eb545644646ee31.zip
llvm-6a63e21cf4e6a8499d90e2337eb545644646ee31.tar.gz
llvm-6a63e21cf4e6a8499d90e2337eb545644646ee31.tar.bz2
[flang] Fix rank and byte stride in pointer remapping
In some remapping case the rank of the pointer is different from the target one. ``` program remap type :: p integer :: a end type t type(p), target :: ta(10) = [ (t(i),i=1,10) ] class(t), pointer :: p(:,:) p(1:2,1:5) => ta end ``` This patch updates the rank and the byte stride to fix such case. Reviewed By: klausler Differential Revision: https://reviews.llvm.org/D143566
-rw-r--r--flang/runtime/pointer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp
index c5ea96f..7bfe775 100644
--- a/flang/runtime/pointer.cpp
+++ b/flang/runtime/pointer.cpp
@@ -102,6 +102,7 @@ void RTNAME(PointerAssociateRemapping)(Descriptor &pointer,
Terminator terminator{sourceFile, sourceLine};
SubscriptValue byteStride{/*captured from first dimension*/};
std::size_t boundElementBytes{bounds.ElementBytes()};
+ pointer.raw().rank = bounds.rank();
for (int j{0}; j < bounds.rank(); ++j) {
auto &dim{pointer.GetDimension(j)};
dim.SetBounds(GetInt64(bounds.ZeroBasedIndexedElement<const char>(2 * j),
@@ -109,7 +110,7 @@ void RTNAME(PointerAssociateRemapping)(Descriptor &pointer,
GetInt64(bounds.ZeroBasedIndexedElement<const char>(2 * j + 1),
boundElementBytes, terminator));
if (j == 0) {
- byteStride = dim.ByteStride();
+ byteStride = dim.ByteStride() * dim.Extent();
} else {
dim.SetByteStride(byteStride);
byteStride *= dim.Extent();