Skip to content

dmd.toobj: Move the toObjFile call in genTypeInfo to DMD gluelayer#13690

Draft
ibuclaw wants to merge 1 commit intodlang:masterfrom
ibuclaw:gentypinfofortype
Draft

dmd.toobj: Move the toObjFile call in genTypeInfo to DMD gluelayer#13690
ibuclaw wants to merge 1 commit intodlang:masterfrom
ibuclaw:gentypinfofortype

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Feb 18, 2022

Almost all code in typinf.d is common front-end semantic logic for all compilers, with exception to the toObjFile() call into DMD's gluelayer.

This moves that call to a new helper function genTypeInfoForType in the dmd-specific toobj.d module.

With this, GDC no longer needs to patch any DMD front-end sources in order for it to work with the GCC glue.

@ibuclaw ibuclaw added the Severity:Refactoring No semantic changes to code label Feb 18, 2022
@ibuclaw ibuclaw requested a review from kinke February 18, 2022 19:29
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#13690"

@ibuclaw ibuclaw marked this pull request as draft February 18, 2022 19:40
@ibuclaw
Copy link
Member Author

ibuclaw commented Feb 19, 2022

There's some funny things going on with type merging. But on closer inspection, sc is only not null from one place when calling genTypeInfo, so we can refactor with that in mind instead.

@ibuclaw ibuclaw force-pushed the gentypinfofortype branch 3 times, most recently from 61a32c5 to f625ff5 Compare February 19, 2022 09:22
@ibuclaw
Copy link
Member Author

ibuclaw commented Feb 19, 2022

Passes, but can be further simplified, as for instance getTypeInfoType is only ever called from semantic, so doesn't need sc checking, nor extern(C++).

{
// Find module that will go all the way to an object file
Module m = sc._module.importedFrom;
m.members.push(t.vtinfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I don't assign any TypeInfos here to modules anymore for LDC. Instead, I emit struct and ad-hoc TypeInfos into each referencing object file, solely from the glue layer. Besides potentially less inter-object-file dependencies and increased optimization potential, this also takes care of all CTFE / speculative instantiation problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments