[flang-commits] [PATCH] D120801: [flang] Generate PDT runtime type info in the type definition scope
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Mar 2 09:31:43 PST 2022
jeanPerier added a comment.
> Can you really create the derived type description object in the same scope as the definition of the type when the type is USE-associated from a module file and instantiated in another compilation unit? What happens in that case?
Yes, that works, this was already the case with non-PDT types where runtime type info for module was always generated in the compilation unit using the module _inside_ the used module scope, not at the instantiation scope. However, they used to just be ignored in lowering that relied on the related symbols to be translated while processing the module compilation unit. I am moving away from this approach in lowering, and instead taking an approach where runtime type info will always be generated as fully defined weak constant data in compilation unit that needs it. All the duplicate weak symbols are merged at link time.
Here is an example:
module.f90
subroutine bar()
use m
type(t(4)) :: a
a%i = 1
print *, a%i
end subroutine
module m
type t(k)
integer, kind :: k
integer :: i(k)
end type
end module
test.f90
use m
type(t(4)) :: a
a%i = 2
print *, a%i
call bar()
end
Both `bar.o` and `test.o` will contain a definition of weak definitions of `_QMmE.dt.t.4` that are merged by the linker into a single one in the final executable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120801/new/
https://reviews.llvm.org/D120801
More information about the flang-commits
mailing list