Skip to content

Commit e24e7c4

Browse files
committed
Allow core_intrinsics when autodiff is enabled
1 parent 1bd54a7 commit e24e7c4

File tree

16 files changed

+9
-14
lines changed

16 files changed

+9
-14
lines changed

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ impl<'tcx> TyCtxt<'tcx> {
409409
return EvalResult::Allow;
410410
}
411411

412+
// The `#[autodiff_forward]` and `#[autodiff_reverse]` attribute macros use `enzyme_autodiff` core intrinsic in its expansion.
413+
// To avoid requiring users to manually add `#![feature(core_intrinsics)]`, we allow this feature when `autodiff` is enabled.
414+
if self.features().enabled(sym::autodiff) && feature == sym::core_intrinsics {
415+
return EvalResult::Allow;
416+
}
417+
412418
let suggestion = suggestion_for_allocator_api(self, def_id, span, feature);
413419
EvalResult::Deny {
414420
feature,
@@ -555,6 +561,7 @@ impl<'tcx> TyCtxt<'tcx> {
555561
let is_allowed = matches!(eval_result, EvalResult::Allow);
556562
match eval_result {
557563
EvalResult::Allow => {}
564+
// MARKER(Sa4dUs): Here
558565
EvalResult::Deny { feature, reason, issue, suggestion, is_soft } => report_unstable(
559566
self.sess,
560567
feature,

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ symbols! {
540540
audit_that,
541541
augmented_assignments,
542542
auto_traits,
543+
autodiff,
543544
autodiff_forward,
544545
autodiff_reverse,
545546
automatically_derived,
@@ -750,6 +751,7 @@ symbols! {
750751
copysignf64,
751752
copysignf128,
752753
core,
754+
core_intrinsics,
753755
core_panic,
754756
core_panic_2015_macro,
755757
core_panic_2021_macro,

tests/codegen-llvm/autodiffv2.rs renamed to tests/codegen-llvm/autodiff/autodiffv2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
// in our frontend and in the llvm backend to avoid these issues.
2626

2727
#![feature(autodiff)]
28-
#![feature(core_intrinsics)]
2928

3029
use std::autodiff::autodiff_forward;
3130

tests/codegen-llvm/autodiff/batched.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// reduce this test to only match the first lines and the ret instructions.
1111

1212
#![feature(autodiff)]
13-
#![feature(core_intrinsics)]
1413

1514
use std::autodiff::autodiff_forward;
1615

tests/codegen-llvm/autodiff/generic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ no-prefer-dynamic
33
//@ needs-enzyme
44
#![feature(autodiff)]
5-
#![feature(core_intrinsics)]
65

76
use std::autodiff::autodiff_reverse;
87

tests/codegen-llvm/autodiff/identical_fnc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// We also explicetly test that we keep running merge_function after AD, by checking for two
1111
// identical function calls in the LLVM-IR, while having two different calls in the Rust code.
1212
#![feature(autodiff)]
13-
#![feature(core_intrinsics)]
1413

1514
use std::autodiff::autodiff_reverse;
1615

tests/codegen-llvm/autodiff/scalar.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@ no-prefer-dynamic
33
//@ needs-enzyme
44
#![feature(autodiff)]
5-
#![feature(core_intrinsics)]
65

76
use std::autodiff::autodiff_reverse;
87

tests/codegen-llvm/autodiff/sret.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// We therefore use this test to verify some of our sret handling.
99

1010
#![feature(autodiff)]
11-
#![feature(core_intrinsics)]
1211

1312
use std::autodiff::autodiff_reverse;
1413

tests/codegen-llvm/autodiff/trait.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Just check it does not crash for now
66
// CHECK: ;
77
#![feature(autodiff)]
8-
#![feature(core_intrinsics)]
98

109
use std::autodiff::autodiff_reverse;
1110

tests/pretty/autodiff/autodiff_forward.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//@ needs-enzyme
44

55
#![feature(autodiff)]
6-
#![feature(core_intrinsics)]
76
#[prelude_import]
87
use ::std::prelude::rust_2015::*;
98
#[macro_use]

0 commit comments

Comments
 (0)