File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 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(
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 ;
Original file line number Diff line number Diff 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) ;
You can’t perform that action at this time.
0 commit comments