Page MenuHomePhabricator

[flang] Skip creating AggregateStores for common block associated aggregates

Authored by jpenix-quic on Sep 28 2022, 1:03 PM.



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.


Diff Detail

Event Timeline

jpenix-quic created this revision.Sep 28 2022, 1:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2022, 1:03 PM
jpenix-quic requested review of this revision.Sep 28 2022, 1:03 PM

Thanks for identifying the issue and submitting this patch!

As you mention, AggregateStore are actually not used for common blocks since "instantiateCommon" is used even if they are equivalenced variables in the common block. They are meant to deal with storages that are interlaced because of an equivalence, but if the variables are part of a common, all this information is already available.

So, I think that instead of modifying the AggregateStoreKeys so that "common block" AggregateStore stores can be added without overriding non common block AggregateStores, and later be unused, I think it might be simpler to simply not build the AggregateStore for common blocks (see inlined suggestion).


I think you could maybe simply continue here if first belong to a common block in order to not build aggregate stores for common blocks.

jpenix-quic retitled this revision from [flang] Add COMMON block information when searching for aggregate stores to [flang] Skip creating AggregateStores for common block associated aggregates.
jpenix-quic edited the summary of this revision. (Show Details)

Implement @jeanPerier's suggestion and update the title/summary accordingly. Also fixed "equivaleneced" -> "equivalenced" in the test comment.

jpenix-quic marked an inline comment as done.Sep 29 2022, 2:56 PM
jpenix-quic added inline comments.

This is indeed much simpler and tested ok for me. Thanks!

jpenix-quic marked an inline comment as done.Sep 29 2022, 2:56 PM
jeanPerier accepted this revision.Oct 2 2022, 11:47 PM

Thanks for fixing the issue !

This revision is now accepted and ready to land.Oct 2 2022, 11:47 PM