Skip to content

Commit 1e09cea

Browse files
committed
Remove dead code
1 parent 04f64af commit 1e09cea

File tree

11 files changed

+9
-212
lines changed

11 files changed

+9
-212
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4307,7 +4307,6 @@ name = "rustc_monomorphize"
43074307
version = "0.0.0"
43084308
dependencies = [
43094309
"rustc_abi",
4310-
"rustc_ast",
43114310
"rustc_data_structures",
43124311
"rustc_errors",
43134312
"rustc_fluent_macro",
@@ -4316,7 +4315,6 @@ dependencies = [
43164315
"rustc_middle",
43174316
"rustc_session",
43184317
"rustc_span",
4319-
"rustc_symbol_mangling",
43204318
"rustc_target",
43214319
"serde",
43224320
"serde_json",

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use context::SimpleCx;
3030
use errors::ParseTargetMachineConfig;
3131
use llvm_util::target_config;
3232
use rustc_ast::expand::allocator::AllocatorKind;
33-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
3433
use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule};
3534
use rustc_codegen_ssa::back::write::{
3635
CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryConfig, TargetMachineFactoryFn,
@@ -173,15 +172,10 @@ impl WriteBackendMethods for LlvmCodegenBackend {
173172
exported_symbols_for_lto: &[String],
174173
each_linked_rlib_for_lto: &[PathBuf],
175174
modules: Vec<FatLtoInput<Self>>,
176-
diff_fncs: Vec<AutoDiffItem>,
177175
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
178176
let mut module =
179177
back::lto::run_fat(cgcx, exported_symbols_for_lto, each_linked_rlib_for_lto, modules)?;
180178

181-
if !diff_fncs.is_empty() {
182-
builder::autodiff::differentiate(&module, cgcx, diff_fncs)?;
183-
}
184-
185179
let dcx = cgcx.create_dcx();
186180
let dcx = dcx.handle();
187181
back::lto::run_pass_manager(cgcx, dcx, &mut module, false)?;

compiler/rustc_codegen_ssa/src/back/write.rs

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

88
use rustc_abi::Size;
99
use rustc_ast::attr;
10-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
1110
use rustc_data_structures::fx::FxIndexMap;
1211
use rustc_data_structures::jobserver::{self, Acquired};
1312
use rustc_data_structures::memmap::Mmap;
@@ -38,7 +37,7 @@ use tracing::debug;
3837
use super::link::{self, ensure_removed};
3938
use super::lto::{self, SerializedModule};
4039
use crate::back::lto::check_lto_allowed;
41-
use crate::errors::{AutodiffWithoutLto, ErrorCreatingRemarkDir};
40+
use crate::errors::ErrorCreatingRemarkDir;
4241
use crate::traits::*;
4342
use crate::{
4443
CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
@@ -454,7 +453,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
454453
backend: B,
455454
tcx: TyCtxt<'_>,
456455
target_cpu: String,
457-
autodiff_items: &[AutoDiffItem],
458456
) -> OngoingCodegen<B> {
459457
let (coordinator_send, coordinator_receive) = channel();
460458

@@ -473,7 +471,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
473471
backend.clone(),
474472
tcx,
475473
&crate_info,
476-
autodiff_items,
477474
shared_emitter,
478475
codegen_worker_send,
479476
coordinator_receive,
@@ -728,7 +725,6 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
728725
each_linked_rlib_for_lto: Vec<PathBuf>,
729726
needs_fat_lto: Vec<FatLtoInput<B>>,
730727
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
731-
autodiff: Vec<AutoDiffItem>,
732728
},
733729
/// Performs thin-LTO on the given module.
734730
ThinLto(lto::ThinModule<B>),
@@ -1001,7 +997,6 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
1001997
each_linked_rlib_for_lto: &[PathBuf],
1002998
mut needs_fat_lto: Vec<FatLtoInput<B>>,
1003999
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
1004-
autodiff: Vec<AutoDiffItem>,
10051000
module_config: &ModuleConfig,
10061001
) -> Result<WorkItemResult<B>, FatalError> {
10071002
for (module, wp) in import_only_modules {
@@ -1013,7 +1008,6 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
10131008
exported_symbols_for_lto,
10141009
each_linked_rlib_for_lto,
10151010
needs_fat_lto,
1016-
autodiff,
10171011
)?;
10181012
let module = B::codegen(cgcx, module, module_config)?;
10191013
Ok(WorkItemResult::Finished(module))
@@ -1105,7 +1099,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
11051099
backend: B,
11061100
tcx: TyCtxt<'_>,
11071101
crate_info: &CrateInfo,
1108-
autodiff_items: &[AutoDiffItem],
11091102
shared_emitter: SharedEmitter,
11101103
codegen_worker_send: Sender<CguMessage>,
11111104
coordinator_receive: Receiver<Message<B>>,
@@ -1115,7 +1108,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
11151108
) -> thread::JoinHandle<Result<CompiledModules, ()>> {
11161109
let coordinator_send = tx_to_llvm_workers;
11171110
let sess = tcx.sess;
1118-
let autodiff_items = autodiff_items.to_vec();
11191111

11201112
let mut each_linked_rlib_for_lto = Vec::new();
11211113
let mut each_linked_rlib_file_for_lto = Vec::new();
@@ -1448,19 +1440,13 @@ fn start_executing_work<B: ExtraBackendMethods>(
14481440
each_linked_rlib_for_lto: each_linked_rlib_file_for_lto,
14491441
needs_fat_lto,
14501442
import_only_modules,
1451-
autodiff: autodiff_items.clone(),
14521443
},
14531444
0,
14541445
));
14551446
if cgcx.parallel {
14561447
helper.request_token();
14571448
}
14581449
} else {
1459-
if !autodiff_items.is_empty() {
1460-
let dcx = cgcx.create_dcx();
1461-
dcx.handle().emit_fatal(AutodiffWithoutLto {});
1462-
}
1463-
14641450
for (work, cost) in generate_thin_lto_work(
14651451
&cgcx,
14661452
&exported_symbols_for_lto,
@@ -1795,7 +1781,6 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
17951781
each_linked_rlib_for_lto,
17961782
needs_fat_lto,
17971783
import_only_modules,
1798-
autodiff,
17991784
} => {
18001785
let _timer = cgcx
18011786
.prof
@@ -1806,7 +1791,6 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
18061791
&each_linked_rlib_for_lto,
18071792
needs_fat_lto,
18081793
import_only_modules,
1809-
autodiff,
18101794
module_config,
18111795
)
18121796
}

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/codegen_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ fn inherited_align<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<Align> {
624624
/// placeholder functions. We wrote the rustc_autodiff attributes ourself, so this should never
625625
/// panic, unless we introduced a bug when parsing the autodiff macro.
626626
//FIXME(jdonszelmann): put in the main loop. No need to have two..... :/ Let's do that when we make autodiff parsed.
627-
fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> {
627+
pub fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> {
628628
let attrs = tcx.get_attrs(id, sym::rustc_autodiff);
629629

630630
let attrs = attrs.filter(|attr| attr.has_name(sym::rustc_autodiff)).collect::<Vec<_>>();

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

@@ -23,7 +22,6 @@ pub trait WriteBackendMethods: Clone + 'static {
2322
exported_symbols_for_lto: &[String],
2423
each_linked_rlib_for_lto: &[PathBuf],
2524
modules: Vec<FatLtoInput<Self>>,
26-
diff_fncs: Vec<AutoDiffItem>,
2725
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
2826
/// Performs thin LTO by performing necessary global analysis and returning two
2927
/// 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_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
76
use rustc_data_structures::fingerprint::Fingerprint;
87
use rustc_data_structures::fx::FxIndexMap;
@@ -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_data_structures = { path = "../rustc_data_structures" }
1110
rustc_errors = { path = "../rustc_errors" }
1211
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
@@ -15,7 +14,6 @@ rustc_macros = { path = "../rustc_macros" }
1514
rustc_middle = { path = "../rustc_middle" }
1615
rustc_session = { path = "../rustc_session" }
1716
rustc_span = { path = "../rustc_span" }
18-
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
1917
rustc_target = { path = "../rustc_target" }
2018
serde = "1"
2119
serde_json = "1"

compiler/rustc_monomorphize/src/collector/autodiff.rs

Lines changed: 1 addition & 2 deletions
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>(
@@ -27,7 +26,7 @@ fn collect_autodiff_fn_from_arg<'tcx>(
2726
output: &mut MonoItems<'tcx>,
2827
) {
2928
let (instance, span) = match arg.kind() {
30-
rustc_middle::infer::canonical::ir::GenericArgKind::Type(ty) => match ty.kind() {
29+
ty::GenericArgKind::Type(ty) => match ty.kind() {
3130
ty::FnDef(def_id, substs) => {
3231
let span = tcx.def_span(def_id);
3332
let instance = ty::Instance::expect_resolve(

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
&& let Err(err) =
@@ -1234,11 +1210,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
12341210
}
12351211
}
12361212

1237-
MonoItemPartitions {
1238-
all_mono_items: tcx.arena.alloc(mono_items),
1239-
codegen_units,
1240-
autodiff_items,
1241-
}
1213+
MonoItemPartitions { all_mono_items: tcx.arena.alloc(mono_items), codegen_units }
12421214
}
12431215

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

0 commit comments

Comments
 (0)