[flang] Skip creating AggregateStores for common block associated aggregates
authorJonathon Penix <jpenix@quicinc.com>
Thu, 29 Sep 2022 20:10:19 +0000 (13:10 -0700)
committerJonathon Penix <jpenix@quicinc.com>
Mon, 3 Oct 2022 19:19:53 +0000 (12:19 -0700)
commit403d0b7a4e13e8e3bcaa1a0c57ab66ffe761c7af
treee7884bf37957cba747fe887ed92d8bf3d9a0ed69
parent5b06ccb6115cc721e7cb8ee650fea93764106e18
[flang] Skip creating AggregateStores for common block associated aggregates

Previously, AggregateStores were created for aggregates associated with common
blocks. As a) AggregateStoreMap uses scope and offset information to search for
aggregate stores and b) variables related to common blocks have their
offsets set relative to the common block itself, if there were multiple
equivalences and at least one involved variables defined in a common block there
was an opportunity for the scope/offset pairs to match between distinct
aggregate stores. As a result, entries in AggregateStoreMap could collide,
resulting in incorrect stores being returned for a particular variable.

To prevent these collisions, skip creating AggregateStores for aggregates which
are associated with common blocks. This information was already unused as
aggregates associated with common blocks are handled by instantiateCommon.

Fixes https://github.com/llvm/llvm-project/issues/57749

Differential Revision: https://reviews.llvm.org/D134828
flang/lib/Lower/PFTBuilder.cpp
flang/test/Lower/equivalence-2.f90