Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9e4680c

Browse files
authoredMar 12, 2025
Rollup merge of rust-lang#138345 - oli-obk:autodiff-cleanup, r=compiler-errors
Some autodiff cleanups cc ``@ZuseZ4`` just some things I noticed
2 parents 511574d + 9882eca commit 9e4680c

File tree

1 file changed

+5
-11
lines changed
  • compiler/rustc_monomorphize/src/partitioning

1 file changed

+5
-11
lines changed
 

‎compiler/rustc_monomorphize/src/partitioning/autodiff.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,15 @@ fn adjust_activity_to_abi<'tcx>(tcx: TyCtxt<'tcx>, fn_ty: Ty<'tcx>, da: &mut Vec
1212
if !matches!(fn_ty.kind(), ty::FnDef(..)) {
1313
bug!("expected fn def for autodiff, got {:?}", fn_ty);
1414
}
15-
let fnc_binder: ty::Binder<'_, ty::FnSig<'_>> = fn_ty.fn_sig(tcx);
1615

17-
// If rustc compiles the unmodified primal, we know that this copy of the function
18-
// also has correct lifetimes. We know that Enzyme won't free the shadow too early
19-
// (or actually at all), so let's strip lifetimes when computing the layout.
20-
let x = tcx.instantiate_bound_regions_with_erased(fnc_binder);
16+
// We don't actually pass the types back into the type system.
17+
// All we do is decide how to handle the arguments.
18+
let sig = fn_ty.fn_sig(tcx).skip_binder();
19+
2120
let mut new_activities = vec![];
2221
let mut new_positions = vec![];
23-
for (i, ty) in x.inputs().iter().enumerate() {
22+
for (i, ty) in sig.inputs().iter().enumerate() {
2423
if let Some(inner_ty) = ty.builtin_deref(true) {
25-
if ty.is_fn_ptr() {
26-
// FIXME(ZuseZ4): add a nicer error, or just figure out how to support them,
27-
// since Enzyme itself can handle them.
28-
tcx.dcx().err("function pointers are currently not supported in autodiff");
29-
}
3024
if inner_ty.is_slice() {
3125
// We know that the length will be passed as extra arg.
3226
if !da.is_empty() {

0 commit comments

Comments
 (0)
Failed to load comments.