When emboxing to a polymorphic entity without a type source box,
the type desc address must be retrived from the input type and
not from the box type.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/lib/Frontend/CompilerInvocation.cpp | ||
---|---|---|
959 ↗ | (On Diff #491640) | Probably not intended here? |
flang/lib/Optimizer/CodeGen/CodeGen.cpp | ||
1581 | Is the input type the base type or the "base type after applying component refs" ? e.g: if you have "call foo(some_derived1(:)%some_derived2)" beinging passed to a polymoprhic some_derived2_base_type, would input type here be "some_derived1" or "some_derived2" ? |
flang/lib/Optimizer/CodeGen/CodeGen.cpp | ||
---|---|---|
1581 | This should be some_derived2 but let me double check. |
flang/lib/Optimizer/CodeGen/CodeGen.cpp | ||
---|---|---|
1581 | So in this case we have a fir.embox first that goes to a fir.box of the correct type. The polymorphic box is created with a fir.rebox. So the embox is taking the normal codegen where the result box type is used. So the correct type is used. type p1 integer :: a integer :: b end type type outer type(p1) :: inner end type ... subroutine test2(p) class(p1) :: p(:) end subroutine subroutine test1() type(outer) :: o(10) call test2(o(:)%inner) end subroutine %7 = fir.embox %0(%5) [%6] : (!fir.ref<!fir.array<10x!fir.type<_QMpolymorphic_testTouter{inner:!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<?x!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>> %8 = fir.rebox %7 : (!fir.box<!fir.array<?x!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>>) -> !fir.class<!fir.array<?x!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>> |
Is the input type the base type or the "base type after applying component refs" ?
e.g: if you have "call foo(some_derived1(:)%some_derived2)" beinging passed to a polymoprhic some_derived2_base_type, would input type here be "some_derived1" or "some_derived2" ?