-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][polymorphic] Type descriptors are not emitted during separate compilation #63775
Comments
@llvm/issue-subscribers-flang-ir |
The problem is coming from the fact that we try to find the global before we emit it. I'll have a patch that will fix this issue up for review tomorrow. |
Thanks a lot Valentin! |
@llvm/issue-subscribers-flang-runtime |
@llvm/issue-subscribers-flang-ir |
Do not look for the global early in nullify codegen. The type descriptor can be emitted later and it would raise an error as it could not be found. Use `fir.type_desc` instead so it delays the type descriptor lookup until evrything is emitted. #63775 Reviewed By: vzakhari Differential Revision: https://reviews.llvm.org/D154982
@rofirrim The patch has landed upstream. Please confirm it solved your issue. |
Hi @clementval, yes it fixes my issue. Thanks again for the prompt fix. |
Thanks for confirming and reporting the issue! |
I'm aware the polymorphic support is still experimental but I think it is useful to have this recorded.
Consider the two following files:
If we compile them separatedly,
mymod2.f90
will crash while generating FIR because the type descriptor ofmyfoo
has not been emitted andnullify
needs it.I looked into it a bit and IIUC, it seems that the type descriptor is emitted as part of
lowerModuleDeclScope
in the Bridge. If the two files together are compiled as a single file (e.g. adding aninclude 'mymod.f90'
at the beginning ofmymod2.f90
) then the crash does not happen because the descriptor is indeed emitted.In a separate compilation setting, AFAICT the module is loaded and parsed and its names resolved but I don't think we synthesise enough information so the type descriptors get emitted as a consequence of a
use
-statement. One thing I saw is that the descriptors (and other runtime info) are already emitted as weak global objects so emitting repeated definitions in different object files should not be a problem.Any hints on how we could address this? I wonder if it makes sense to check use-associations to derived types and emit their descriptors if they haven't been emitted yet?
The text was updated successfully, but these errors were encountered: