Skip to content

Commit 5ea9125

Browse files
committed
update documentation
1 parent 31578dc commit 5ea9125

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,11 @@ pub(crate) unsafe fn llvm_optimize(
576576
// When we build rustc with enzyme/autodiff support, we want to postpone size-increasing
577577
// optimizations until after differentiation. Our pipeline is thus: (opt + enzyme), (full opt).
578578
// We therefore have two calls to llvm_optimize, if autodiff is used.
579+
//
580+
// We also must disable merge_functions, since autodiff placeholder/dummy bodies tend to be
581+
// identical. We run opts before AD, so there is a chance that LLVM will merge our dummies.
582+
// In that case, we lack some dummy bodies and can't replace them with the real AD code anymore.
583+
// We then would need to abort compilation. This was especially common in test cases.
579584
if consider_ad && autodiff_stage != AutodiffStage::PostAD {
580585
merge_functions = false;
581586
unroll_loops = false;

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ pub(crate) fn differentiate<'ll>(
445445
return Err(diag_handler.handle().emit_almost_fatal(AutoDiffWithoutEnable));
446446
}
447447

448-
// Before dumping the module, we want all the TypeTrees to become part of the module.
448+
// Here we replace the placeholder code with the actual autodiff code, which calls Enzyme.
449449
for item in diff_items.iter() {
450450
let name = item.source.clone();
451451
let fn_def: Option<&llvm::Value> = cx.get_function(&name);

0 commit comments

Comments
 (0)