Skip to content

Commit 2f144db

Browse files
committed
Remove dead code
1 parent e9139fe commit 2f144db

File tree

9 files changed

+8
-224
lines changed

9 files changed

+8
-224
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,7 +4190,6 @@ name = "rustc_monomorphize"
41904190
version = "0.0.0"
41914191
dependencies = [
41924192
"rustc_abi",
4193-
"rustc_ast",
41944193
"rustc_attr_data_structures",
41954194
"rustc_data_structures",
41964195
"rustc_errors",
@@ -4200,7 +4199,6 @@ dependencies = [
42004199
"rustc_middle",
42014200
"rustc_session",
42024201
"rustc_span",
4203-
"rustc_symbol_mangling",
42044202
"rustc_target",
42054203
"serde",
42064204
"serde_json",

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ use gccjit::{CType, Context, OptimizationLevel};
9696
#[cfg(feature = "master")]
9797
use gccjit::{TargetInfo, Version};
9898
use rustc_ast::expand::allocator::AllocatorKind;
99-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
10099
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
101100
use rustc_codegen_ssa::back::write::{
102101
CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn,
@@ -433,15 +432,6 @@ impl WriteBackendMethods for GccCodegenBackend {
433432
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
434433
back::write::link(cgcx, dcx, modules)
435434
}
436-
437-
fn autodiff(
438-
_cgcx: &CodegenContext<Self>,
439-
_module: &ModuleCodegen<Self::Module>,
440-
_diff_functions: Vec<AutoDiffItem>,
441-
_config: &ModuleConfig,
442-
) -> Result<(), FatalError> {
443-
unimplemented!()
444-
}
445435
}
446436

447437
/// This is the entrypoint for a hot plugged rustc_codegen_gccjit

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 4 additions & 26 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::{FxHashMap, FxIndexMap};
1312
use rustc_data_structures::jobserver::{self, Acquired};
1413
use rustc_data_structures::memmap::Mmap;
@@ -41,7 +40,7 @@ use tracing::debug;
4140
use super::link::{self, ensure_removed};
4241
use super::lto::{self, SerializedModule};
4342
use super::symbol_export::symbol_name_for_instance_in_crate;
44-
use crate::errors::{AutodiffWithoutLto, ErrorCreatingRemarkDir};
43+
use crate::errors::ErrorCreatingRemarkDir;
4544
use crate::traits::*;
4645
use crate::{
4746
CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
@@ -399,7 +398,6 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
399398

400399
fn generate_lto_work<B: ExtraBackendMethods>(
401400
cgcx: &CodegenContext<B>,
402-
autodiff: Vec<AutoDiffItem>,
403401
needs_fat_lto: Vec<FatLtoInput<B>>,
404402
needs_thin_lto: Vec<(String, B::ThinBuffer)>,
405403
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
@@ -413,10 +411,6 @@ fn generate_lto_work<B: ExtraBackendMethods>(
413411
// We are adding a single work item, so the cost doesn't matter.
414412
vec![(WorkItem::LTO(module), 0)]
415413
} else {
416-
if !autodiff.is_empty() {
417-
let dcx = cgcx.create_dcx();
418-
dcx.handle().emit_fatal(AutodiffWithoutLto {});
419-
}
420414
assert!(needs_fat_lto.is_empty());
421415
let (lto_modules, copy_jobs) = B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules)
422416
.unwrap_or_else(|e| e.raise());
@@ -1027,9 +1021,6 @@ pub(crate) enum Message<B: WriteBackendMethods> {
10271021
/// Sent from a backend worker thread.
10281022
WorkItem { result: Result<WorkItemResult<B>, Option<WorkerFatalError>>, worker_id: usize },
10291023

1030-
/// A vector containing all the AutoDiff tasks that we have to pass to Enzyme.
1031-
AddAutoDiffItems(Vec<AutoDiffItem>),
1032-
10331024
/// The frontend has finished generating something (backend IR or a
10341025
/// post-LTO artifact) for a codegen unit, and it should be passed to the
10351026
/// backend. Sent from the main thread.
@@ -1357,7 +1348,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
13571348

13581349
// This is where we collect codegen units that have gone all the way
13591350
// through codegen and LLVM.
1360-
let mut autodiff_items = Vec::new();
13611351
let mut compiled_modules = vec![];
13621352
let mut compiled_allocator_module = None;
13631353
let mut needs_link = Vec::new();
@@ -1469,13 +1459,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
14691459
let needs_thin_lto = mem::take(&mut needs_thin_lto);
14701460
let import_only_modules = mem::take(&mut lto_import_only_modules);
14711461

1472-
for (work, cost) in generate_lto_work(
1473-
&cgcx,
1474-
autodiff_items.clone(),
1475-
needs_fat_lto,
1476-
needs_thin_lto,
1477-
import_only_modules,
1478-
) {
1462+
for (work, cost) in
1463+
generate_lto_work(&cgcx, needs_fat_lto, needs_thin_lto, import_only_modules)
1464+
{
14791465
let insertion_index = work_items
14801466
.binary_search_by_key(&cost, |&(_, cost)| cost)
14811467
.unwrap_or_else(|e| e);
@@ -1611,10 +1597,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
16111597
main_thread_state = MainThreadState::Idle;
16121598
}
16131599

1614-
Message::AddAutoDiffItems(mut items) => {
1615-
autodiff_items.append(&mut items);
1616-
}
1617-
16181600
Message::CodegenComplete => {
16191601
if codegen_state != Aborted {
16201602
codegen_state = Completed;
@@ -2077,10 +2059,6 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
20772059
drop(self.coordinator.sender.send(Box::new(Message::CodegenComplete::<B>)));
20782060
}
20792061

2080-
pub(crate) fn submit_autodiff_items(&self, items: Vec<AutoDiffItem>) {
2081-
drop(self.coordinator.sender.send(Box::new(Message::<B>::AddAutoDiffItems(items))));
2082-
}
2083-
20842062
pub(crate) fn check_for_errors(&self, sess: &Session) {
20852063
self.shared_emitter_main.check(sess, false);
20862064
}

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
687687

688688
// Run the monomorphization collector and partition the collected items into
689689
// codegen units.
690-
let MonoItemPartitions { codegen_units, autodiff_items, .. } =
691-
tcx.collect_and_partition_mono_items(());
692-
let autodiff_fncs = autodiff_items.to_vec();
690+
let MonoItemPartitions { codegen_units, .. } = tcx.collect_and_partition_mono_items(());
693691

694692
// Force all codegen_unit queries so they are already either red or green
695693
// when compile_codegen_unit accesses them. We are not able to re-execute
@@ -732,10 +730,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
732730
);
733731
}
734732

735-
if !autodiff_fncs.is_empty() {
736-
ongoing_codegen.submit_autodiff_items(autodiff_fncs);
737-
}
738-
739733
// For better throughput during parallel processing by LLVM, we used to sort
740734
// CGUs largest to smallest. This would lead to better thread utilization
741735
// by, for example, preventing a large CGU from being processed last and

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;
@@ -340,7 +339,6 @@ impl ToStableHashKey<StableHashingContext<'_>> for MonoItem<'_> {
340339
pub struct MonoItemPartitions<'tcx> {
341340
pub codegen_units: &'tcx [CodegenUnit<'tcx>],
342341
pub all_mono_items: &'tcx DefIdSet,
343-
pub autodiff_items: &'tcx [AutoDiffItem],
344342
}
345343

346344
#[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};
@@ -255,17 +253,7 @@ where
255253
always_export_generics,
256254
);
257255

258-
// We can't differentiate a function that got inlined.
259-
let autodiff_active = cfg!(llvm_enzyme)
260-
&& matches!(mono_item, MonoItem::Fn(_))
261-
&& cx
262-
.tcx
263-
.codegen_fn_attrs(mono_item.def_id())
264-
.autodiff_item
265-
.as_ref()
266-
.is_some_and(|ad| ad.is_active());
267-
268-
if !autodiff_active && visibility == Visibility::Hidden && can_be_internalized {
256+
if visibility == Visibility::Hidden && can_be_internalized {
269257
internalization_candidates.insert(mono_item);
270258
}
271259
let size_estimate = mono_item.size_estimate(cx.tcx);
@@ -1161,27 +1149,15 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
11611149
}
11621150
}
11631151

1164-
#[cfg(not(llvm_enzyme))]
1165-
let autodiff_mono_items: Vec<_> = vec![];
1166-
#[cfg(llvm_enzyme)]
1167-
let mut autodiff_mono_items: Vec<_> = vec![];
11681152
let mono_items: DefIdSet = items
11691153
.iter()
11701154
.filter_map(|mono_item| match *mono_item {
1171-
MonoItem::Fn(ref instance) => {
1172-
#[cfg(llvm_enzyme)]
1173-
autodiff_mono_items.push((mono_item, instance));
1174-
Some(instance.def_id())
1175-
}
1155+
MonoItem::Fn(ref instance) => Some(instance.def_id()),
11761156
MonoItem::Static(def_id) => Some(def_id),
11771157
_ => None,
11781158
})
11791159
.collect();
11801160

1181-
let autodiff_items =
1182-
autodiff::find_autodiff_source_functions(tcx, &usage_map, autodiff_mono_items);
1183-
let autodiff_items = tcx.arena.alloc_from_iter(autodiff_items);
1184-
11851161
// Output monomorphization stats per def_id
11861162
if let SwitchWithOptPath::Enabled(ref path) = tcx.sess.opts.unstable_opts.dump_mono_stats {
11871163
if let Err(err) =
@@ -1240,11 +1216,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> MonoItemPartitio
12401216
}
12411217
}
12421218

1243-
MonoItemPartitions {
1244-
all_mono_items: tcx.arena.alloc(mono_items),
1245-
codegen_units,
1246-
autodiff_items,
1247-
}
1219+
MonoItemPartitions { all_mono_items: tcx.arena.alloc(mono_items), codegen_units }
12481220
}
12491221

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

0 commit comments

Comments
 (0)