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

simplify binder handling #83

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2735,21 +2735,12 @@ pub fn fnc_typetrees<'tcx>(tcx: TyCtxt<'tcx>, fn_ty: Ty<'tcx>, da: &mut Vec<Diff
}
let fnc_binder: ty::Binder<'_, ty::FnSig<'_>> = fn_ty.fn_sig(tcx);

// TODO: cleanup
// Ok, sorry whoever reviews this.
// If we call this on arbitrary rust functions which we don't differentiate directly,
// then we have no da vec. We might encounter complex types, so do it properly.
// If we have a da vec, we know we are difrectly differentiating that fnc,
// so can assume it's something simpler, where skip_binder is ok (for now).
let x: ty::FnSig<'_>;
if da.is_empty() {
x = match fnc_binder.no_bound_vars() {
Some(x) => x,
None => return FncTree { args: vec![], ret: TypeTree::new() },
}
} else {
x = fnc_binder.skip_binder();
}
// If rustc compiles the unmodified primal, we know that this copy of the function
// also has correct lifetimes. We know that Enzyme won't free the shadow too early
// (or actually at all), so let's strip lifetimes when computing the layout.
// Recommended by compiler-errors:
// https://discord.com/channels/273534239310479360/957720175619215380/1223454360676208751
let x = tcx.instantiate_bound_regions_with_erased(fnc_binder);
dbg!("creating fncTree");

let mut offset = 0;
Expand Down
Loading