Skip to content

Commit 0597d21

Browse files
committed
small code quality improvements
1 parent b28d354 commit 0597d21

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::ptr;
22

33
use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, AutoDiffItem, DiffActivity, DiffMode};
4-
use rustc_codegen_ssa::ModuleCodegen;
54
use rustc_codegen_ssa::back::write::ModuleConfig;
65
use rustc_errors::FatalError;
76
use tracing::{debug, trace};
@@ -276,7 +275,7 @@ fn generate_enzyme_call<'ll>(
276275
}
277276

278277
pub(crate) fn differentiate<'ll>(
279-
module: &'ll ModuleCodegen<ModuleLlvm>,
278+
module_llvm: &'ll ModuleLlvm,
280279
cgcx: &CodegenContext<LlvmCodegenBackend>,
281280
diff_items: Vec<AutoDiffItem>,
282281
_config: &ModuleConfig,
@@ -286,7 +285,7 @@ pub(crate) fn differentiate<'ll>(
286285
}
287286

288287
let diag_handler = cgcx.create_dcx();
289-
let cx = SimpleCx { llmod: module.module_llvm.llmod(), llcx: module.module_llvm.llcx };
288+
let cx = SimpleCx { llmod: module_llvm.llmod(), llcx: module_llvm.llcx };
290289

291290
// First of all, did the user try to use autodiff without using the -Zautodiff=Enable flag?
292291
if !diff_items.is_empty()

compiler/rustc_codegen_llvm/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ impl WriteBackendMethods for LlvmCodegenBackend {
241241
let dcx = cgcx.create_dcx();
242242
return Err(dcx.handle().emit_almost_fatal(AutoDiffWithoutLTO));
243243
}
244-
builder::autodiff::differentiate(module, cgcx, diff_fncs, config)
244+
let module_llvm = &module.module_llvm;
245+
builder::autodiff::differentiate(module_llvm, cgcx, diff_fncs, config)
245246
}
246247
}
247248

compiler/rustc_codegen_ssa/src/back/write.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1473,13 +1473,14 @@ fn start_executing_work<B: ExtraBackendMethods>(
14731473
assert!(!started_lto);
14741474
started_lto = true;
14751475

1476+
let autodiff_items = mem::take(&mut autodiff_items);
14761477
let needs_fat_lto = mem::take(&mut needs_fat_lto);
14771478
let needs_thin_lto = mem::take(&mut needs_thin_lto);
14781479
let import_only_modules = mem::take(&mut lto_import_only_modules);
14791480

14801481
for (work, cost) in generate_lto_work(
14811482
&cgcx,
1482-
autodiff_items.clone(),
1483+
autodiff_items,
14831484
needs_fat_lto,
14841485
needs_thin_lto,
14851486
import_only_modules,

0 commit comments

Comments
 (0)