-
Notifications
You must be signed in to change notification settings - Fork 8
feat!: [RFC] Preliminaries for linking by name #2143
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
base: main
Are you sure you want to change the base?
Conversation
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary
|
5788e0f
to
f15eccb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2143 +/- ##
==========================================
- Coverage 82.10% 82.06% -0.04%
==========================================
Files 230 230
Lines 40943 41014 +71
Branches 37044 37115 +71
==========================================
+ Hits 33616 33660 +44
- Misses 5363 5392 +29
+ Partials 1964 1962 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I've not reviewed the code, but the description is so good I can give initial feedback from that"
So when a FuncDefn with public == true is "lifted" to a module the public flag "turns on"? This seems a bit dangerous. Lifting functions to modules is very normal and useful. I don't see a better path though. This is a case for emitting a warning (non-module-child has link name)
This is my preference. I expect the "String" to grow in complexity over time, linking is complicated. One might want to link two hugrs together, i.e. one uses a "public" function of the other, but that function doesn't want to be actually exposed as a public symbol after conversion to llvm. There is weak linking, ODR. I expect we will want more than zero of these features. Yes name can be moved to metadata. Or it can stay where it is because it's Very Important Metadata. Nice to have: it would be great if we were able to be unconcerned with naming generated functions (e.g. monomorphise)
I think there is benefit in maintaining the distinction between "link name" and "user-written-name".
Yes, once we have a definition of public dataflow analysis should use this
Perhaps we should mark FuncDefn (and everything else?) #[non_exhaustive] ? Do you think we should change "FuncDecls must be children of module" here? I do not think we should attempt to link Consts. One can just write a function that returns the const. Yes we need const de-duplication, but we need it without linking too. |
Thanks @doug-q, great points! :)
Yes, good point. I've made it an error to have an exported FuncDefn that isn't at the top-level.
Yup ok, I've kept
Right. So monomorphise now mangles
yup, good point, done
This is the one I haven't really seen the use case for. Seems to me that whereas a
Yup, done
Now that every Hugr has a module root, no, I think we can insist every FuncDecl lives there.
Removed. |
Note minimal fix to serial_upgrade test - this doesn't look like an upgrade though?!
7fb8962
to
aaeffa6
Compare
I think it is important that functions, aliases, etc. can be referred to by a name. This is not immediately clear when just concentrating on writing the in-memory data structure of the compiler, but becomes much more apparent when considering other aspects, including but not limited to linking. These other aspects have been neglected so far, which I think can be felt very acutely. Names are in particular essential for the text format. That How about this: the current |
Thanks, both. I like Lukas' suggestion (rename "Metadata" Also it seems odd for metadata that is used only by humans to be compulsory. I guess (if there is no uniqueness requirement) one can provide an empty string (which, incidentally, would be another way to declare that a function has no link-name; empty string is, after all, not a legal name). Finally @doug-q the idea that monomorphization leaves human-name unchanged but mangles link-name is kinda annoying in that monomorphization still acts on functions that have no link-name, but then the human-name does not give any way to tell them apart. I guess one then has to inspect the type of the function, which is much more cumbersome. |
Yes, there's an argument to allow for The human readable title should be optional. If |
Not ready yet, but hoping for feedback ASAP; I expect this to be a prereq for #2108 as it defines how linking should operate.
link_name: Option<String>
to FuncDefn (closes Decide on which functions are "public" #1752). This must beNone
if the FuncDefn isn't direct child of the Module root.validate
checks that the public children of a Module have unique names (also FuncDecls - i.e. don't allow exporting a FuncDefn and importing the same name)define_function
methodsdefine_function_link_name
is very long; maybedefine_function_ln
? (ln
is the Linux linker after all!) Maybe also addModuleBuilder::define_private_function
FuncDefn
as#[non_exhaustive]
BREAKING CHANGE: FuncDefn has an extra field, recommend using
new
,new_public
ornew_private