This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add TODO for creation of polymorphic temporary
ClosedPublic

Authored by jeanPerier on Mar 31 2023, 8:20 AM.

Details

Summary

The current code is wrong: it is doing an alloca with the declared
type instead of the dynamic type, leading to undefined behavior
when the dynamic type and declared type differ and the temporary
is later used.
This also introduces some fir.alloca none for unlimited polymorphic that
are not allocating the right thing at all.

Add TODOs for now, the correct thing to do will probably be to use the
runtime (like AssignTemporary), but since this happens in code doing
"mold" temp allocation, I first need to check if there is a need for "mold"
temporary creation not followed by an assign, or if this can be combined
with the assign instead (for HLFIR, it is pretty easy combine this from as_expr
codegen, not sure for the current lowering).

Diff Detail

Event Timeline

jeanPerier created this revision.Mar 31 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2023, 8:20 AM
jeanPerier requested review of this revision.Mar 31 2023, 8:20 AM
This revision is now accepted and ready to land.Mar 31 2023, 9:08 AM
PeteSteinfeld accepted this revision.Mar 31 2023, 9:59 AM

All builds and tests correctly and looks good.

This revision was automatically updated to reflect the committed changes.