Skip to content

Commit e1c1eae

Browse files
committed
cleanup
1 parent 21d0961 commit e1c1eae

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,23 +550,28 @@ pub(crate) unsafe fn llvm_optimize(
550550
let unroll_loops;
551551
let vectorize_slp;
552552
let vectorize_loop;
553+
let run_enzyme;
553554

554-
let run_enzyme = cfg!(llvm_enzyme);
555555
// When we build rustc with enzyme/autodiff support, we want to postpone size-increasing
556-
// optimizations until after differentiation. FIXME(ZuseZ4): Before shipping on nightly,
556+
// optimizations until after differentiation. Our pipeline is thus: (opt + enzyme), (full opt).
557+
// We therefore have two calls to llvm_optimize, if autodiff is used.
558+
//
559+
// FIXME(ZuseZ4): Before shipping on nightly,
557560
// we should make this more granular, or at least check that the user has at least one autodiff
558561
// call in their code, to justify altering the compilation pipeline.
559-
if skip_size_increasing_opts && run_enzyme {
562+
if skip_size_increasing_opts && cfg!(llvm_enzyme) {
560563
unroll_loops = false;
561564
vectorize_slp = false;
562565
vectorize_loop = false;
566+
run_enzyme = true;
563567
} else {
564568
unroll_loops =
565569
opt_level != config::OptLevel::Size && opt_level != config::OptLevel::SizeMin;
566570
vectorize_slp = config.vectorize_slp;
567571
vectorize_loop = config.vectorize_loop;
572+
run_enzyme = false;
568573
}
569-
trace!(?unroll_loops, ?vectorize_slp, ?vectorize_loop);
574+
trace!(?unroll_loops, ?vectorize_slp, ?vectorize_loop, ?run_enzyme);
570575
let using_thin_buffers = opt_stage == llvm::OptStage::PreLinkThinLTO || config.bitcode_needed();
571576
let pgo_gen_path = get_pgo_gen_path(config);
572577
let pgo_use_path = get_pgo_use_path(config);

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ fn generate_enzyme_call<'ll>(
222222
// A duplicated pointer will have the following two outer_fn arguments:
223223
// (..., ptr, ptr, ...). We add the following llvm-ir to our __enzyme call:
224224
// (..., metadata! enzyme_dup, ptr, ptr, ...).
225-
if matches!(diff_activity, DiffActivity::Duplicated | DiffActivity::DuplicatedOnly) {
225+
if matches!(
226+
diff_activity,
227+
DiffActivity::Duplicated | DiffActivity::DuplicatedOnly
228+
) {
226229
assert!(
227230
llvm::LLVMRustGetTypeKind(next_outer_ty) == llvm::TypeKind::Pointer
228231
);

0 commit comments

Comments
 (0)