Skip to content
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

Fix monomorphization of constant strings in generic functions #1032

Merged
merged 7 commits into from
Sep 26, 2023

Conversation

kyouko-taiga
Copy link
Contributor

This PR fixes the monomorphization of constant strings occurring in generic functions.

In the current implementation, constant strings are lowered as references to global constants. That causes monomorphization to fail because the module in which the constant is being declared isn't necessarily the same as the module in which the monomorphized function is inserted. With this patch, constant strings are lowered with a dedicated instructions, constant_strings, that can get rewritten in each monomorphized variant.

A different way to solve this could have been to expose a symbol representing the global being referenced so that it could be referenced by another module. This approach may have to be used to deal with other kind of global references used in generic code (e.g., references to witness tables).

@kyouko-taiga kyouko-taiga linked an issue Sep 26, 2023 that may be closed by this pull request
@kyouko-taiga kyouko-taiga merged commit 289ed31 into main Sep 26, 2023
@kyouko-taiga kyouko-taiga deleted the globals-in-generics branch September 26, 2023 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use precondition in standard library
1 participant