Skip to content

Commit 97f0985

Browse files
committed
Reintroduce autodiff enable and lto errors
1 parent 2f144db commit 97f0985

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,13 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
3737
}
3838
}
3939

40-
// TODO(Sa4dUs): we will need to reintroduce these errors somewhere
41-
/*
4240
#[derive(Diagnostic)]
4341
#[diag(codegen_llvm_autodiff_without_lto)]
4442
pub(crate) struct AutoDiffWithoutLTO;
4543

4644
#[derive(Diagnostic)]
4745
#[diag(codegen_llvm_autodiff_without_enable)]
4846
pub(crate) struct AutoDiffWithoutEnable;
49-
*/
5047

5148
#[derive(Diagnostic)]
5249
#[diag(codegen_llvm_lto_disallowed)]

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_middle::mir::BinOp;
1515
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
1616
use rustc_middle::ty::{self, GenericArgsRef, Instance, Ty, TyCtxt, TypingEnv};
1717
use rustc_middle::{bug, span_bug};
18+
use rustc_session::config::Lto;
1819
use rustc_span::{Span, Symbol, sym};
1920
use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
2021
use rustc_target::callconv::PassMode;
@@ -25,6 +26,7 @@ use crate::abi::FnAbiLlvmExt;
2526
use crate::builder::Builder;
2627
use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call};
2728
use crate::context::CodegenCx;
29+
use crate::errors::{AutoDiffWithoutEnable, AutoDiffWithoutLTO};
2830
use crate::llvm::{self, Metadata};
2931
use crate::type_::Type;
3032
use crate::type_of::LayoutLlvmExt;
@@ -1136,6 +1138,14 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
11361138
args: &[OperandRef<'tcx, &'ll Value>],
11371139
result: PlaceRef<'tcx, &'ll Value>,
11381140
) {
1141+
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
1142+
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
1143+
}
1144+
1145+
if tcx.sess.lto() != Lto::Fat {
1146+
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLTO);
1147+
}
1148+
11391149
let fn_args = instance.args;
11401150
let callee_ty = instance.ty(tcx, bx.typing_env());
11411151

0 commit comments

Comments
 (0)