Skip to content

Rollup of 9 pull requests #136811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1ba2153
Enable sanitizers on MSVC CI jobs
tmiasko Jan 27, 2025
335151f
adding first autodiff test
ZuseZ4 Feb 2, 2025
dfca140
Add Four Codegen Tests
veera-sivarajan Dec 21, 2024
70b9ba3
fix fwd-mode autodiff case
ZuseZ4 Feb 5, 2025
ed2823c
ci: upgrade to crosstool-ng 1.27.0
heiher Feb 6, 2025
8f87e80
get tests to work without -Z/-C flags
ZuseZ4 Feb 7, 2025
38a8302
Update `compiler-builtins` to 0.1.146
tgross35 Feb 7, 2025
3a44180
update enzyme core to provide c bindings
ZuseZ4 Feb 7, 2025
6345b59
simplify autodiff tests to run without local path
ZuseZ4 Feb 7, 2025
a6e5527
fix autodiff perf by running the enzyme opt pass before autodiff
ZuseZ4 Feb 8, 2025
21d0961
fix non-enzyme builds
ZuseZ4 Feb 8, 2025
8eba29a
rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync"
safinaskar Feb 8, 2025
3580698
tests: issue-122805 -> dont-shuffle-bswaps
workingjubilee Feb 10, 2025
d42d20d
tests: simplify dont-shuffle-bswaps test
workingjubilee Feb 10, 2025
2ea7953
tests/codegen: use -Copt-level=3 instead of -O
workingjubilee Feb 9, 2025
3f50076
compiler: gate `extern "{abi}"` in ast_lowering
workingjubilee Nov 4, 2024
90c50f0
compiler: start using rustc_ast_lowering in rustc_passes
workingjubilee Feb 5, 2025
ca19347
tests: error strings for ABI stability now match
workingjubilee Feb 5, 2025
54ff6e0
compiler: remove rustc_target::spec::abi reexports
workingjubilee Feb 5, 2025
cd9d39e
compiler: remove `abi`-specific `extern "{abi}"` suggestions
workingjubilee Feb 7, 2025
1221cff
move second opt run to lto phase and cleanup code
ZuseZ4 Feb 10, 2025
061abbc
remove outdated *First autodiff variants for higher-order ad
ZuseZ4 Feb 10, 2025
18b9ee7
add x86-sse2 (32bit) ABI that requires SSE2 target feature
RalfJung Jan 29, 2025
a2fe644
x86-sse2 ABI: use SSE registers for floats and SIMD
RalfJung Jan 29, 2025
c26f1ab
Rollup merge of #134626 - veera-sivarajan:five-codegen-tests, r=Mark-…
workingjubilee Feb 10, 2025
4656104
Rollup merge of #135408 - RalfJung:x86-sse2, r=workingjubilee
workingjubilee Feb 10, 2025
dd2bd47
Rollup merge of #136155 - tmiasko:msvc-enable-sanitizers, r=Mark-Simu…
workingjubilee Feb 10, 2025
7547483
Rollup merge of #136419 - EnzymeAD:autodiff-tests, r=onur-ozkan,jieyouxu
workingjubilee Feb 10, 2025
77d876c
Rollup merge of #136603 - workingjubilee:move-abi-versioning-into-ast…
workingjubilee Feb 10, 2025
a7b3520
Rollup merge of #136628 - heiher:crosstool-ng-1.27, r=Mark-Simulacrum
workingjubilee Feb 10, 2025
24bc002
Rollup merge of #136714 - tgross35:update-builtins, r=tgross35
workingjubilee Feb 10, 2025
dcbcc2d
Rollup merge of #136731 - safinaskar:parallel-2025-02-08-07-22, r=Spa…
workingjubilee Feb 10, 2025
563390f
Rollup merge of #136761 - workingjubilee:specify-opt-level-for-codege…
workingjubilee Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3336,7 +3336,6 @@ dependencies = [
"rand 0.8.5",
"rand_xoshiro",
"rustc_data_structures",
"rustc_feature",
"rustc_index",
"rustc_macros",
"rustc_serialize",
Expand Down Expand Up @@ -3398,6 +3397,7 @@ dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
Expand Down Expand Up @@ -3702,6 +3702,7 @@ version = "0.0.0"
dependencies = [
"ctrlc",
"libc",
"rustc_abi",
"rustc_ast",
"rustc_ast_lowering",
"rustc_ast_passes",
Expand Down Expand Up @@ -4357,6 +4358,7 @@ version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_ast",
"rustc_ast_lowering",
"rustc_ast_pretty",
"rustc_attr_parsing",
"rustc_data_structures",
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ bitflags = "2.4.1"
rand = { version = "0.8.4", default-features = false, optional = true }
rand_xoshiro = { version = "0.6.0", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rustc_feature = { path = "../rustc_feature", optional = true }
rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true }
rustc_serialize = { path = "../rustc_serialize", optional = true }
Expand All @@ -24,7 +23,6 @@ default = ["nightly", "randomize"]
# without depending on rustc_data_structures, rustc_macros and rustc_serialize
nightly = [
"dep:rustc_data_structures",
"dep:rustc_feature",
"dep:rustc_macros",
"dep:rustc_serialize",
"dep:rustc_span",
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_abi/src/callconv.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#[cfg(feature = "nightly")]
use crate::{BackendRepr, FieldsShape, TyAbiInterface, TyAndLayout};
use crate::{Primitive, Size, Variants};
use crate::{BackendRepr, FieldsShape, Primitive, Size, TyAbiInterface, TyAndLayout, Variants};

mod reg;

Expand Down
130 changes: 9 additions & 121 deletions compiler/rustc_abi/src/extern_abi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt;

use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::{Span, Symbol, sym};

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -95,14 +94,14 @@ impl Abi {

#[derive(Copy, Clone)]
pub struct AbiData {
abi: Abi,
pub abi: Abi,

/// Name of this ABI as we like it called.
name: &'static str,
pub name: &'static str,
}

#[allow(non_upper_case_globals)]
const AbiDatas: &[AbiData] = &[
pub const AbiDatas: &[AbiData] = &[
AbiData { abi: Abi::Rust, name: "Rust" },
AbiData { abi: Abi::C { unwind: false }, name: "C" },
AbiData { abi: Abi::C { unwind: true }, name: "C-unwind" },
Expand Down Expand Up @@ -142,129 +141,18 @@ const AbiDatas: &[AbiData] = &[
];

#[derive(Copy, Clone, Debug)]
pub enum AbiUnsupported {
Unrecognized,
Reason { explain: &'static str },
}

pub struct AbiUnsupported {}
/// Returns the ABI with the given name (if any).
pub fn lookup(name: &str) -> Result<Abi, AbiUnsupported> {
AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi).ok_or_else(|| match name {
"riscv-interrupt" => AbiUnsupported::Reason {
explain: "please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively",
},
"riscv-interrupt-u" => AbiUnsupported::Reason {
explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314",
},
"wasm" => AbiUnsupported::Reason {
explain: "non-standard wasm ABI is no longer supported",
},

_ => AbiUnsupported::Unrecognized,

})
}

pub fn all_names() -> Vec<&'static str> {
AbiDatas.iter().map(|d| d.name).collect()
}

pub fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> {
AbiDatas
.iter()
.map(|d| d.name)
.filter(|name| is_enabled(features, span, name).is_ok())
.collect()
.find(|abi_data| name == abi_data.name)
.map(|&x| x.abi)
.ok_or_else(|| AbiUnsupported {})
}

pub enum AbiDisabled {
Unstable { feature: Symbol, explain: &'static str },
Unrecognized,
}

pub fn is_enabled(
features: &rustc_feature::Features,
span: Span,
name: &str,
) -> Result<(), AbiDisabled> {
let s = is_stable(name);
if let Err(AbiDisabled::Unstable { feature, .. }) = s {
if features.enabled(feature) || span.allows_unstable(feature) {
return Ok(());
}
}
s
}

/// Returns whether the ABI is stable to use.
///
/// Note that there is a separate check determining whether the ABI is even supported
/// on the current target; see `fn is_abi_supported` in `rustc_target::spec`.
pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
match name {
// Stable
"Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind"
| "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind"
| "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" | "thiscall"
| "thiscall-unwind" => Ok(()),
"rust-intrinsic" => Err(AbiDisabled::Unstable {
feature: sym::intrinsics,
explain: "intrinsics are subject to change",
}),
"vectorcall" => Err(AbiDisabled::Unstable {
feature: sym::abi_vectorcall,
explain: "vectorcall is experimental and subject to change",
}),
"vectorcall-unwind" => Err(AbiDisabled::Unstable {
feature: sym::abi_vectorcall,
explain: "vectorcall-unwind ABI is experimental and subject to change",
}),
"rust-call" => Err(AbiDisabled::Unstable {
feature: sym::unboxed_closures,
explain: "rust-call ABI is subject to change",
}),
"rust-cold" => Err(AbiDisabled::Unstable {
feature: sym::rust_cold_cc,
explain: "rust-cold is experimental and subject to change",
}),
"ptx-kernel" => Err(AbiDisabled::Unstable {
feature: sym::abi_ptx,
explain: "PTX ABIs are experimental and subject to change",
}),
"unadjusted" => Err(AbiDisabled::Unstable {
feature: sym::abi_unadjusted,
explain: "unadjusted ABI is an implementation detail and perma-unstable",
}),
"msp430-interrupt" => Err(AbiDisabled::Unstable {
feature: sym::abi_msp430_interrupt,
explain: "msp430-interrupt ABI is experimental and subject to change",
}),
"x86-interrupt" => Err(AbiDisabled::Unstable {
feature: sym::abi_x86_interrupt,
explain: "x86-interrupt ABI is experimental and subject to change",
}),
"gpu-kernel" => Err(AbiDisabled::Unstable {
feature: sym::abi_gpu_kernel,
explain: "gpu-kernel ABI is experimental and subject to change",
}),
"avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable {
feature: sym::abi_avr_interrupt,
explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
}),
"riscv-interrupt-m" | "riscv-interrupt-s" => Err(AbiDisabled::Unstable {
feature: sym::abi_riscv_interrupt,
explain: "riscv-interrupt ABIs are experimental and subject to change",
}),
"C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable {
feature: sym::abi_c_cmse_nonsecure_call,
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
}),
"C-cmse-nonsecure-entry" => Err(AbiDisabled::Unstable {
feature: sym::cmse_nonsecure_entry,
explain: "C-cmse-nonsecure-entry ABI is experimental and subject to change",
}),
_ => Err(AbiDisabled::Unrecognized),
}
pub fn all_names() -> Vec<&'static str> {
AbiDatas.iter().map(|d| d.name).collect()
}

impl Abi {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/extern_abi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn lookup_cdecl() {
#[test]
fn lookup_baz() {
let abi = lookup("baz");
assert_matches!(abi, Err(AbiUnsupported::Unrecognized));
assert_matches!(abi, Err(AbiUnsupported {}));
}

#[test]
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ mod extern_abi;

pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
#[cfg(feature = "nightly")]
pub use extern_abi::{
AbiDisabled, AbiUnsupported, ExternAbi, all_names, enabled_names, is_enabled, is_stable, lookup,
};
pub use extern_abi::{AbiDatas, AbiUnsupported, ExternAbi, all_names, lookup};
#[cfg(feature = "nightly")]
pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
pub use layout::{LayoutCalculator, LayoutCalculatorError};
Expand Down
24 changes: 6 additions & 18 deletions compiler/rustc_ast/src/expand/autodiff_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ pub enum DiffMode {
Forward,
/// The target function, to be created using reverse mode AD.
Reverse,
/// The target function, to be created using forward mode AD.
/// This target function will also be used as a source for higher order derivatives,
/// so compute it before all Forward/Reverse targets and optimize it through llvm.
ForwardFirst,
/// The target function, to be created using reverse mode AD.
/// This target function will also be used as a source for higher order derivatives,
/// so compute it before all Forward/Reverse targets and optimize it through llvm.
ReverseFirst,
}

/// Dual and Duplicated (and their Only variants) are getting lowered to the same Enzyme Activity.
Expand Down Expand Up @@ -92,10 +84,10 @@ pub struct AutoDiffAttrs {

impl DiffMode {
pub fn is_rev(&self) -> bool {
matches!(self, DiffMode::Reverse | DiffMode::ReverseFirst)
matches!(self, DiffMode::Reverse)
}
pub fn is_fwd(&self) -> bool {
matches!(self, DiffMode::Forward | DiffMode::ForwardFirst)
matches!(self, DiffMode::Forward)
}
}

Expand All @@ -106,8 +98,6 @@ impl Display for DiffMode {
DiffMode::Source => write!(f, "Source"),
DiffMode::Forward => write!(f, "Forward"),
DiffMode::Reverse => write!(f, "Reverse"),
DiffMode::ForwardFirst => write!(f, "ForwardFirst"),
DiffMode::ReverseFirst => write!(f, "ReverseFirst"),
}
}
}
Expand All @@ -125,12 +115,12 @@ pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool {
match mode {
DiffMode::Error => false,
DiffMode::Source => false,
DiffMode::Forward | DiffMode::ForwardFirst => {
DiffMode::Forward => {
activity == DiffActivity::Dual
|| activity == DiffActivity::DualOnly
|| activity == DiffActivity::Const
}
DiffMode::Reverse | DiffMode::ReverseFirst => {
DiffMode::Reverse => {
activity == DiffActivity::Const
|| activity == DiffActivity::Active
|| activity == DiffActivity::ActiveOnly
Expand Down Expand Up @@ -166,10 +156,10 @@ pub fn valid_input_activity(mode: DiffMode, activity: DiffActivity) -> bool {
return match mode {
DiffMode::Error => false,
DiffMode::Source => false,
DiffMode::Forward | DiffMode::ForwardFirst => {
DiffMode::Forward => {
matches!(activity, Dual | DualOnly | Const)
}
DiffMode::Reverse | DiffMode::ReverseFirst => {
DiffMode::Reverse => {
matches!(activity, Active | ActiveOnly | Duplicated | DuplicatedOnly | Const)
}
};
Expand Down Expand Up @@ -200,8 +190,6 @@ impl FromStr for DiffMode {
"Source" => Ok(DiffMode::Source),
"Forward" => Ok(DiffMode::Forward),
"Reverse" => Ok(DiffMode::Reverse),
"ForwardFirst" => Ok(DiffMode::ForwardFirst),
"ReverseFirst" => Ok(DiffMode::ReverseFirst),
_ => Err(()),
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ use std::iter;
use ast::visit::Visitor;
use hir::def::{DefKind, PartialRes, Res};
use hir::{BodyId, HirId};
use rustc_abi::ExternAbi;
use rustc_ast::*;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::DefId;
use rustc_middle::span_bug;
use rustc_middle::ty::{Asyncness, ResolverAstLowering};
use rustc_span::{Ident, Span};
use rustc_target::spec::abi;
use {rustc_ast as ast, rustc_hir as hir};

use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode};
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
safety: hir::Safety::Safe.into(),
constness: hir::Constness::NotConst,
asyncness: hir::IsAsync::NotAsync,
abi: abi::Abi::Rust,
abi: ExternAbi::Rust,
}
}

Expand Down
17 changes: 1 addition & 16 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_errors::DiagArgFromDisplay;
use rustc_errors::codes::*;
use rustc_errors::{Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};

Expand Down Expand Up @@ -32,8 +32,6 @@ pub(crate) struct InvalidAbi {
pub abi: Symbol,
pub command: String,
#[subdiagnostic]
pub explain: Option<InvalidAbiReason>,
#[subdiagnostic]
pub suggestion: Option<InvalidAbiSuggestion>,
}

Expand All @@ -45,19 +43,6 @@ pub(crate) struct TupleStructWithDefault {
pub span: Span,
}

pub(crate) struct InvalidAbiReason(pub &'static str);

impl Subdiagnostic for InvalidAbiReason {
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
self,
diag: &mut Diag<'_, G>,
_: &F,
) {
#[allow(rustc::untranslatable_diagnostic)]
diag.note(self.0);
}
}

#[derive(Subdiagnostic)]
#[suggestion(
ast_lowering_invalid_abi_suggestion,
Expand Down
Loading
Loading