This is an archive of the discontinued LLVM Phabricator instance.

[flang] Make a descriptor copy for fir.load fir.ref<fir.box>
ClosedPublic

Authored by jeanPerier on Sep 13 2022, 8:16 AM.

Details

Summary

fir.box and fir.ref<fir.box> are both lowered to LLVM as a
descriptor in memory. This is because fir.box of polymorphic and assumed
rank entities cannot be known at compile time, so fir.box cannot be
lowered to a struct value.

fir.load or fir.ref<fir.box> was previously lowered to a no-op,
propagating the operand descriptor storage as a result.
This is wrong because the operand descriptor storage may later be
modified, and these changes should not be visible in the loaded fir.box
that is an immutable SSA value.

Modify fir.load codegen for fir.box to make a copy into a new storage to
ensure the fir.box is immutable.

Diff Detail