Skip to content

Commit 0c18788

Browse files
committed
fix "could not find source function" error by preventing function merging before AD
1 parent ca9b12b commit 0c18788

File tree

1 file changed

+4
-1
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+4
-1
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ pub(crate) unsafe fn llvm_optimize(
568568
let print_before_enzyme = config.autodiff.contains(&config::AutoDiff::PrintModBefore);
569569
let print_after_enzyme = config.autodiff.contains(&config::AutoDiff::PrintModAfter);
570570
let print_passes = config.autodiff.contains(&config::AutoDiff::PrintPasses);
571+
let merge_functions;
571572
let unroll_loops;
572573
let vectorize_slp;
573574
let vectorize_loop;
@@ -576,12 +577,14 @@ pub(crate) unsafe fn llvm_optimize(
576577
// optimizations until after differentiation. Our pipeline is thus: (opt + enzyme), (full opt).
577578
// We therefore have two calls to llvm_optimize, if autodiff is used.
578579
if consider_ad && autodiff_stage != AutodiffStage::PostAD {
580+
merge_functions = false;
579581
unroll_loops = false;
580582
vectorize_slp = false;
581583
vectorize_loop = false;
582584
} else {
583585
unroll_loops =
584586
opt_level != config::OptLevel::Size && opt_level != config::OptLevel::SizeMin;
587+
merge_functions = config.merge_functions;
585588
vectorize_slp = config.vectorize_slp;
586589
vectorize_loop = config.vectorize_loop;
587590
}
@@ -659,7 +662,7 @@ pub(crate) unsafe fn llvm_optimize(
659662
thin_lto_buffer,
660663
config.emit_thin_lto,
661664
config.emit_thin_lto_summary,
662-
config.merge_functions,
665+
merge_functions,
663666
unroll_loops,
664667
vectorize_slp,
665668
vectorize_loop,

0 commit comments

Comments
 (0)