When allocating a polymorphic entity, its type descriptor can come
from the declared type or can be provided in the allocate statement.
This patch adds lowering for allocate on polymorphic by calling
the AllocatableInitDerived runtime function with the correct
type descriptor. Some adaptation are made in the code generation
to accept fir.class where it is appropriate.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM
flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h | ||
---|---|---|
308 | Wow, you made that type accurate ! I am pondering whether this is needed or not. Do you see drawbacks of using fir.ref<None> for this type currently ? | |
flang/lib/Lower/Allocatable.cpp | ||
492 | I think this assert should be a fir::emitFatalError() instead because a user can trigger this state by hiding the intrinsic module which will prevent type descriptor symbols to not be created and generated. |
Wow, you made that type accurate ! I am pondering whether this is needed or not. Do you see drawbacks of using fir.ref<None> for this type currently ?
The cons I see of defining the accurate type here is that you will have to maintain it if it changes, and it makes the IR a bit more verbose (although I really think we should leverage MLIR type aliasing to make IR with derived type more readable, so it should not be the main motivation).