Skip to content

Commit

Permalink
Auto merge of rust-lang#136413 - EnzymeAD:fix-autodiff-comptime-regre…
Browse files Browse the repository at this point in the history
…ssion, r=oli-obk

fix autodiff compile time regression

Tries to fix the regression from rust-lang#133429

Tracking:

- rust-lang#124509
  • Loading branch information
bors committed Feb 3, 2025
2 parents 7daf4cf + e47caa2 commit a5db378
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ fn generate_lto_work<B: ExtraBackendMethods>(
assert!(needs_thin_lto.is_empty());
let mut module =
B::run_fat_lto(cgcx, needs_fat_lto, import_only_modules).unwrap_or_else(|e| e.raise());
if cgcx.lto == Lto::Fat {
if cgcx.lto == Lto::Fat && !autodiff.is_empty() {
let config = cgcx.config(ModuleKind::Regular);
module = unsafe { module.autodiff(cgcx, autodiff, config).unwrap() };
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,23 +1179,23 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
}
}

#[cfg(not(llvm_enzyme))]
let autodiff_mono_items: Vec<_> = vec![];
#[cfg(llvm_enzyme)]
let mut autodiff_mono_items: Vec<_> = vec![];
let mono_items: DefIdSet = items
.iter()
.filter_map(|mono_item| match *mono_item {
MonoItem::Fn(ref instance) => Some(instance.def_id()),
MonoItem::Fn(ref instance) => {
#[cfg(llvm_enzyme)]
autodiff_mono_items.push((mono_item, instance));
Some(instance.def_id())
}
MonoItem::Static(def_id) => Some(def_id),
_ => None,
})
.collect();

let autodiff_mono_items: Vec<_> = items
.iter()
.filter_map(|item| match *item {
MonoItem::Fn(ref instance) => Some((item, instance)),
_ => None,
})
.collect();

let autodiff_items =
autodiff::find_autodiff_source_functions(tcx, &usage_map, autodiff_mono_items);
let autodiff_items = tcx.arena.alloc_from_iter(autodiff_items);
Expand Down

0 comments on commit a5db378

Please sign in to comment.