Skip to content

Commit 94a8bb0

Browse files
committed
fix fn_cg_attrs
1 parent 2b96629 commit 94a8bb0

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,5 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> {
973973
}
974974

975975
pub(crate) fn provide(providers: &mut Providers) {
976-
*providers =
977-
Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
976+
*providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
978977
}

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,20 +254,18 @@ where
254254
always_export_generics,
255255
);
256256

257-
// TODO: This currently crashes compilation:
258-
// thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:242:1:
259-
// DefId(2:45681 ~ core[1460]::iter::adapters::copied::Copied) does not have a "codegen_fn_attrs"
260-
//
261257
// We can't differentiate something that got inlined.
262-
let autodiff_active = cfg!(llvm_enzyme) && {
263-
characteristic_def_id
264-
.and_then(|def_id| cx.tcx.codegen_fn_attrs(def_id).autodiff_item.as_ref())
265-
.is_some_and(|ad| ad.is_active())
266-
};
267-
268-
//if !autodiff_active && visibility == Visibility::Hidden && can_be_internalized {
269-
// internalization_candidates.insert(mono_item);
270-
//}
258+
let autodiff_active = cfg!(llvm_enzyme)
259+
&& cx
260+
.tcx
261+
.codegen_fn_attrs(mono_item.def_id())
262+
.autodiff_item
263+
.as_ref()
264+
.is_some_and(|ad| ad.is_active());
265+
266+
if !autodiff_active && visibility == Visibility::Hidden && can_be_internalized {
267+
internalization_candidates.insert(mono_item);
268+
}
271269
let size_estimate = mono_item.size_estimate(cx.tcx);
272270

273271
cgu.items_mut().insert(mono_item, MonoItemData {
@@ -1275,7 +1273,9 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
12751273
MonoItem::Fn(ref instance_s) => {
12761274
let source_id = instance_s.def_id();
12771275
//if tcx.autodiff_attrs(source_id).is_active() {
1278-
if let Some(ad) = &tcx.codegen_fn_attrs(source_id).autodiff_item && ad.is_active() {
1276+
if let Some(ad) = &tcx.codegen_fn_attrs(source_id).autodiff_item
1277+
&& ad.is_active()
1278+
{
12791279
return Some(instance_s);
12801280
}
12811281
None

0 commit comments

Comments
 (0)