This is an archive of the discontinued LLVM Phabricator instance.

[flang][NFC] Move Array constructor inlined temp management into a utility
ClosedPublic

Authored by jeanPerier on May 22 2023, 7:49 AM.

Details

Summary

This patch moves the counter and storage management part of the array
constructor inlined temporary strategy into its own utility so that it
can be reused for the simple cases of temporary creations inside WHERE
and FORALL.

It actually fixes a bug where the counter first value used for addressing
was "2" leading to read/write after the allocated storage... It seems
I ran the tests end-to-end without the HLFIR flag when previously testing
this. So this may clear some segfaults.

Diff Detail

Event Timeline

jeanPerier created this revision.May 22 2023, 7:49 AM
jeanPerier requested review of this revision.May 22 2023, 7:49 AM
tblah accepted this revision.May 22 2023, 8:33 AM

LGTM, with a small nit.

flang/lib/Optimizer/Builder/TemporaryStorage.cpp
100–103

nit: please could you add a TODO checking that no derived types get here, just in case the strategy is changed later and this file is forgotten about.

This revision is now accepted and ready to land.May 22 2023, 8:33 AM
vzakhari accepted this revision.May 22 2023, 11:58 AM

Looks great! Thank you!

flang/lib/Lower/ConvertArrayConstructor.cpp
106
jeanPerier marked an inline comment as done.May 23 2023, 12:11 AM
jeanPerier added inline comments.
flang/lib/Optimizer/Builder/TemporaryStorage.cpp
100–103

Good point, I turned the assert into a TODO here.

Thanks for the reviews

  • use clang-format 16.
  • turn assert into to TODO
  • fix typo in comment
tblah accepted this revision.May 23 2023, 2:46 AM

Thanks for the update