-
Notifications
You must be signed in to change notification settings - Fork 12.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
Equal CTFE function pointers are unequal after codegen #84581
Comments
With functions being anonymous allocations being duplicated? Sure, we can close this favour of #79738. |
Reopening since the fix for #79738, is not sufficient to resolve this issue. |
I think that's exactly what I talked about here, right? The "value" of the But, is there even a way to tell LLVM that |
Yes, it is possible to refer to an instance from a specific crate. This is how share-generics mode is implemented. Presumably, in this case we would like to identify specific instances that would need to be exported, as opposed to exporting all of them. |
How are these even identified inside the compiler? An
So the "instance in the other crate" that we want to refer to needs to be exported before we can reference it? Yes we'd only want to export those that show up in the value of some static or const. The monomorphization collector already walks all of them to ensure we create the right mono-items: rust/compiler/rustc_monomorphize/src/collector.rs Lines 1343 to 1348 in 339f4be
|
We could add a new GlobalAlloc kind that we use in statics to encode function pointers, and then use that to remember which crate a function is from and to always codegen it in the crate of the static if it isn't already codegenned in a dependency. That GlobalAlloc kind will be preserved cross crate and we then need to always refer to the one from the static's crate instead of relying on |
Why would we not do that for our existing GlobalAlloc::Function?
|
Not sure how we'd do that with constants considering we don't know what function pointers they'll contain until we evaluate them downstream (at least if the constant is generic, we could start caching nongeneric or polymorphized constants) |
GlobalAlloc::Function is never generic I think?
|
Could be with Basically during interning, we also reintern AllocIds that refer to functions, and give them extra information about the crate that they were interned in. |
With IOW, |
The general issue is similar to #79738. In this case a function pointer is represented with
GlobalAlloc::Function(Instance<'tcx>)
, which does not uniquely identify function after codegen.cc @oli-obk
@rustbot modify labels: +A-codegen +A-const-eval
The text was updated successfully, but these errors were encountered: