Skip to content

Commit f19d04e

Browse files
committed
Reintroduce autodiff enable and lto errors
1 parent c65d897 commit f19d04e

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
@@ -32,12 +32,9 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
3232
}
3333
}
3434

35-
// TODO(Sa4dUs): we will need to reintroduce these errors somewhere
36-
/*
3735
#[derive(Diagnostic)]
3836
#[diag(codegen_llvm_autodiff_without_enable)]
3937
pub(crate) struct AutoDiffWithoutEnable;
40-
*/
4138

4239
#[derive(Diagnostic)]
4340
#[diag(codegen_llvm_lto_bitcode_from_rlib)]

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;
@@ -1138,6 +1140,14 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
11381140
args: &[OperandRef<'tcx, &'ll Value>],
11391141
result: PlaceRef<'tcx, &'ll Value>,
11401142
) {
1143+
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
1144+
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
1145+
}
1146+
1147+
if tcx.sess.lto() != Lto::Fat {
1148+
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLTO);
1149+
}
1150+
11411151
let fn_args = instance.args;
11421152
let callee_ty = instance.ty(tcx, bx.typing_env());
11431153

0 commit comments

Comments
 (0)