File tree 2 files changed +6
-1
lines changed
compiler/rustc_codegen_llvm/src
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -576,6 +576,11 @@ pub(crate) unsafe fn llvm_optimize(
576
576
// When we build rustc with enzyme/autodiff support, we want to postpone size-increasing
577
577
// optimizations until after differentiation. Our pipeline is thus: (opt + enzyme), (full opt).
578
578
// 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.
579
584
if consider_ad && autodiff_stage != AutodiffStage :: PostAD {
580
585
merge_functions = false ;
581
586
unroll_loops = false ;
Original file line number Diff line number Diff line change @@ -445,7 +445,7 @@ pub(crate) fn differentiate<'ll>(
445
445
return Err ( diag_handler. handle ( ) . emit_almost_fatal ( AutoDiffWithoutEnable ) ) ;
446
446
}
447
447
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 .
449
449
for item in diff_items. iter ( ) {
450
450
let name = item. source . clone ( ) ;
451
451
let fn_def: Option < & llvm:: Value > = cx. get_function ( & name) ;
You can’t perform that action at this time.
0 commit comments