[flang-commits] [PATCH] D109156: [flang] Extend common block size to cover equivalence storage
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Sep 2 23:14:40 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG084d8bebd0fc: [flang] Extend common block size to cover equivalence storage (authored by jeanPerier).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109156/new/
https://reviews.llvm.org/D109156
Files:
flang/lib/Semantics/compute-offsets.cpp
flang/test/Semantics/offsets03.f90
Index: flang/test/Semantics/offsets03.f90
===================================================================
--- flang/test/Semantics/offsets03.f90
+++ flang/test/Semantics/offsets03.f90
@@ -37,3 +37,23 @@
common /common1/ d3,d2,d1 !CHECK: common1 size=10 offset=0: CommonBlockDetails alignment=4:
common /common2/ d4 !CHECK: common2 size=2 offset=0: CommonBlockDetails alignment=2:
end
+
+! Test extension of common block size through equivalence statements.
+module me
+ integer :: i1, j1, l1(10)
+ equivalence(i1, l1)
+ common /common3/ j1, i1 ! CHECK: common3 size=44 offset=0: CommonBlockDetails alignment=4:
+
+ integer :: i2, j2, l2(10)
+ equivalence(i2, l2(2))
+ common /common4/ j2, i2 ! CHECK: common4 size=40 offset=0: CommonBlockDetails alignment=4:
+
+ integer :: i3, j3, l3(10)
+ equivalence(i3, l3)
+ common /common5/ i3, j3 ! CHECK: common5 size=40 offset=0: CommonBlockDetails alignment=4:
+
+ integer :: i4, j4, l4(10), k4(10)
+ equivalence(i4, l4)
+ equivalence(l4(10), k4)
+ common /common6/ i4, j4 ! CHECK: common6 size=76 offset=0: CommonBlockDetails alignment=4:
+end
Index: flang/lib/Semantics/compute-offsets.cpp
===================================================================
--- flang/lib/Semantics/compute-offsets.cpp
+++ flang/lib/Semantics/compute-offsets.cpp
@@ -151,16 +151,12 @@
for (auto &object : details.objects()) {
Symbol &symbol{*object};
DoSymbol(symbol);
+ auto eqIter{equivalenceBlock_.end()};
auto iter{dependents_.find(symbol)};
if (iter == dependents_.end()) {
- // Get full extent of any EQUIVALENCE block into size of COMMON
- auto eqIter{equivalenceBlock_.find(symbol)};
+ auto eqIter = equivalenceBlock_.find(symbol);
if (eqIter != equivalenceBlock_.end()) {
- SizeAndAlignment &blockInfo{eqIter->second};
- DoEquivalenceBlockBase(symbol, blockInfo);
- minSize = std::max(
- minSize, std::max(offset_, symbol.offset() + blockInfo.size));
- minAlignment = std::max(minAlignment, blockInfo.alignment);
+ DoEquivalenceBlockBase(symbol, eqIter->second);
}
} else {
SymbolAndOffset &dep{iter->second};
@@ -183,10 +179,19 @@
"'%s' cannot backward-extend COMMON block /%s/ via EQUIVALENCE with '%s'"_err_en_US,
symbol.name(), commonBlock.name(), base.name());
} else {
+ eqIter = equivalenceBlock_.find(base);
base.get<ObjectEntityDetails>().set_commonBlock(commonBlock);
base.set_offset(symbol.offset() - dep.offset);
}
}
+ // Get full extent of any EQUIVALENCE block into size of COMMON ( see
+ // 8.10.2.2 point 1 (2))
+ if (eqIter != equivalenceBlock_.end()) {
+ SizeAndAlignment &blockInfo{eqIter->second};
+ minSize = std::max(
+ minSize, std::max(offset_, eqIter->first->offset() + blockInfo.size));
+ minAlignment = std::max(minAlignment, blockInfo.alignment);
+ }
}
commonBlock.set_size(std::max(minSize, offset_));
details.set_alignment(std::max(minAlignment, alignment_));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109156.370485.patch
Type: text/x-patch
Size: 3093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210903/4ea2abd7/attachment.bin>
More information about the flang-commits
mailing list