Skip to content

Commit c65d897

Browse files
committed
Remove dead code
1 parent b77308d commit c65d897

File tree

9 files changed

+7
-204
lines changed

9 files changed

+7
-204
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,7 +4217,6 @@ name = "rustc_monomorphize"
42174217
version = "0.0.0"
42184218
dependencies = [
42194219
"rustc_abi",
4220-
"rustc_ast",
42214220
"rustc_attr_data_structures",
42224221
"rustc_data_structures",
42234222
"rustc_errors",
@@ -4227,7 +4226,6 @@ dependencies = [
42274226
"rustc_middle",
42284227
"rustc_session",
42294228
"rustc_span",
4230-
"rustc_symbol_mangling",
42314229
"rustc_target",
42324230
"serde",
42334231
"serde_json",

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{fs, io, mem, str, thread};
88

99
use rustc_abi::Size;
1010
use rustc_ast::attr;
11-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
1211
use rustc_data_structures::fx::FxIndexMap;
1312
use rustc_data_structures::jobserver::{self, Acquired};
1413
use rustc_data_structures::memmap::Mmap;
@@ -39,7 +38,7 @@ use tracing::debug;
3938
use super::link::{self, ensure_removed};
4039
use super::lto::{self, SerializedModule};
4140
use crate::back::lto::check_lto_allowed;
42-
use crate::errors::{AutodiffWithoutLto, ErrorCreatingRemarkDir};
41+
use crate::errors::ErrorCreatingRemarkDir;
4342
use crate::traits::*;
4443
use crate::{
4544
CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
@@ -455,7 +454,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
455454
backend: B,
456455
tcx: TyCtxt<'_>,
457456
target_cpu: String,
458-
autodiff_items: &[AutoDiffItem],
459457
) -> OngoingCodegen<B> {
460458
let (coordinator_send, coordinator_receive) = channel();
461459

@@ -474,7 +472,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
474472
backend.clone(),
475473
tcx,
476474
&crate_info,
477-
autodiff_items,
478475
shared_emitter,
479476
codegen_worker_send,
480477
coordinator_receive,
@@ -729,7 +726,6 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
729726
each_linked_rlib_for_lto: Vec<PathBuf>,
730727
needs_fat_lto: Vec<FatLtoInput<B>>,
731728
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
732-
autodiff: Vec<AutoDiffItem>,
733729
},
734730
/// Performs thin-LTO on the given module.
735731
ThinLto(lto::ThinModule<B>),
@@ -1003,7 +999,6 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
1003999
each_linked_rlib_for_lto: &[PathBuf],
10041000
mut needs_fat_lto: Vec<FatLtoInput<B>>,
10051001
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
1006-
autodiff: Vec<AutoDiffItem>,
10071002
module_config: &ModuleConfig,
10081003
) -> Result<WorkItemResult<B>, FatalError> {
10091004
for (module, wp) in import_only_modules {
@@ -1015,7 +1010,6 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
10151010
exported_symbols_for_lto,
10161011
each_linked_rlib_for_lto,
10171012
needs_fat_lto,
1018-
autodiff,
10191013
)?;
10201014
let module = B::codegen(cgcx, module, module_config)?;
10211015
Ok(WorkItemResult::Finished(module))
@@ -1119,7 +1113,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
11191113
backend: B,
11201114
tcx: TyCtxt<'_>,
11211115
crate_info: &CrateInfo,
1122-
autodiff_items: &[AutoDiffItem],
11231116
shared_emitter: SharedEmitter,
11241117
codegen_worker_send: Sender<CguMessage>,
11251118
coordinator_receive: Receiver<Box<dyn Any + Send>>,
@@ -1129,7 +1122,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
11291122
) -> thread::JoinHandle<Result<CompiledModules, ()>> {
11301123
let coordinator_send = tx_to_llvm_workers;
11311124
let sess = tcx.sess;
1132-
let autodiff_items = autodiff_items.to_vec();
11331125

11341126
let mut each_linked_rlib_for_lto = Vec::new();
11351127
let mut each_linked_rlib_file_for_lto = Vec::new();
@@ -1464,19 +1456,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
14641456
each_linked_rlib_for_lto: each_linked_rlib_file_for_lto,
14651457
needs_fat_lto,
14661458
import_only_modules,
1467-
autodiff: autodiff_items.clone(),
14681459
},
14691460
0,
14701461
));
14711462
if cgcx.parallel {
14721463
helper.request_token();
14731464
}
14741465
} else {
1475-
if !autodiff_items.is_empty() {
1476-
let dcx = cgcx.create_dcx();
1477-
dcx.handle().emit_fatal(AutodiffWithoutLto {});
1478-
}
1479-
14801466
for (work, cost) in generate_thin_lto_work(
14811467
&cgcx,
14821468
&exported_symbols_for_lto,
@@ -1827,7 +1813,6 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18271813
each_linked_rlib_for_lto,
18281814
needs_fat_lto,
18291815
import_only_modules,
1830-
autodiff,
18311816
} => {
18321817
let _timer = cgcx
18331818
.prof
@@ -1838,7 +1823,6 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18381823
&each_linked_rlib_for_lto,
18391824
needs_fat_lto,
18401825
import_only_modules,
1841-
autodiff,
18421826
module_config,
18431827
)
18441828
}

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
647647
) -> OngoingCodegen<B> {
648648
// Skip crate items and just output metadata in -Z no-codegen mode.
649649
if tcx.sess.opts.unstable_opts.no_codegen || !tcx.sess.opts.output_types.should_codegen() {
650-
let ongoing_codegen = start_async_codegen(backend, tcx, target_cpu, &[]);
650+
let ongoing_codegen = start_async_codegen(backend, tcx, target_cpu);
651651

652652
ongoing_codegen.codegen_finished(tcx);
653653

@@ -665,8 +665,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
665665

666666
// Run the monomorphization collector and partition the collected items into
667667
// codegen units.
668-
let MonoItemPartitions { codegen_units, autodiff_items, .. } =
669-
tcx.collect_and_partition_mono_items(());
668+
let MonoItemPartitions { codegen_units, .. } = tcx.collect_and_partition_mono_items(());
670669

671670
// Force all codegen_unit queries so they are already either red or green
672671
// when compile_codegen_unit accesses them. We are not able to re-execute
@@ -679,7 +678,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
679678
}
680679
}
681680

682-
let ongoing_codegen = start_async_codegen(backend.clone(), tcx, target_cpu, autodiff_items);
681+
let ongoing_codegen = start_async_codegen(backend.clone(), tcx, target_cpu);
683682

684683
// Codegen an allocator shim, if necessary.
685684
if let Some(kind) = allocator_kind_for_codegen(tcx) {

compiler/rustc_codegen_ssa/src/traits/write.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::path::PathBuf;
22

3-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
43
use rustc_errors::{DiagCtxtHandle, FatalError};
54
use rustc_middle::dep_graph::WorkProduct;
65

@@ -29,7 +28,6 @@ pub trait WriteBackendMethods: Clone + 'static {
2928
exported_symbols_for_lto: &[String],
3029
each_linked_rlib_for_lto: &[PathBuf],
3130
modules: Vec<FatLtoInput<Self>>,
32-
diff_fncs: Vec<AutoDiffItem>,
3331
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
3432
/// Performs thin LTO by performing necessary global analysis and returning two
3533
/// lists, one of the modules that need optimization and another for modules that

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::borrow::Cow;
22
use std::fmt;
33
use std::hash::Hash;
44

5-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
65
use rustc_attr_data_structures::InlineAttr;
76
use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
87
use rustc_data_structures::fingerprint::Fingerprint;
@@ -337,7 +336,6 @@ impl ToStableHashKey<StableHashingContext<'_>> for MonoItem<'_> {
337336
pub struct MonoItemPartitions<'tcx> {
338337
pub codegen_units: &'tcx [CodegenUnit<'tcx>],
339338
pub all_mono_items: &'tcx DefIdSet,
340-
pub autodiff_items: &'tcx [AutoDiffItem],
341339
}
342340

343341
#[derive(Debug, HashStable)]

compiler/rustc_monomorphize/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
rustc_abi = { path = "../rustc_abi" }
9-
rustc_ast = { path = "../rustc_ast" }
109
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
1110
rustc_data_structures = { path = "../rustc_data_structures" }
1211
rustc_errors = { path = "../rustc_errors" }
@@ -16,7 +15,6 @@ rustc_macros = { path = "../rustc_macros" }
1615
rustc_middle = { path = "../rustc_middle" }
1716
rustc_session = { path = "../rustc_session" }
1817
rustc_span = { path = "../rustc_span" }
19-
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
2018
rustc_target = { path = "../rustc_target" }
2119
serde = "1"
2220
serde_json = "1"

compiler/rustc_monomorphize/src/collector/autodiff.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub(crate) fn collect_enzyme_autodiff_fn<'tcx>(
1818
};
1919

2020
collect_autodiff_fn_from_arg(instance.args[0], tcx, output);
21-
collect_autodiff_fn_from_arg(instance.args[1], tcx, output);
2221
}
2322

2423
fn collect_autodiff_fn_from_arg<'tcx>(

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@
9292
//! source-level module, functions from the same module will be available for
9393
//! inlining, even when they are not marked `#[inline]`.
9494
95-
mod autodiff;
96-
9795
use std::cmp;
9896
use std::collections::hash_map::Entry;
9997
use std::fs::{self, File};
@@ -251,17 +249,7 @@ where
251249
always_export_generics,
252250
);
253251

254-
// We can't differentiate a function that got inlined.
255-
let autodiff_active = cfg!(llvm_enzyme)
256-
&& matches!(mono_item, MonoItem::Fn(_))
257-
&& cx
258-
.tcx
259-
.codegen_fn_attrs(mono_item.def_id())
260-
.autodiff_item
261-
.as_ref()
262-
.is_some_and(|ad| ad.is_active());
263-
264-
if !autodiff_active && visibility == Visibility::Hidden && can_be_internalized {
252+
if visibility == Visibility::Hidden && can_be_internalized {
265253
internalization_candidates.insert(mono_item);
266254
}
267255
let size_estimate = mono_item.size_estimate(cx.tcx);
@@ -1156,27 +1144,15 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
11561144
}
11571145
}
11581146

1159-
#[cfg(not(llvm_enzyme))]
1160-
let autodiff_mono_items: Vec<_> = vec![];
1161-
#[cfg(llvm_enzyme)]
1162-
let mut autodiff_mono_items: Vec<_> = vec![];
11631147
let mono_items: DefIdSet = items
11641148
.iter()
11651149
.filter_map(|mono_item| match *mono_item {
1166-
MonoItem::Fn(ref instance) => {
1167-
#[cfg(llvm_enzyme)]
1168-
autodiff_mono_items.push((mono_item, instance));
1169-
Some(instance.def_id())
1170-
}
1150+
MonoItem::Fn(ref instance) => Some(instance.def_id()),
11711151
MonoItem::Static(def_id) => Some(def_id),
11721152
_ => None,
11731153
})
11741154
.collect();
11751155

1176-
let autodiff_items =
1177-
autodiff::find_autodiff_source_functions(tcx, &usage_map, autodiff_mono_items);
1178-
let autodiff_items = tcx.arena.alloc_from_iter(autodiff_items);
1179-
11801156
// Output monomorphization stats per def_id
11811157
if let SwitchWithOptPath::Enabled(ref path) = tcx.sess.opts.unstable_opts.dump_mono_stats {
11821158
if let Err(err) =
@@ -1235,11 +1211,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
12351211
}
12361212
}
12371213

1238-
MonoItemPartitions {
1239-
all_mono_items: tcx.arena.alloc(mono_items),
1240-
codegen_units,
1241-
autodiff_items,
1242-
}
1214+
MonoItemPartitions { all_mono_items: tcx.arena.alloc(mono_items), codegen_units }
12431215
}
12441216

12451217
/// Outputs stats about instantiation counts and estimated size, per `MonoItem`'s

0 commit comments

Comments
 (0)