Skip to content

Commit 6f61d6a

Browse files
committed
small code quality improvements
1 parent b28d354 commit 6f61d6a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fn generate_enzyme_call<'ll>(
276276
}
277277

278278
pub(crate) fn differentiate<'ll>(
279-
module: &'ll ModuleCodegen<ModuleLlvm>,
279+
module_llvm: &'ll ModuleLlvm,
280280
cgcx: &CodegenContext<LlvmCodegenBackend>,
281281
diff_items: Vec<AutoDiffItem>,
282282
_config: &ModuleConfig,
@@ -286,7 +286,7 @@ pub(crate) fn differentiate<'ll>(
286286
}
287287

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

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

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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)