This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fold instantiated PDT character component length when needed
ClosedPublic

Authored by jeanPerier on Apr 1 2022, 1:45 PM.

Details

Summary

In case a character component PDT length only depends on kind parameters,
fold it while instantiating the PDT. This is especially important if the
component has an initializer because later semantic phases (offset
computation or runtime type info generation) might get confused and
generate offset/type info that will lead to crashes in lowering.

Diff Detail

Event Timeline

jeanPerier created this revision.Apr 1 2022, 1:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 1:45 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
jeanPerier requested review of this revision.Apr 1 2022, 1:45 PM
klausler accepted this revision.Apr 1 2022, 1:50 PM
klausler added inline comments.
flang/lib/Semantics/type.cpp
402

Odd formatting without substantive change.

449

The newer IsActuallyConstant() predicate might be better here than ToInt64() since you're changing this line anyway.

This revision is now accepted and ready to land.Apr 1 2022, 1:50 PM
jeanPerier updated this revision to Diff 419857.Apr 1 2022, 2:14 PM

Use IsActuallyConstant and make the required instantiation available to the linker.
Revert unrelated format change.

jeanPerier marked 2 inline comments as done.Apr 1 2022, 2:14 PM
klausler added inline comments.Apr 1 2022, 2:17 PM
flang/lib/Semantics/type.cpp
433

Typo in name (and also below at the use site): should be FoldCharacterLength with a 'c' before the first 't'.

jeanPerier updated this revision to Diff 419867.EditedApr 1 2022, 2:56 PM

Fix typo in FoldCharacterLength.

jeanPerier marked an inline comment as done.Apr 1 2022, 2:56 PM