Add support for generics in offloadand remove no_mangle attribute - #159566
Add support for generics in offloadand remove no_mangle attribute#159566Sa4dUs wants to merge 5 commits into
offloadand remove no_mangle attribute#159566Conversation
This comment has been minimized.
This comment has been minimized.
| // core/std/allocators/etc. For example symbols used to hook up allocation | ||
| // are not considered for export | ||
| let codegen_fn_attrs = tcx.codegen_fn_attrs(sym_def_id); | ||
| let is_extern = codegen_fn_attrs.contains_extern_indicator(); |
There was a problem hiding this comment.
Perhaps contains_extern_indicator should return true for offload functions?
|
Great improvement ( I'll review later). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
|
Very nice!
On a sidenote: As due to 1., no more hash suffix is added to kernels, we should ensure that we fail compilation if someone tries to compile a program that defines the same mangled kernel name twice. |
| .iter() | ||
| .any(|o| matches!(o, rustc_session::config::Offload::HostMetadata(_))); | ||
| if is_host_metadata { | ||
| let crate_items = tcx.hir_crate_items(()); |
There was a problem hiding this comment.
What about trait_items? The impl_items note says it also covers traits, but he owners function on ModuleItems still collects both so they might not be exactly the same?
| Device, | ||
| /// Like `Device`, but reads a manifest of required generic kernel instantiations | ||
| /// produced by a previous `HostMetadata` pass. | ||
| DeviceWithManifest(String), |
There was a problem hiding this comment.
Now we went from 2 to 4 stages :D Shouldn't we be able to drop the former Device variant? We could always just create an empty DeviceManifest, I think that's easier to understand than an extra compilation path.
| let Some(path) = tcx.sess.opts.unstable_opts.offload.iter().find_map(|o| { | ||
| if let rustc_session::config::Offload::HostMetadata(p) = o { Some(p) } else { None } | ||
| }) else { | ||
| return; |
There was a problem hiding this comment.
You already check that on the caller side, so maybe bug! here if you want to check again?
implements a 3rd pass where we collect kernel instantiations required by offload to work
also enforces consistent mangling for offload functions between host and device
closes: #150985
r? @ZuseZ4