From 7ae198b08dc422662136c5158b482859b159ec50 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Sat, 18 Jan 2025 07:43:31 +0000 Subject: [PATCH 01/15] don't use partial ordering on types that support total ordering --- compiler/rustc_resolve/src/diagnostics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index ba217b7c88a8e..66a04eb0617a8 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1139,7 +1139,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }); // Make sure error reporting is deterministic. - suggestions.sort_by(|a, b| a.candidate.as_str().partial_cmp(b.candidate.as_str()).unwrap()); + suggestions.sort_by(|a, b| a.candidate.as_str().cmp(b.candidate.as_str())); match find_best_match_for_name( &suggestions.iter().map(|suggestion| suggestion.candidate).collect::>(), @@ -2360,7 +2360,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // 2) `std` suggestions before `core` suggestions. let mut extern_crate_names = self.extern_prelude.keys().map(|ident| ident.name).collect::>(); - extern_crate_names.sort_by(|a, b| b.as_str().partial_cmp(a.as_str()).unwrap()); + extern_crate_names.sort_by(|a, b| b.as_str().cmp(a.as_str())); for name in extern_crate_names.into_iter() { // Replace first ident with a crate name and check if that is valid. From ce0b72a99c4c71c3b72c85549fafe5d0beb4cee4 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Sat, 18 Jan 2025 07:44:37 +0000 Subject: [PATCH 02/15] use slice patterns for checking for elements of slice --- compiler/rustc_resolve/src/diagnostics.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 66a04eb0617a8..0da27a9c0717d 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2242,14 +2242,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { mut path: Vec, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec, Option)> { - match (path.get(0), path.get(1)) { + match path[..] { // `{{root}}::ident::...` on both editions. // On 2015 `{{root}}` is usually added implicitly. - (Some(fst), Some(snd)) - if fst.ident.name == kw::PathRoot && !snd.ident.is_path_segment_keyword() => {} + [first, second, ..] + if first.ident.name == kw::PathRoot && !second.ident.is_path_segment_keyword() => {} // `ident::...` on 2018. - (Some(fst), _) - if fst.ident.span.at_least_rust_2018() && !fst.ident.is_path_segment_keyword() => + [first, ..] + if first.ident.span.at_least_rust_2018() + && !first.ident.is_path_segment_keyword() => { // Insert a placeholder that's later replaced by `self`/`super`/etc. path.insert(0, Segment::from_ident(Ident::empty())); From 68ff0f17976721ee59229f72e6f7fe0cae44c8eb Mon Sep 17 00:00:00 2001 From: joboet Date: Fri, 7 Feb 2025 18:34:09 +0100 Subject: [PATCH 03/15] std: replace the `FromInner` implementation for addresses with private conversion functions Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed. I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`. --- library/std/src/net/ip_addr.rs | 29 --- library/std/src/net/socket_addr.rs | 46 +---- library/std/src/os/solid/io.rs | 4 +- library/std/src/sys/net/connection/sgx.rs | 35 ---- library/std/src/sys/net/connection/socket.rs | 188 +++++++++++------- .../src/sys/net/connection/socket/hermit.rs | 10 +- .../src/sys/net/connection/socket/solid.rs | 8 +- .../std/src/sys/net/connection/socket/unix.rs | 11 +- .../src/sys/net/connection/socket/wasip2.rs | 9 +- .../src/sys/net/connection/socket/windows.rs | 23 ++- .../std/src/sys/net/connection/unsupported.rs | 35 ---- library/std/src/sys/net/connection/wasip1.rs | 35 ---- .../std/src/sys/net/connection/xous/mod.rs | 35 ---- 13 files changed, 155 insertions(+), 313 deletions(-) diff --git a/library/std/src/net/ip_addr.rs b/library/std/src/net/ip_addr.rs index 4d673a1d66db6..7262899b3bbbe 100644 --- a/library/std/src/net/ip_addr.rs +++ b/library/std/src/net/ip_addr.rs @@ -8,32 +8,3 @@ pub use core::net::IpAddr; pub use core::net::Ipv6MulticastScope; #[stable(feature = "rust1", since = "1.0.0")] pub use core::net::{Ipv4Addr, Ipv6Addr}; - -use crate::sys::net::netc as c; -use crate::sys_common::{FromInner, IntoInner}; - -impl IntoInner for Ipv4Addr { - #[inline] - fn into_inner(self) -> c::in_addr { - // `s_addr` is stored as BE on all machines and the array is in BE order. - // So the native endian conversion method is used so that it's never swapped. - c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) } - } -} -impl FromInner for Ipv4Addr { - fn from_inner(addr: c::in_addr) -> Ipv4Addr { - Ipv4Addr::from(addr.s_addr.to_ne_bytes()) - } -} - -impl IntoInner for Ipv6Addr { - fn into_inner(self) -> c::in6_addr { - c::in6_addr { s6_addr: self.octets() } - } -} -impl FromInner for Ipv6Addr { - #[inline] - fn from_inner(addr: c::in6_addr) -> Ipv6Addr { - Ipv6Addr::from(addr.s6_addr) - } -} diff --git a/library/std/src/net/socket_addr.rs b/library/std/src/net/socket_addr.rs index e8355cc31d7a5..4c8905c0d4609 100644 --- a/library/std/src/net/socket_addr.rs +++ b/library/std/src/net/socket_addr.rs @@ -6,50 +6,8 @@ mod tests; pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use crate::sys::net::{LookupHost, netc as c}; -use crate::sys_common::{FromInner, IntoInner}; -use crate::{io, iter, mem, option, slice, vec}; - -impl FromInner for SocketAddrV4 { - fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 { - SocketAddrV4::new(Ipv4Addr::from_inner(addr.sin_addr), u16::from_be(addr.sin_port)) - } -} - -impl FromInner for SocketAddrV6 { - fn from_inner(addr: c::sockaddr_in6) -> SocketAddrV6 { - SocketAddrV6::new( - Ipv6Addr::from_inner(addr.sin6_addr), - u16::from_be(addr.sin6_port), - addr.sin6_flowinfo, - addr.sin6_scope_id, - ) - } -} - -impl IntoInner for SocketAddrV4 { - fn into_inner(self) -> c::sockaddr_in { - c::sockaddr_in { - sin_family: c::AF_INET as c::sa_family_t, - sin_port: self.port().to_be(), - sin_addr: self.ip().into_inner(), - ..unsafe { mem::zeroed() } - } - } -} - -impl IntoInner for SocketAddrV6 { - fn into_inner(self) -> c::sockaddr_in6 { - c::sockaddr_in6 { - sin6_family: c::AF_INET6 as c::sa_family_t, - sin6_port: self.port().to_be(), - sin6_addr: self.ip().into_inner(), - sin6_flowinfo: self.flowinfo(), - sin6_scope_id: self.scope_id(), - ..unsafe { mem::zeroed() } - } - } -} +use crate::sys::net::LookupHost; +use crate::{io, iter, option, slice, vec}; /// A trait for objects which can be converted or resolved to one or more /// [`SocketAddr`] values. diff --git a/library/std/src/os/solid/io.rs b/library/std/src/os/solid/io.rs index b8c3440542d00..ca58a900c4451 100644 --- a/library/std/src/os/solid/io.rs +++ b/library/std/src/os/solid/io.rs @@ -122,7 +122,7 @@ impl BorrowedFd<'_> { /// Creates a new `OwnedFd` instance that shares the same underlying file /// description as the existing `BorrowedFd` instance. pub fn try_clone_to_owned(&self) -> crate::io::Result { - let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?; + let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?; Ok(unsafe { OwnedFd::from_raw_fd(fd) }) } } @@ -168,7 +168,7 @@ impl FromRawFd for OwnedFd { impl Drop for OwnedFd { #[inline] fn drop(&mut self) { - unsafe { sys::net::netc::close(self.fd.as_inner()) }; + unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) }; } } diff --git a/library/std/src/sys/net/connection/sgx.rs b/library/std/src/sys/net/connection/sgx.rs index b390a5eac5f74..242df10bc3270 100644 --- a/library/std/src/sys/net/connection/sgx.rs +++ b/library/std/src/sys/net/connection/sgx.rs @@ -499,38 +499,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { LookupHost::new(format!("{host}:{port}")) } } - -#[allow(bad_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/library/std/src/sys/net/connection/socket.rs b/library/std/src/sys/net/connection/socket.rs index 6fe3430b53f79..b4f0a7836803e 100644 --- a/library/std/src/sys/net/connection/socket.rs +++ b/library/std/src/sys/net/connection/socket.rs @@ -3,9 +3,9 @@ mod tests; use crate::ffi::{c_int, c_void}; use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; -use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; +use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::sys::common::small_c_string::run_with_cstr; -use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner}; use crate::time::Duration; use crate::{cmp, fmt, mem, ptr}; @@ -79,6 +79,111 @@ cfg_if::cfg_if! { } } +//////////////////////////////////////////////////////////////////////////////// +// address conversions +//////////////////////////////////////////////////////////////////////////////// + +fn ip_v4_addr_to_c(addr: &Ipv4Addr) -> c::in_addr { + // `s_addr` is stored as BE on all machines and the array is in BE order. + // So the native endian conversion method is used so that it's never swapped. + c::in_addr { s_addr: u32::from_ne_bytes(addr.octets()) } +} + +fn ip_v6_addr_to_c(addr: &Ipv6Addr) -> c::in6_addr { + c::in6_addr { s6_addr: addr.octets() } +} + +fn ip_v4_addr_from_c(addr: c::in_addr) -> Ipv4Addr { + Ipv4Addr::from(addr.s_addr.to_ne_bytes()) +} + +fn ip_v6_addr_from_c(addr: c::in6_addr) -> Ipv6Addr { + Ipv6Addr::from(addr.s6_addr) +} + +fn socket_addr_v4_to_c(addr: &SocketAddrV4) -> c::sockaddr_in { + c::sockaddr_in { + sin_family: c::AF_INET as c::sa_family_t, + sin_port: addr.port().to_be(), + sin_addr: ip_v4_addr_to_c(addr.ip()), + ..unsafe { mem::zeroed() } + } +} + +fn socket_addr_v6_to_c(addr: &SocketAddrV6) -> c::sockaddr_in6 { + c::sockaddr_in6 { + sin6_family: c::AF_INET6 as c::sa_family_t, + sin6_port: addr.port().to_be(), + sin6_addr: ip_v6_addr_to_c(addr.ip()), + sin6_flowinfo: addr.flowinfo(), + sin6_scope_id: addr.scope_id(), + ..unsafe { mem::zeroed() } + } +} + +fn socket_addr_v4_from_c(addr: c::sockaddr_in) -> SocketAddrV4 { + SocketAddrV4::new(ip_v4_addr_from_c(addr.sin_addr), u16::from_be(addr.sin_port)) +} + +fn socket_addr_v6_from_c(addr: c::sockaddr_in6) -> SocketAddrV6 { + SocketAddrV6::new( + ip_v6_addr_from_c(addr.sin6_addr), + u16::from_be(addr.sin6_port), + addr.sin6_flowinfo, + addr.sin6_scope_id, + ) +} + +/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level +/// SocketAddr* types into their system representation. The benefit of this specific +/// type over using `c::sockaddr_storage` is that this type is exactly as large as it +/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. +#[repr(C)] +union SocketAddrCRepr { + v4: c::sockaddr_in, + v6: c::sockaddr_in6, +} + +impl SocketAddrCRepr { + fn as_ptr(&self) -> *const c::sockaddr { + self as *const _ as *const c::sockaddr + } +} + +fn socket_addr_to_c(addr: &SocketAddr) -> (SocketAddrCRepr, c::socklen_t) { + match addr { + SocketAddr::V4(a) => { + let sockaddr = SocketAddrCRepr { v4: socket_addr_v4_to_c(a) }; + (sockaddr, mem::size_of::() as c::socklen_t) + } + SocketAddr::V6(a) => { + let sockaddr = SocketAddrCRepr { v6: socket_addr_v6_to_c(a) }; + (sockaddr, mem::size_of::() as c::socklen_t) + } + } +} + +unsafe fn socket_addr_from_c( + storage: *const c::sockaddr_storage, + len: usize, +) -> io::Result { + match (*storage).ss_family as c_int { + c::AF_INET => { + assert!(len >= mem::size_of::()); + Ok(SocketAddr::V4(socket_addr_v4_from_c(unsafe { + *(storage as *const _ as *const c::sockaddr_in) + }))) + } + c::AF_INET6 => { + assert!(len >= mem::size_of::()); + Ok(SocketAddr::V6(socket_addr_v6_from_c(unsafe { + *(storage as *const _ as *const c::sockaddr_in6) + }))) + } + _ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")), + } +} + //////////////////////////////////////////////////////////////////////////////// // sockaddr and misc bindings //////////////////////////////////////////////////////////////////////////////// @@ -124,25 +229,7 @@ where let mut storage: c::sockaddr_storage = mem::zeroed(); let mut len = mem::size_of_val(&storage) as c::socklen_t; cvt(f((&raw mut storage) as *mut _, &mut len))?; - sockaddr_to_addr(&storage, len as usize) - } -} - -pub fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result { - match storage.ss_family as c_int { - c::AF_INET => { - assert!(len >= mem::size_of::()); - Ok(SocketAddr::V4(FromInner::from_inner(unsafe { - *(storage as *const _ as *const c::sockaddr_in) - }))) - } - c::AF_INET6 => { - assert!(len >= mem::size_of::()); - Ok(SocketAddr::V6(FromInner::from_inner(unsafe { - *(storage as *const _ as *const c::sockaddr_in6) - }))) - } - _ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")), + socket_addr_from_c(&storage, len as usize) } } @@ -179,7 +266,7 @@ impl Iterator for LookupHost { unsafe { let cur = self.cur.as_ref()?; self.cur = cur.ai_next; - match sockaddr_to_addr(mem::transmute(cur.ai_addr), cur.ai_addrlen as usize) { + match socket_addr_from_c(cur.ai_addr.cast(), cur.ai_addrlen as usize) { Ok(addr) => return Some(addr), Err(_) => continue, } @@ -432,7 +519,7 @@ impl TcpListener { setsockopt(&sock, c::SOL_SOCKET, c::SO_REUSEADDR, 1 as c_int)?; // Bind our new socket - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?; cfg_if::cfg_if! { @@ -473,7 +560,7 @@ impl TcpListener { let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; let mut len = mem::size_of_val(&storage) as c::socklen_t; let sock = self.inner.accept((&raw mut storage) as *mut _, &mut len)?; - let addr = sockaddr_to_addr(&storage, len as usize)?; + let addr = unsafe { socket_addr_from_c(&storage, len as usize)? }; Ok((TcpStream { inner: sock }, addr)) } @@ -542,7 +629,7 @@ impl UdpSocket { init(); let sock = Socket::new(addr, c::SOCK_DGRAM)?; - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?; Ok(UdpSocket { inner: sock }) } @@ -574,7 +661,7 @@ impl UdpSocket { pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result { let len = cmp::min(buf.len(), ::MAX as usize) as wrlen_t; - let (dst, dstlen) = dst.into_inner(); + let (dst, dstlen) = socket_addr_to_c(dst); let ret = cvt(unsafe { c::sendto( self.inner.as_raw(), @@ -656,15 +743,15 @@ impl UdpSocket { pub fn join_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { let mreq = c::ip_mreq { - imr_multiaddr: multiaddr.into_inner(), - imr_interface: interface.into_inner(), + imr_multiaddr: ip_v4_addr_to_c(multiaddr), + imr_interface: ip_v4_addr_to_c(interface), }; setsockopt(&self.inner, c::IPPROTO_IP, c::IP_ADD_MEMBERSHIP, mreq) } pub fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = c::ipv6_mreq { - ipv6mr_multiaddr: multiaddr.into_inner(), + ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr), ipv6mr_interface: to_ipv6mr_interface(interface), }; setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq) @@ -672,15 +759,15 @@ impl UdpSocket { pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { let mreq = c::ip_mreq { - imr_multiaddr: multiaddr.into_inner(), - imr_interface: interface.into_inner(), + imr_multiaddr: ip_v4_addr_to_c(multiaddr), + imr_interface: ip_v4_addr_to_c(interface), }; setsockopt(&self.inner, c::IPPROTO_IP, c::IP_DROP_MEMBERSHIP, mreq) } pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = c::ipv6_mreq { - ipv6mr_multiaddr: multiaddr.into_inner(), + ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr), ipv6mr_interface: to_ipv6mr_interface(interface), }; setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, mreq) @@ -720,7 +807,7 @@ impl UdpSocket { } pub fn connect(&self, addr: io::Result<&SocketAddr>) -> io::Result<()> { - let (addr, len) = addr?.into_inner(); + let (addr, len) = socket_addr_to_c(addr?); cvt_r(|| unsafe { c::connect(self.inner.as_raw(), addr.as_ptr(), len) }).map(drop) } } @@ -743,38 +830,3 @@ impl fmt::Debug for UdpSocket { res.field(name, &self.inner.as_raw()).finish() } } - -//////////////////////////////////////////////////////////////////////////////// -// Converting SocketAddr to libc representation -//////////////////////////////////////////////////////////////////////////////// - -/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level -/// SocketAddr* types into their system representation. The benefit of this specific -/// type over using `c::sockaddr_storage` is that this type is exactly as large as it -/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. -#[repr(C)] -pub(crate) union SocketAddrCRepr { - v4: c::sockaddr_in, - v6: c::sockaddr_in6, -} - -impl SocketAddrCRepr { - pub fn as_ptr(&self) -> *const c::sockaddr { - self as *const _ as *const c::sockaddr - } -} - -impl<'a> IntoInner<(SocketAddrCRepr, c::socklen_t)> for &'a SocketAddr { - fn into_inner(self) -> (SocketAddrCRepr, c::socklen_t) { - match *self { - SocketAddr::V4(ref a) => { - let sockaddr = SocketAddrCRepr { v4: a.into_inner() }; - (sockaddr, mem::size_of::() as c::socklen_t) - } - SocketAddr::V6(ref a) => { - let sockaddr = SocketAddrCRepr { v6: a.into_inner() }; - (sockaddr, mem::size_of::() as c::socklen_t) - } - } - } -} diff --git a/library/std/src/sys/net/connection/socket/hermit.rs b/library/std/src/sys/net/connection/socket/hermit.rs index 42179dcc9156d..e393342ced9da 100644 --- a/library/std/src/sys/net/connection/socket/hermit.rs +++ b/library/std/src/sys/net/connection/socket/hermit.rs @@ -2,13 +2,13 @@ use core::ffi::c_int; -pub(crate) use hermit_abi as netc; +pub(super) use hermit_abi as netc; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; use crate::sys::fd::FileDesc; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys::time::Instant; pub use crate::sys::{cvt, cvt_r}; use crate::sys_common::{AsInner, FromInner, IntoInner}; @@ -55,7 +55,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -63,7 +63,7 @@ impl Socket { pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { self.set_nonblocking(true)?; let r = unsafe { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(netc::connect(self.as_raw_fd(), addr.as_ptr(), len)) }; self.set_nonblocking(false)?; @@ -195,7 +195,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/library/std/src/sys/net/connection/socket/solid.rs b/library/std/src/sys/net/connection/socket/solid.rs index f85ecbb883ee7..906bef267b6f0 100644 --- a/library/std/src/sys/net/connection/socket/solid.rs +++ b/library/std/src/sys/net/connection/socket/solid.rs @@ -1,17 +1,17 @@ use libc::{c_int, c_void, size_t}; use self::netc::{MSG_PEEK, sockaddr, socklen_t}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}; use crate::sys::abi; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys_common::{FromInner, IntoInner}; use crate::time::Duration; use crate::{cmp, mem, ptr, str}; -pub mod netc { +pub(super) mod netc { pub use crate::sys::abi::sockets::*; } @@ -131,7 +131,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -256,7 +256,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs index da6316055273f..34ab26bc117af 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -5,7 +5,7 @@ use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::sys::fd::FileDesc; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; +use crate::sys::net::{getsockopt, setsockopt}; use crate::sys::pal::IsMinusOne; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; @@ -19,8 +19,9 @@ cfg_if::cfg_if! { } } -pub(crate) use libc as netc; +pub(super) use libc as netc; +use super::{socket_addr_from_c, socket_addr_to_c}; pub use crate::sys::{cvt, cvt_r}; #[expect(non_camel_case_types)] @@ -150,7 +151,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); loop { let result = unsafe { libc::connect(self.as_raw_fd(), addr.as_ptr(), len) }; if result.is_minus_one() { @@ -168,7 +169,7 @@ impl Socket { pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { self.set_nonblocking(true)?; let r = unsafe { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(libc::connect(self.as_raw_fd(), addr.as_ptr(), len)) }; self.set_nonblocking(false)?; @@ -334,7 +335,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/library/std/src/sys/net/connection/socket/wasip2.rs b/library/std/src/sys/net/connection/socket/wasip2.rs index 9d1c05a473e4d..c5034e73dd704 100644 --- a/library/std/src/sys/net/connection/socket/wasip2.rs +++ b/library/std/src/sys/net/connection/socket/wasip2.rs @@ -1,19 +1,18 @@ #![deny(unsafe_op_in_unsafe_fn)] +pub(super) use libc as netc; use libc::{c_int, c_void, size_t}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys::unsupported; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; use crate::{cmp, mem, str}; -pub extern crate libc as netc; - #[allow(non_camel_case_types)] pub type wrlen_t = size_t; @@ -89,7 +88,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -224,7 +223,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/library/std/src/sys/net/connection/socket/windows.rs b/library/std/src/sys/net/connection/socket/windows.rs index 80cf37eaf0580..428f142dabe20 100644 --- a/library/std/src/sys/net/connection/socket/windows.rs +++ b/library/std/src/sys/net/connection/socket/windows.rs @@ -2,6 +2,7 @@ use core::ffi::{c_int, c_long, c_ulong, c_ushort}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read}; use crate::net::{Shutdown, SocketAddr}; use crate::os::windows::io::{ @@ -16,7 +17,7 @@ use crate::{cmp, mem, ptr, sys}; #[allow(non_camel_case_types)] pub type wrlen_t = i32; -pub mod netc { +pub(super) mod netc { //! BSD socket compatibility shim //! //! Some Windows API types are not quite what's expected by our cross-platform @@ -225,7 +226,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); let result = unsafe { c::connect(self.as_raw(), addr.as_ptr(), len) }; cvt(result).map(drop) } @@ -401,12 +402,12 @@ impl Socket { let error = unsafe { c::WSAGetLastError() }; if error == c::WSAESHUTDOWN { - Ok((0, super::sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((0, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } else { Err(io::Error::from_raw_os_error(error)) } } - _ => Ok((result as usize, super::sockaddr_to_addr(&storage, addrlen as usize)?)), + _ => Ok((result as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })), } } @@ -451,11 +452,11 @@ impl Socket { } None => 0, }; - super::setsockopt(self, c::SOL_SOCKET, kind, timeout) + setsockopt(self, c::SOL_SOCKET, kind, timeout) } pub fn timeout(&self, kind: c_int) -> io::Result> { - let raw: u32 = super::getsockopt(self, c::SOL_SOCKET, kind)?; + let raw: u32 = getsockopt(self, c::SOL_SOCKET, kind)?; if raw == 0 { Ok(None) } else { @@ -488,26 +489,26 @@ impl Socket { l_linger: linger.unwrap_or_default().as_secs() as c_ushort, }; - super::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) + setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) } pub fn linger(&self) -> io::Result> { - let val: c::LINGER = super::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?; + let val: c::LINGER = getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?; Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64))) } pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { - super::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL) + setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL) } pub fn nodelay(&self) -> io::Result { - let raw: c::BOOL = super::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?; + let raw: c::BOOL = getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?; Ok(raw != 0) } pub fn take_error(&self) -> io::Result> { - let raw: c_int = super::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?; + let raw: c_int = getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?; if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) } } diff --git a/library/std/src/sys/net/connection/unsupported.rs b/library/std/src/sys/net/connection/unsupported.rs index 87e6106468fdb..da2174396266f 100644 --- a/library/std/src/sys/net/connection/unsupported.rs +++ b/library/std/src/sys/net/connection/unsupported.rs @@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/library/std/src/sys/net/connection/wasip1.rs b/library/std/src/sys/net/connection/wasip1.rs index 27e3a528af497..951dc65e5b47d 100644 --- a/library/std/src/sys/net/connection/wasip1.rs +++ b/library/std/src/sys/net/connection/wasip1.rs @@ -505,38 +505,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/library/std/src/sys/net/connection/xous/mod.rs b/library/std/src/sys/net/connection/xous/mod.rs index 3e18ed24208d3..e44a375b9e3c5 100644 --- a/library/std/src/sys/net/connection/xous/mod.rs +++ b/library/std/src/sys/net/connection/xous/mod.rs @@ -46,38 +46,3 @@ pub struct GetAddress { } pub use dns::LookupHost; - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} From 5932b2fe9cd9735749ef3b141f3782edc815f4e6 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 8 Feb 2025 18:56:25 -0800 Subject: [PATCH 04/15] tests/assembly: make windows ABI test cross-compile --- tests/assembly/x86_64-windows-float-abi.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/assembly/x86_64-windows-float-abi.rs b/tests/assembly/x86_64-windows-float-abi.rs index 1381d492fa593..e8900be1aaee3 100644 --- a/tests/assembly/x86_64-windows-float-abi.rs +++ b/tests/assembly/x86_64-windows-float-abi.rs @@ -1,11 +1,17 @@ //@ assembly-output: emit-asm -//@ compile-flags: -O -//@ only-windows -//@ only-x86_64 +//@ compile-flags: -Copt-level=3 +//@ compile-flags: --target x86_64-pc-windows-msvc +//@ needs-llvm-components: x86 +//@ add-core-stubs #![feature(f16, f128)] +#![feature(no_core)] +#![no_core] #![crate_type = "lib"] +extern crate minicore; +use minicore::*; + // CHECK-LABEL: second_f16 // CHECK: movaps %xmm1, %xmm0 // CHECK-NEXT: retq From b3464fa65ff4486b20589e0e7486657ba0ea533d Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 8 Feb 2025 19:00:27 -0800 Subject: [PATCH 05/15] tests/assembly: make typed-swap test much less fragile --- tests/assembly/x86_64-typed-swap.rs | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/assembly/x86_64-typed-swap.rs b/tests/assembly/x86_64-typed-swap.rs index 95e87519e6c4b..dfd6ee565bccb 100644 --- a/tests/assembly/x86_64-typed-swap.rs +++ b/tests/assembly/x86_64-typed-swap.rs @@ -3,7 +3,7 @@ //@ [LIN] only-linux //@ only-x86_64 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O +//@ compile-flags: --crate-type=lib -Copt-level=3 use std::arch::x86_64::__m128; use std::mem::swap; @@ -12,42 +12,42 @@ use std::mem::swap; #[no_mangle] pub fn swap_i32(x: &mut i32, y: &mut i32) { // CHECK: movl (%[[ARG1:.+]]), %[[T1:.+]] - // CHECK: movl (%[[ARG2:.+]]), %[[T2:.+]] - // CHECK: movl %[[T2]], (%[[ARG1]]) - // CHECK: movl %[[T1]], (%[[ARG2]]) - // CHECK: retq + // CHECK-NEXT: movl (%[[ARG2:.+]]), %[[T2:.+]] + // CHECK-DAG: movl %[[T2]], (%[[ARG1]]) + // CHECK-DAG: movl %[[T1]], (%[[ARG2]]) + // CHECK-NEXT: retq swap(x, y) } // CHECK-LABEL: swap_pair: #[no_mangle] pub fn swap_pair(x: &mut (i32, u32), y: &mut (i32, u32)) { - // CHECK: movq (%[[ARG1]]), %[[T1:.+]] - // CHECK: movq (%[[ARG2]]), %[[T2:.+]] - // CHECK: movq %[[T2]], (%[[ARG1]]) - // CHECK: movq %[[T1]], (%[[ARG2]]) - // CHECK: retq + // CHECK: movq (%[[ARG1:r..?]]), %[[T1:.+]] + // CHECK-NEXT: movq (%[[ARG2:r..?]]), %[[T2:.+]] + // CHECK-DAG: movq %[[T2]], (%[[ARG1]]) + // CHECK-DAG: movq %[[T1]], (%[[ARG2]]) + // CHECK-NEXT: retq swap(x, y) } // CHECK-LABEL: swap_str: #[no_mangle] pub fn swap_str<'a>(x: &mut &'a str, y: &mut &'a str) { - // CHECK: movups (%[[ARG1]]), %[[T1:xmm.]] - // CHECK: movups (%[[ARG2]]), %[[T2:xmm.]] - // CHECK: movups %[[T2]], (%[[ARG1]]) - // CHECK: movups %[[T1]], (%[[ARG2]]) - // CHECK: retq + // CHECK: movups (%[[ARG1:r..?]]), %[[T1:xmm.]] + // CHECK-NEXT: movups (%[[ARG2:r..?]]), %[[T2:xmm.]] + // CHECK-DAG: movups %[[T2]], (%[[ARG1]]) + // CHECK-DAG: movups %[[T1]], (%[[ARG2]]) + // CHECK-NEXT: retq swap(x, y) } // CHECK-LABEL: swap_simd: #[no_mangle] pub fn swap_simd(x: &mut __m128, y: &mut __m128) { - // CHECK: movaps (%[[ARG1]]), %[[T1:xmm.]] - // CHECK: movaps (%[[ARG2]]), %[[T2:xmm.]] - // CHECK: movaps %[[T2]], (%[[ARG1]]) - // CHECK: movaps %[[T1]], (%[[ARG2]]) - // CHECK: retq + // CHECK: movaps (%[[ARG1:r..?]]), %[[T1:xmm.]] + // CHECK-NEXT: movaps (%[[ARG2:r..?]]), %[[T2:xmm.]] + // CHECK-DAG: movaps %[[T2]], (%[[ARG1]]) + // CHECK-DAG: movaps %[[T1]], (%[[ARG2]]) + // CHECK-NEXT: retq swap(x, y) } From ee111b24e35c32b251a0879e590af3da8d5015b0 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 8 Feb 2025 18:56:57 -0800 Subject: [PATCH 06/15] tests/assembly: use -Copt-level=3 instead of -O --- tests/assembly/asm/aarch64-modifiers.rs | 4 ++-- tests/assembly/asm/aarch64-outline-atomics.rs | 2 +- tests/assembly/asm/arm-modifiers.rs | 4 ++-- tests/assembly/asm/x86-modifiers.rs | 4 ++-- tests/assembly/libs/issue-115339-zip-arrays.rs | 2 +- tests/assembly/manual-eq-efficient.rs | 2 +- tests/assembly/panic-no-unwind-no-uwtable.rs | 2 +- tests/assembly/powerpc64-struct-abi.rs | 2 +- tests/assembly/s390x-backchain-toggle.rs | 2 +- tests/assembly/s390x-vector-abi.rs | 2 +- tests/assembly/simd-bitmask.rs | 2 +- tests/assembly/simd-intrinsic-gather.rs | 2 +- tests/assembly/simd-intrinsic-mask-load.rs | 2 +- tests/assembly/simd-intrinsic-mask-reduce.rs | 2 +- tests/assembly/simd-intrinsic-mask-store.rs | 2 +- tests/assembly/simd-intrinsic-scatter.rs | 2 +- tests/assembly/simd-intrinsic-select.rs | 2 +- tests/assembly/simd/reduce-fadd-unordered.rs | 3 ++- tests/assembly/slice-is_ascii.rs | 2 +- tests/assembly/x86-return-float.rs | 2 +- tests/assembly/x86_64-array-pair-load-store-merge.rs | 2 +- tests/assembly/x86_64-bigint-helpers.rs | 2 +- tests/assembly/x86_64-floating-point-clamp.rs | 2 +- tests/assembly/x86_64-function-return.rs | 2 +- tests/assembly/x86_64-no-jump-tables.rs | 2 +- 25 files changed, 29 insertions(+), 28 deletions(-) diff --git a/tests/assembly/asm/aarch64-modifiers.rs b/tests/assembly/asm/aarch64-modifiers.rs index a3956d21a0677..58f7c114d3a60 100644 --- a/tests/assembly/asm/aarch64-modifiers.rs +++ b/tests/assembly/asm/aarch64-modifiers.rs @@ -1,6 +1,6 @@ //@ add-core-stubs //@ assembly-output: emit-asm -//@ compile-flags: -O -C panic=abort +//@ compile-flags: -Copt-level=3 -C panic=abort //@ compile-flags: --target aarch64-unknown-linux-gnu //@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: aarch64 @@ -15,7 +15,7 @@ use minicore::*; macro_rules! check { ($func:ident $reg:ident $code:literal) => { - // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0 + // -Copt-level=3 and extern "C" guarantee that the selected register is always r0/s0/d0/q0 #[no_mangle] pub unsafe extern "C" fn $func() -> i32 { let y; diff --git a/tests/assembly/asm/aarch64-outline-atomics.rs b/tests/assembly/asm/aarch64-outline-atomics.rs index 46586f0f31c01..5990fb8494214 100644 --- a/tests/assembly/asm/aarch64-outline-atomics.rs +++ b/tests/assembly/asm/aarch64-outline-atomics.rs @@ -1,5 +1,5 @@ //@ assembly-output: emit-asm -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ compile-flags: --target aarch64-unknown-linux-gnu //@ needs-llvm-components: aarch64 //@ only-aarch64 diff --git a/tests/assembly/asm/arm-modifiers.rs b/tests/assembly/asm/arm-modifiers.rs index 562b6bed74c35..32a368404924a 100644 --- a/tests/assembly/asm/arm-modifiers.rs +++ b/tests/assembly/asm/arm-modifiers.rs @@ -1,6 +1,6 @@ //@ add-core-stubs //@ assembly-output: emit-asm -//@ compile-flags: -O -C panic=abort +//@ compile-flags: -Copt-level=3 -C panic=abort //@ compile-flags: --target armv7-unknown-linux-gnueabihf //@ compile-flags: -C target-feature=+neon //@ compile-flags: -Zmerge-functions=disabled @@ -21,7 +21,7 @@ impl Copy for f32x4 {} macro_rules! check { ($func:ident $modifier:literal $reg:ident $ty:ident $mov:literal) => { - // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0 + // -Copt-level=3 and extern "C" guarantee that the selected register is always r0/s0/d0/q0 #[no_mangle] pub unsafe extern "C" fn $func() -> $ty { let y; diff --git a/tests/assembly/asm/x86-modifiers.rs b/tests/assembly/asm/x86-modifiers.rs index 53e4b92f84acb..5f68e5c7317f3 100644 --- a/tests/assembly/asm/x86-modifiers.rs +++ b/tests/assembly/asm/x86-modifiers.rs @@ -1,7 +1,7 @@ //@ add-core-stubs //@ revisions: x86_64 i686 //@ assembly-output: emit-asm -//@ compile-flags: -O -C panic=abort +//@ compile-flags: -Copt-level=3 -C panic=abort //@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu //@[x86_64] needs-llvm-components: x86 //@[i686] compile-flags: --target i686-unknown-linux-gnu @@ -20,7 +20,7 @@ use minicore::*; macro_rules! check { ($func:ident $modifier:literal $reg:ident $mov:literal) => { - // -O and extern "C" guarantee that the selected register is always ax/xmm0 + // -Copt-level=3 and extern "C" guarantee that the selected register is always ax/xmm0 #[no_mangle] pub unsafe extern "C" fn $func() -> i32 { let y; diff --git a/tests/assembly/libs/issue-115339-zip-arrays.rs b/tests/assembly/libs/issue-115339-zip-arrays.rs index 956459b2c7731..098382502e8a0 100644 --- a/tests/assembly/libs/issue-115339-zip-arrays.rs +++ b/tests/assembly/libs/issue-115339-zip-arrays.rs @@ -1,6 +1,6 @@ //@ assembly-output: emit-asm // # zen3 previously exhibited odd vectorization -//@ compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -O +//@ compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -Copt-level=3 //@ only-x86_64 //@ ignore-sgx diff --git a/tests/assembly/manual-eq-efficient.rs b/tests/assembly/manual-eq-efficient.rs index 817ce94f476a3..8dafed354bebe 100644 --- a/tests/assembly/manual-eq-efficient.rs +++ b/tests/assembly/manual-eq-efficient.rs @@ -1,6 +1,6 @@ // Regression test for #106269 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel +//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel //@ only-x86_64 //@ ignore-sgx diff --git a/tests/assembly/panic-no-unwind-no-uwtable.rs b/tests/assembly/panic-no-unwind-no-uwtable.rs index 24626280155a2..b51b173e9616e 100644 --- a/tests/assembly/panic-no-unwind-no-uwtable.rs +++ b/tests/assembly/panic-no-unwind-no-uwtable.rs @@ -1,6 +1,6 @@ //@ assembly-output: emit-asm //@ only-x86_64-unknown-linux-gnu -//@ compile-flags: -C panic=unwind -C force-unwind-tables=n -O +//@ compile-flags: -C panic=unwind -C force-unwind-tables=n -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/assembly/powerpc64-struct-abi.rs b/tests/assembly/powerpc64-struct-abi.rs index db08a5148196d..0332eb94d8a76 100644 --- a/tests/assembly/powerpc64-struct-abi.rs +++ b/tests/assembly/powerpc64-struct-abi.rs @@ -1,6 +1,6 @@ //@ revisions: elfv1-be elfv2-be elfv2-le aix //@ assembly-output: emit-asm -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@[elfv1-be] compile-flags: --target powerpc64-unknown-linux-gnu //@[elfv1-be] needs-llvm-components: powerpc //@[elfv2-be] compile-flags: --target powerpc64-unknown-linux-musl diff --git a/tests/assembly/s390x-backchain-toggle.rs b/tests/assembly/s390x-backchain-toggle.rs index 8b6d0cf212320..7ef0292d911e0 100644 --- a/tests/assembly/s390x-backchain-toggle.rs +++ b/tests/assembly/s390x-backchain-toggle.rs @@ -1,6 +1,6 @@ //@ revisions: enable-backchain disable-backchain //@ assembly-output: emit-asm -//@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu //@ needs-llvm-components: systemz //@[enable-backchain] compile-flags: -Ctarget-feature=+backchain //@[disable-backchain] compile-flags: -Ctarget-feature=-backchain diff --git a/tests/assembly/s390x-vector-abi.rs b/tests/assembly/s390x-vector-abi.rs index c1935582561f3..7d86559c0026d 100644 --- a/tests/assembly/s390x-vector-abi.rs +++ b/tests/assembly/s390x-vector-abi.rs @@ -1,7 +1,7 @@ //@ revisions: z10 z10_vector z13 z13_no_vector // ignore-tidy-linelength //@ assembly-output: emit-asm -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@[z10] compile-flags: --target s390x-unknown-linux-gnu --cfg no_vector //@[z10] needs-llvm-components: systemz //@[z10_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector diff --git a/tests/assembly/simd-bitmask.rs b/tests/assembly/simd-bitmask.rs index 9a355cc162f67..4a829c4dd98b2 100644 --- a/tests/assembly/simd-bitmask.rs +++ b/tests/assembly/simd-bitmask.rs @@ -10,7 +10,7 @@ //@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu //@ [aarch64] needs-llvm-components: aarch64 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd-intrinsic-gather.rs b/tests/assembly/simd-intrinsic-gather.rs index 29b0df6406556..3152de35f295e 100644 --- a/tests/assembly/simd-intrinsic-gather.rs +++ b/tests/assembly/simd-intrinsic-gather.rs @@ -3,7 +3,7 @@ //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq //@ [x86-avx512] needs-llvm-components: x86 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd-intrinsic-mask-load.rs b/tests/assembly/simd-intrinsic-mask-load.rs index 89b35ed7734ed..efe3e3752fabe 100644 --- a/tests/assembly/simd-intrinsic-mask-load.rs +++ b/tests/assembly/simd-intrinsic-mask-load.rs @@ -6,7 +6,7 @@ //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq //@ [x86-avx512] needs-llvm-components: x86 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd-intrinsic-mask-reduce.rs b/tests/assembly/simd-intrinsic-mask-reduce.rs index 8ac55990c7348..4d4adda6c24f9 100644 --- a/tests/assembly/simd-intrinsic-mask-reduce.rs +++ b/tests/assembly/simd-intrinsic-mask-reduce.rs @@ -7,7 +7,7 @@ //@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu //@ [aarch64] needs-llvm-components: aarch64 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd-intrinsic-mask-store.rs b/tests/assembly/simd-intrinsic-mask-store.rs index 1686fd5dd8833..f5d924f24a764 100644 --- a/tests/assembly/simd-intrinsic-mask-store.rs +++ b/tests/assembly/simd-intrinsic-mask-store.rs @@ -6,7 +6,7 @@ //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq //@ [x86-avx512] needs-llvm-components: x86 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd-intrinsic-scatter.rs b/tests/assembly/simd-intrinsic-scatter.rs index 3f4d7569c59f4..5f52ababd19c0 100644 --- a/tests/assembly/simd-intrinsic-scatter.rs +++ b/tests/assembly/simd-intrinsic-scatter.rs @@ -3,7 +3,7 @@ //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq //@ [x86-avx512] needs-llvm-components: x86 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd-intrinsic-select.rs b/tests/assembly/simd-intrinsic-select.rs index 803abf2eeb306..74784a772133d 100644 --- a/tests/assembly/simd-intrinsic-select.rs +++ b/tests/assembly/simd-intrinsic-select.rs @@ -8,7 +8,7 @@ //@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu //@ [aarch64] needs-llvm-components: aarch64 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C panic=abort +//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort #![feature(no_core, lang_items, repr_simd, intrinsics)] #![no_core] diff --git a/tests/assembly/simd/reduce-fadd-unordered.rs b/tests/assembly/simd/reduce-fadd-unordered.rs index ade60ba184c57..e872826f6ef79 100644 --- a/tests/assembly/simd/reduce-fadd-unordered.rs +++ b/tests/assembly/simd/reduce-fadd-unordered.rs @@ -1,6 +1,7 @@ //@ revisions: x86_64 aarch64 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O +//@ compile-flags: --crate-type=lib -Copt-level=3 + //@[aarch64] only-aarch64 //@[x86_64] only-x86_64 //@[x86_64] compile-flags: -Ctarget-feature=+sse3 diff --git a/tests/assembly/slice-is_ascii.rs b/tests/assembly/slice-is_ascii.rs index 3a050347d8981..e53cd5160cf56 100644 --- a/tests/assembly/slice-is_ascii.rs +++ b/tests/assembly/slice-is_ascii.rs @@ -2,7 +2,7 @@ //@ [WIN] only-windows //@ [LIN] only-linux //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel +//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel //@ only-x86_64 //@ ignore-sgx diff --git a/tests/assembly/x86-return-float.rs b/tests/assembly/x86-return-float.rs index acd1af8d38af1..423263c967321 100644 --- a/tests/assembly/x86-return-float.rs +++ b/tests/assembly/x86-return-float.rs @@ -6,7 +6,7 @@ // Use the same target CPU as `i686` so that LLVM orders the instructions in the same order. //@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4 // Force frame pointers to make ASM more consistent between targets -//@ compile-flags: -O -C force-frame-pointers +//@ compile-flags: -Copt-level=3 -C force-frame-pointers //@ filecheck-flags: --implicit-check-not fld --implicit-check-not fst //@ revisions: normal win //@[normal] ignore-windows diff --git a/tests/assembly/x86_64-array-pair-load-store-merge.rs b/tests/assembly/x86_64-array-pair-load-store-merge.rs index 849f34e72e51e..56a1a9e82062e 100644 --- a/tests/assembly/x86_64-array-pair-load-store-merge.rs +++ b/tests/assembly/x86_64-array-pair-load-store-merge.rs @@ -1,5 +1,5 @@ //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel +//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel //@ only-x86_64 //@ ignore-sgx //@ ignore-apple (manipulates rsp too) diff --git a/tests/assembly/x86_64-bigint-helpers.rs b/tests/assembly/x86_64-bigint-helpers.rs index 3ad253a2bd0fe..58785932bc2f9 100644 --- a/tests/assembly/x86_64-bigint-helpers.rs +++ b/tests/assembly/x86_64-bigint-helpers.rs @@ -1,6 +1,6 @@ //@ only-x86_64 //@ assembly-output: emit-asm -//@ compile-flags: --crate-type=lib -O -C target-cpu=x86-64-v4 +//@ compile-flags: --crate-type=lib -Copt-level=3 -C target-cpu=x86-64-v4 //@ compile-flags: -C llvm-args=-x86-asm-syntax=intel //@ revisions: llvm-pre-20 llvm-20 //@ [llvm-20] min-llvm-version: 20 diff --git a/tests/assembly/x86_64-floating-point-clamp.rs b/tests/assembly/x86_64-floating-point-clamp.rs index c05afadff645c..6b0c29c5f2148 100644 --- a/tests/assembly/x86_64-floating-point-clamp.rs +++ b/tests/assembly/x86_64-floating-point-clamp.rs @@ -3,7 +3,7 @@ //@ assembly-output: emit-asm // Set the base cpu explicitly, in case the default has been changed. -//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64 +//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64 //@ only-x86_64 //@ ignore-sgx diff --git a/tests/assembly/x86_64-function-return.rs b/tests/assembly/x86_64-function-return.rs index 7cfdf5bce0c1e..7fd57200a9eef 100644 --- a/tests/assembly/x86_64-function-return.rs +++ b/tests/assembly/x86_64-function-return.rs @@ -3,7 +3,7 @@ //@ revisions: unset keep thunk-extern keep-thunk-extern thunk-extern-keep //@ assembly-output: emit-asm -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ [keep] compile-flags: -Zfunction-return=keep //@ [thunk-extern] compile-flags: -Zfunction-return=thunk-extern //@ [keep-thunk-extern] compile-flags: -Zfunction-return=keep -Zfunction-return=thunk-extern diff --git a/tests/assembly/x86_64-no-jump-tables.rs b/tests/assembly/x86_64-no-jump-tables.rs index 9b7812262326d..bb10042d8f629 100644 --- a/tests/assembly/x86_64-no-jump-tables.rs +++ b/tests/assembly/x86_64-no-jump-tables.rs @@ -3,7 +3,7 @@ //@ revisions: unset set //@ assembly-output: emit-asm -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ [set] compile-flags: -Zno-jump-tables //@ only-x86_64 //@ ignore-sgx From 833f07021465b7d34b13fd7d6e5aadf2c35b61a0 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 8 Feb 2025 21:16:31 -0800 Subject: [PATCH 07/15] tests/assembly: cross-compile x86-return-float We choose to test for Linux and Windows instead of random other targets. --- tests/assembly/x86-return-float.rs | 43 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/tests/assembly/x86-return-float.rs b/tests/assembly/x86-return-float.rs index 423263c967321..ad760627b3a36 100644 --- a/tests/assembly/x86-return-float.rs +++ b/tests/assembly/x86-return-float.rs @@ -1,19 +1,28 @@ //@ assembly-output: emit-asm -//@ only-x86 // FIXME(#114479): LLVM miscompiles loading and storing `f32` and `f64` when SSE is disabled. // There's no compiletest directive to ignore a test on i586 only, so just always explicitly enable // SSE2. // Use the same target CPU as `i686` so that LLVM orders the instructions in the same order. //@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4 // Force frame pointers to make ASM more consistent between targets -//@ compile-flags: -Copt-level=3 -C force-frame-pointers +//@ compile-flags: -C force-frame-pointers +// At opt-level=3, LLVM can merge two movss into one movsd, and we aren't testing for that. +//@ compile-flags: -Copt-level=2 //@ filecheck-flags: --implicit-check-not fld --implicit-check-not fst -//@ revisions: normal win -//@[normal] ignore-windows -//@[win] only-windows +//@ revisions: linux win +//@ add-core-stubs +//@[linux] needs-llvm-components: x86 +//@[win] needs-llvm-components: x86 +//@[linux] compile-flags: --target i686-unknown-linux-gnu +//@[win] compile-flags: --target i686-pc-windows-msvc #![crate_type = "lib"] #![feature(f16, f128)] +#![feature(no_core)] +#![no_core] + +extern crate minicore; +use minicore::*; // Tests that returning `f32` and `f64` with the "Rust" ABI on 32-bit x86 doesn't use the x87 // floating point stack, as loading and storing `f32`s and `f64`s to and from the x87 stack quietens @@ -190,8 +199,8 @@ pub unsafe fn call_f64_f64(x: &mut (f64, f64)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64_f64 - // normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] + // linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // linux-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // win: movsd (%esp), %[[VAL1:.*]] // win-NEXT: movsd 8(%esp), %[[VAL2:.*]] // CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]]) @@ -207,12 +216,12 @@ pub unsafe fn call_f32_f64(x: &mut (f32, f64)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f32_f64 - // normal: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] + // linux: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // linux-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] // win: movss (%esp), %[[VAL1:.*]] // win-NEXT: movsd 8(%esp), %[[VAL2:.*]] // CHECK-NEXT: movss %[[VAL1]], (%[[PTR]]) - // normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) + // linux-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) // win-NEXT: movsd %[[VAL2]], 8(%[[PTR]]) *x = get_f32_f64(); } @@ -225,8 +234,8 @@ pub unsafe fn call_f64_f32(x: &mut (f64, f32)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64_f32 - // normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] + // linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // linux-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // win: movsd (%esp), %[[VAL1:.*]] // win-NEXT: movss 8(%esp), %[[VAL2:.*]] // CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]]) @@ -257,8 +266,8 @@ pub unsafe fn call_f64_other(x: &mut (f64, usize)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64_other - // normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] + // linux: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // linux-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // win: movsd (%esp), %[[VAL1:.*]] // win-NEXT: movl 8(%esp), %[[VAL2:.*]] // CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]]) @@ -289,12 +298,12 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_other_f64 - // normal: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] + // linux: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // linux-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] // win: movl (%esp), %[[VAL1:.*]] // win-NEXT: movsd 8(%esp), %[[VAL2:.*]] // CHECK-NEXT: movl %[[VAL1]], (%[[PTR]]) - // normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) + // linux-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) // win-NEXT: movsd %[[VAL2]], 8(%[[PTR]]) *x = get_other_f64(); } From 3580698996f6da6f006477809d7959bffcfd3bf0 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 9 Feb 2025 16:54:02 -0800 Subject: [PATCH 08/15] tests: issue-122805 -> dont-shuffle-bswaps --- tests/codegen/{issues/issue-122805.rs => dont-shuffle-bswaps.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{issues/issue-122805.rs => dont-shuffle-bswaps.rs} (100%) diff --git a/tests/codegen/issues/issue-122805.rs b/tests/codegen/dont-shuffle-bswaps.rs similarity index 100% rename from tests/codegen/issues/issue-122805.rs rename to tests/codegen/dont-shuffle-bswaps.rs From d42d20d2edde9142e4eb5f30bc7ba16174172354 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 9 Feb 2025 16:54:53 -0800 Subject: [PATCH 09/15] tests: simplify dont-shuffle-bswaps test This should guarantee it tests what we want it to test and no more. --- tests/codegen/dont-shuffle-bswaps.rs | 38 ++++++---------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/tests/codegen/dont-shuffle-bswaps.rs b/tests/codegen/dont-shuffle-bswaps.rs index 16dae801ee43a..9a6f5862f9adf 100644 --- a/tests/codegen/dont-shuffle-bswaps.rs +++ b/tests/codegen/dont-shuffle-bswaps.rs @@ -1,11 +1,6 @@ -//@ revisions: OPT2 OPT3WINX64 OPT3LINX64 -//@ [OPT2] compile-flags: -O -//@ [OPT3LINX64] compile-flags: -C opt-level=3 -//@ [OPT3WINX64] compile-flags: -C opt-level=3 -//@ [OPT3LINX64] only-linux -//@ [OPT3WINX64] only-windows -//@ [OPT3LINX64] only-x86_64 -//@ [OPT3WINX64] only-x86_64 +//@ revisions: OPT2 OPT3 +//@[OPT2] compile-flags: -Copt-level=2 +//@[OPT3] compile-flags: -C opt-level=3 //@ min-llvm-version: 18.1.3 #![crate_type = "lib"] @@ -16,28 +11,11 @@ // to avoid complicating the code. // CHECK-LABEL: define{{.*}}void @convert( // CHECK-NOT: shufflevector -// OPT2: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 2 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 4 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 6 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 8 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 10 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 12 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 14 -// OPT2-NEXT: store i16 -// OPT3LINX64: load <8 x i16> -// OPT3LINX64-NEXT: call <8 x i16> @llvm.bswap -// OPT3LINX64-NEXT: store <8 x i16> -// OPT3WINX64: load <8 x i16> -// OPT3WINX64-NEXT: call <8 x i16> @llvm.bswap -// OPT3WINX64-NEXT: store <8 x i16> -// CHECK-NEXT: ret void +// On higher opt levels, this should just be a bswap: +// OPT3: load <8 x i16> +// OPT3-NEXT: call <8 x i16> @llvm.bswap +// OPT3-NEXT: store <8 x i16> +// OPT3-NEXT: ret void #[no_mangle] pub fn convert(value: [u16; 8]) -> [u8; 16] { #[cfg(target_endian = "little")] From 2ea795337c956b6841ef4b91cc09c1551ecc7c13 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 8 Feb 2025 19:45:40 -0800 Subject: [PATCH 10/15] tests/codegen: use -Copt-level=3 instead of -O --- tests/codegen/abi-repr-ext.rs | 2 +- tests/codegen/align-offset.rs | 2 +- tests/codegen/alloc-optimisation.rs | 2 +- tests/codegen/array-clone.rs | 2 +- tests/codegen/array-codegen.rs | 2 +- tests/codegen/array-equality.rs | 2 +- tests/codegen/array-optimized.rs | 2 +- tests/codegen/array-repeat.rs | 2 +- tests/codegen/asm/goto.rs | 2 +- tests/codegen/asm/may_unwind.rs | 2 +- tests/codegen/asm/maybe-uninit.rs | 2 +- tests/codegen/asm/multiple-options.rs | 2 +- tests/codegen/asm/options.rs | 2 +- tests/codegen/asm/x86-clobber_abi.rs | 2 +- tests/codegen/asm/x86-clobbers.rs | 2 +- tests/codegen/atomic-operations.rs | 2 +- tests/codegen/atomicptr.rs | 2 +- tests/codegen/avr/avr-func-addrspace.rs | 2 +- tests/codegen/binary-heap-peek-mut-pop-no-panic.rs | 2 +- tests/codegen/binary-search-index-no-bound-check.rs | 2 +- tests/codegen/box-uninit-bytes.rs | 2 +- tests/codegen/call-metadata.rs | 2 +- tests/codegen/cast-optimized.rs | 2 +- tests/codegen/cast-target-abi.rs | 2 +- tests/codegen/catch-unwind.rs | 2 +- tests/codegen/char-ascii-branchless.rs | 2 +- tests/codegen/checked_ilog.rs | 2 +- tests/codegen/checked_math.rs | 2 +- tests/codegen/clone_as_copy.rs | 2 +- tests/codegen/common_prim_int_ptr.rs | 2 +- tests/codegen/const-array.rs | 2 +- tests/codegen/cross-crate-inlining/always-inline.rs | 2 +- tests/codegen/cross-crate-inlining/auxiliary/always.rs | 2 +- tests/codegen/cross-crate-inlining/auxiliary/leaf.rs | 2 +- tests/codegen/cross-crate-inlining/auxiliary/never.rs | 2 +- tests/codegen/cross-crate-inlining/leaf-inlining.rs | 2 +- tests/codegen/cross-crate-inlining/never-inline.rs | 2 +- tests/codegen/dealloc-no-unwind.rs | 2 +- tests/codegen/debug-fndef-size.rs | 2 +- tests/codegen/debuginfo-constant-locals.rs | 2 +- tests/codegen/debuginfo-inline-callsite-location.rs | 2 +- tests/codegen/deduced-param-attrs.rs | 2 +- tests/codegen/drop-in-place-noalias.rs | 2 +- tests/codegen/dst-vtable-align-nonzero.rs | 2 +- tests/codegen/dst-vtable-size-range.rs | 2 +- tests/codegen/emscripten-catch-unwind-js-eh.rs | 2 +- tests/codegen/emscripten-catch-unwind-wasm-eh.rs | 2 +- tests/codegen/enum/enum-bounds-check-derived-idx.rs | 2 +- tests/codegen/enum/enum-bounds-check-issue-13926.rs | 2 +- tests/codegen/enum/enum-bounds-check.rs | 2 +- tests/codegen/enum/enum-early-otherwise-branch.rs | 2 +- tests/codegen/enum/unreachable_enum_default_branch.rs | 2 +- tests/codegen/error-provide.rs | 2 +- tests/codegen/external-no-mangle-statics.rs | 2 +- tests/codegen/f128-wasm32-callconv.rs | 2 +- tests/codegen/fastcall-inreg.rs | 2 +- tests/codegen/fewer-names.rs | 2 +- tests/codegen/function-arguments.rs | 2 +- tests/codegen/hint/cold_path.rs | 2 +- tests/codegen/hint/likely.rs | 2 +- tests/codegen/hint/unlikely.rs | 2 +- tests/codegen/i128-wasm32-callconv.rs | 2 +- tests/codegen/i128-x86-align.rs | 2 +- tests/codegen/integer-overflow.rs | 2 +- tests/codegen/intrinsics/aggregate-thin-pointer.rs | 2 +- tests/codegen/intrinsics/cold_path.rs | 2 +- tests/codegen/intrinsics/compare_bytes.rs | 2 +- tests/codegen/intrinsics/likely.rs | 2 +- tests/codegen/intrinsics/likely_assert.rs | 2 +- tests/codegen/intrinsics/nontemporal.rs | 2 +- tests/codegen/intrinsics/offset.rs | 2 +- tests/codegen/intrinsics/ptr_metadata.rs | 2 +- tests/codegen/intrinsics/select_unpredictable.rs | 2 +- tests/codegen/intrinsics/transmute-x64.rs | 2 +- tests/codegen/intrinsics/transmute.rs | 2 +- tests/codegen/intrinsics/unlikely.rs | 2 +- tests/codegen/is_val_statically_known.rs | 2 +- tests/codegen/issues/issue-101048.rs | 2 +- tests/codegen/issues/issue-101082.rs | 2 +- tests/codegen/issues/issue-101814.rs | 2 +- tests/codegen/issues/issue-103132.rs | 2 +- tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs | 2 +- tests/codegen/issues/issue-103327.rs | 2 +- tests/codegen/issues/issue-103840.rs | 2 +- tests/codegen/issues/issue-105386-ub-in-debuginfo.rs | 2 +- tests/codegen/issues/issue-106369.rs | 2 +- tests/codegen/issues/issue-107681-unwrap_unchecked.rs | 2 +- tests/codegen/issues/issue-108395-branchy-bool-match.rs | 2 +- tests/codegen/issues/issue-109328-split_first.rs | 2 +- tests/codegen/issues/issue-110797-enum-jump-same.rs | 2 +- tests/codegen/issues/issue-111603.rs | 2 +- tests/codegen/issues/issue-112509-slice-get-andthen-get.rs | 2 +- tests/codegen/issues/issue-114312.rs | 2 +- tests/codegen/issues/issue-115385-llvm-jump-threading.rs | 2 +- tests/codegen/issues/issue-116878.rs | 2 +- tests/codegen/issues/issue-118306.rs | 2 +- tests/codegen/issues/issue-118392.rs | 2 +- tests/codegen/issues/issue-119422.rs | 2 +- tests/codegen/issues/issue-121719-common-field-offset.rs | 2 +- tests/codegen/issues/issue-122600-ptr-discriminant-update.rs | 2 +- tests/codegen/issues/issue-13018.rs | 2 +- tests/codegen/issues/issue-27130.rs | 2 +- tests/codegen/issues/issue-34634.rs | 2 +- tests/codegen/issues/issue-34947-pow-i32.rs | 2 +- tests/codegen/issues/issue-36010-some-box-is_some.rs | 2 +- tests/codegen/issues/issue-37945.rs | 2 +- tests/codegen/issues/issue-45222.rs | 2 +- tests/codegen/issues/issue-45466.rs | 2 +- tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs | 2 +- tests/codegen/issues/issue-59352.rs | 2 +- tests/codegen/issues/issue-68667-unwrap-combinators.rs | 2 +- tests/codegen/issues/issue-69101-bounds-check.rs | 2 +- tests/codegen/issues/issue-73031.rs | 2 +- tests/codegen/issues/issue-73258.rs | 2 +- tests/codegen/issues/issue-73396-bounds-check-after-position.rs | 2 +- .../codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs | 2 +- tests/codegen/issues/issue-74938-array-split-at.rs | 2 +- tests/codegen/issues/issue-75525-bounds-checks.rs | 2 +- tests/codegen/issues/issue-75546.rs | 2 +- tests/codegen/issues/issue-75659.rs | 2 +- tests/codegen/issues/issue-75978.rs | 2 +- tests/codegen/issues/issue-77812.rs | 2 +- tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs | 2 +- tests/codegen/issues/issue-84268.rs | 2 +- tests/codegen/issues/issue-85872-multiple-reverse.rs | 2 +- tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs | 2 +- tests/codegen/issues/issue-93036-assert-index.rs | 2 +- tests/codegen/issues/issue-96274.rs | 2 +- tests/codegen/issues/issue-96497-slice-size-nowrap.rs | 2 +- tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs | 2 +- tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs | 2 +- tests/codegen/issues/issue-99960.rs | 2 +- tests/codegen/layout-size-checks.rs | 2 +- tests/codegen/lib-optimizations/iter-sum.rs | 2 +- tests/codegen/lib-optimizations/slice_rotate.rs | 2 +- tests/codegen/lifetime_start_end.rs | 2 +- tests/codegen/loads.rs | 2 +- tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs | 2 +- tests/codegen/lto-removes-invokes.rs | 2 +- tests/codegen/macos/i686-macosx-deployment-target.rs | 2 +- tests/codegen/macos/i686-no-macosx-deployment-target.rs | 2 +- tests/codegen/macos/x86_64-macosx-deployment-target.rs | 2 +- tests/codegen/macos/x86_64-no-macosx-deployment-target.rs | 2 +- tests/codegen/match-optimized.rs | 2 +- tests/codegen/match-optimizes-away.rs | 2 +- tests/codegen/maybeuninit-rvo.rs | 2 +- tests/codegen/mem-replace-simple-type.rs | 2 +- tests/codegen/merge-functions.rs | 2 +- tests/codegen/mir-aggregate-no-alloca.rs | 2 +- tests/codegen/mir-inlined-line-numbers.rs | 2 +- tests/codegen/move-before-nocapture-ref-arg.rs | 2 +- tests/codegen/move-operands.rs | 2 +- tests/codegen/naked-fn/generics.rs | 2 +- tests/codegen/noalias-box-off.rs | 2 +- tests/codegen/noalias-box.rs | 2 +- tests/codegen/noalias-flag.rs | 2 +- tests/codegen/noalias-refcell.rs | 2 +- tests/codegen/noalias-rwlockreadguard.rs | 2 +- tests/codegen/noalias-unpin.rs | 2 +- tests/codegen/nrvo.rs | 2 +- tests/codegen/option-as-slice.rs | 2 +- tests/codegen/option-niche-eq.rs | 2 +- tests/codegen/packed.rs | 2 +- tests/codegen/panic-abort-windows.rs | 2 +- tests/codegen/panic-in-drop-abort.rs | 2 +- tests/codegen/personality_lifetimes.rs | 2 +- tests/codegen/placement-new.rs | 2 +- tests/codegen/ptr-arithmetic.rs | 2 +- tests/codegen/ptr-read-metadata.rs | 2 +- tests/codegen/range-attribute.rs | 2 +- tests/codegen/range_to_inclusive.rs | 2 +- tests/codegen/reg-struct-return.rs | 2 +- tests/codegen/regparm-inreg.rs | 2 +- tests/codegen/repeat-trusted-len.rs | 2 +- tests/codegen/repr/transparent-byval-struct-ptr.rs | 2 +- tests/codegen/repr/transparent-imm-array.rs | 2 +- tests/codegen/repr/transparent-mips64.rs | 2 +- tests/codegen/repr/transparent-opaque-ptr.rs | 2 +- tests/codegen/repr/transparent-sparc64.rs | 2 +- tests/codegen/repr/transparent-sysv64.rs | 2 +- tests/codegen/repr/transparent.rs | 2 +- tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs | 2 +- tests/codegen/riscv-abi/riscv64-lp64d-abi.rs | 2 +- tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs | 2 +- tests/codegen/rust-abi-arch-specific-adjustment.rs | 2 +- tests/codegen/s390x-simd.rs | 2 +- tests/codegen/scalar-pair-bool.rs | 2 +- tests/codegen/simd/swap-simd-types.rs | 2 +- tests/codegen/slice-as_chunks.rs | 2 +- tests/codegen/slice-indexing.rs | 2 +- tests/codegen/slice-iter-fold.rs | 2 +- tests/codegen/slice-iter-len-eq-zero.rs | 2 +- tests/codegen/slice-iter-nonnull.rs | 2 +- tests/codegen/slice-pointer-nonnull-unwrap.rs | 2 +- tests/codegen/slice-position-bounds-check.rs | 2 +- tests/codegen/slice-ref-equality.rs | 2 +- tests/codegen/slice-reverse.rs | 2 +- tests/codegen/slice-windows-no-bounds-check.rs | 2 +- tests/codegen/slice_as_from_ptr_range.rs | 2 +- tests/codegen/some-global-nonnull.rs | 2 +- tests/codegen/sparc-struct-abi.rs | 2 +- tests/codegen/static-relocation-model-msvc.rs | 2 +- tests/codegen/step_by-overflow-checks.rs | 2 +- tests/codegen/swap-large-types.rs | 2 +- tests/codegen/swap-small-types.rs | 2 +- tests/codegen/thread-local.rs | 2 +- tests/codegen/to_vec.rs | 2 +- tests/codegen/trailing_zeros.rs | 2 +- tests/codegen/transmute-optimized.rs | 2 +- tests/codegen/try_question_mark_nop.rs | 2 +- tests/codegen/ub-checks.rs | 2 +- tests/codegen/unchecked_shifts.rs | 2 +- tests/codegen/union-abi.rs | 2 +- tests/codegen/var-names.rs | 2 +- tests/codegen/vec-as-ptr.rs | 2 +- tests/codegen/vec-calloc.rs | 2 +- tests/codegen/vec-in-place.rs | 2 +- tests/codegen/vec-iter-collect-len.rs | 2 +- tests/codegen/vec-iter.rs | 2 +- tests/codegen/vec-len-invariant.rs | 2 +- tests/codegen/vec-optimizes-away.rs | 2 +- tests/codegen/vec-reserve-extend.rs | 2 +- tests/codegen/vec-shrink-panik.rs | 2 +- tests/codegen/vec-with-capacity.rs | 2 +- tests/codegen/vec_pop_push_noop.rs | 2 +- tests/codegen/vecdeque-drain.rs | 2 +- tests/codegen/vecdeque-nonempty-get-no-panic.rs | 2 +- tests/codegen/vecdeque_no_panic.rs | 2 +- tests/codegen/vecdeque_pop_push.rs | 2 +- tests/codegen/virtual-function-elimination-32bit.rs | 2 +- tests/codegen/virtual-function-elimination.rs | 2 +- tests/codegen/vtable-loads.rs | 2 +- tests/codegen/zip.rs | 2 +- 233 files changed, 233 insertions(+), 233 deletions(-) diff --git a/tests/codegen/abi-repr-ext.rs b/tests/codegen/abi-repr-ext.rs index a42f73566961e..b06d225ed70e6 100644 --- a/tests/codegen/abi-repr-ext.rs +++ b/tests/codegen/abi-repr-ext.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv diff --git a/tests/codegen/align-offset.rs b/tests/codegen/align-offset.rs index aeac230f718fb..21062cc0a914b 100644 --- a/tests/codegen/align-offset.rs +++ b/tests/codegen/align-offset.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/alloc-optimisation.rs b/tests/codegen/alloc-optimisation.rs index 6f320e68fdb30..8abeecf8550be 100644 --- a/tests/codegen/alloc-optimisation.rs +++ b/tests/codegen/alloc-optimisation.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/array-clone.rs b/tests/codegen/array-clone.rs index 2873f3cadca82..35445174684f9 100644 --- a/tests/codegen/array-clone.rs +++ b/tests/codegen/array-clone.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs index fc272f2556cbf..9b0c6e8c3472e 100644 --- a/tests/codegen/array-codegen.rs +++ b/tests/codegen/array-codegen.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/array-equality.rs b/tests/codegen/array-equality.rs index bc5425c7a4f4e..fa0475bf4809c 100644 --- a/tests/codegen/array-equality.rs +++ b/tests/codegen/array-equality.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/array-optimized.rs b/tests/codegen/array-optimized.rs index 42fdbd39b7efa..000163d5519b3 100644 --- a/tests/codegen/array-optimized.rs +++ b/tests/codegen/array-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/array-repeat.rs b/tests/codegen/array-repeat.rs index b6f3b2e83d3e1..4c755df939034 100644 --- a/tests/codegen/array-repeat.rs +++ b/tests/codegen/array-repeat.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(array_repeat)] diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs index c40a43fbe1bd3..7a87bb7983bae 100644 --- a/tests/codegen/asm/goto.rs +++ b/tests/codegen/asm/goto.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/may_unwind.rs b/tests/codegen/asm/may_unwind.rs index be66b3975ff87..63cdec7584c9b 100644 --- a/tests/codegen/asm/may_unwind.rs +++ b/tests/codegen/asm/may_unwind.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/maybe-uninit.rs b/tests/codegen/asm/maybe-uninit.rs index 55813c35a468b..d76d5cb1312e2 100644 --- a/tests/codegen/asm/maybe-uninit.rs +++ b/tests/codegen/asm/maybe-uninit.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/multiple-options.rs b/tests/codegen/asm/multiple-options.rs index 1ee295e32c9e9..4d87471a1939d 100644 --- a/tests/codegen/asm/multiple-options.rs +++ b/tests/codegen/asm/multiple-options.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/options.rs b/tests/codegen/asm/options.rs index 96a72c2f5ae90..c087f91fd4343 100644 --- a/tests/codegen/asm/options.rs +++ b/tests/codegen/asm/options.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/x86-clobber_abi.rs b/tests/codegen/asm/x86-clobber_abi.rs index cc563474bf8c2..5b34b4e8ef312 100644 --- a/tests/codegen/asm/x86-clobber_abi.rs +++ b/tests/codegen/asm/x86-clobber_abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/x86-clobbers.rs b/tests/codegen/asm/x86-clobbers.rs index 4094db7413468..50163b646b257 100644 --- a/tests/codegen/asm/x86-clobbers.rs +++ b/tests/codegen/asm/x86-clobbers.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/atomic-operations.rs b/tests/codegen/atomic-operations.rs index 8a70c94e48053..8771b8b241998 100644 --- a/tests/codegen/atomic-operations.rs +++ b/tests/codegen/atomic-operations.rs @@ -1,5 +1,5 @@ // Code generation of atomic operations. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] use std::sync::atomic::AtomicI32; diff --git a/tests/codegen/atomicptr.rs b/tests/codegen/atomicptr.rs index e8c5e6a674970..4819af40ca2d2 100644 --- a/tests/codegen/atomicptr.rs +++ b/tests/codegen/atomicptr.rs @@ -4,7 +4,7 @@ // ensures that we do not have such a round-trip for AtomicPtr::swap, because LLVM supports pointer // arguments to `atomicrmw xchg`. -//@ compile-flags: -O -Cno-prepopulate-passes +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes #![crate_type = "lib"] #![feature(strict_provenance_atomic_ptr)] diff --git a/tests/codegen/avr/avr-func-addrspace.rs b/tests/codegen/avr/avr-func-addrspace.rs index 7a36490fe93b8..ed8acccb1ad85 100644 --- a/tests/codegen/avr/avr-func-addrspace.rs +++ b/tests/codegen/avr/avr-func-addrspace.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --target=avr-unknown-gnu-atmega328 --crate-type=rlib -C panic=abort +//@ compile-flags: -Copt-level=3 --target=avr-unknown-gnu-atmega328 --crate-type=rlib -C panic=abort //@ needs-llvm-components: avr // This test validates that function pointers can be stored in global variables diff --git a/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs index e3bc9a4761cfd..2c40327f62454 100644 --- a/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs +++ b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions #![crate_type = "lib"] diff --git a/tests/codegen/binary-search-index-no-bound-check.rs b/tests/codegen/binary-search-index-no-bound-check.rs index a213c015a40b3..d59c0beec6419 100644 --- a/tests/codegen/binary-search-index-no-bound-check.rs +++ b/tests/codegen/binary-search-index-no-bound-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Make sure no bounds checks are emitted when slicing or indexing diff --git a/tests/codegen/box-uninit-bytes.rs b/tests/codegen/box-uninit-bytes.rs index 63a6c7b841560..3b83ef3e250c4 100644 --- a/tests/codegen/box-uninit-bytes.rs +++ b/tests/codegen/box-uninit-bytes.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] use std::mem::MaybeUninit; diff --git a/tests/codegen/call-metadata.rs b/tests/codegen/call-metadata.rs index b986b4467face..7ad3ded2f09de 100644 --- a/tests/codegen/call-metadata.rs +++ b/tests/codegen/call-metadata.rs @@ -1,7 +1,7 @@ // Checks that range metadata gets emitted on calls to functions returning a // scalar value. -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ max-llvm-major-version: 18 #![crate_type = "lib"] diff --git a/tests/codegen/cast-optimized.rs b/tests/codegen/cast-optimized.rs index 59cf40935cd54..11220c4a922b1 100644 --- a/tests/codegen/cast-optimized.rs +++ b/tests/codegen/cast-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or diff --git a/tests/codegen/cast-target-abi.rs b/tests/codegen/cast-target-abi.rs index b3a35cbf3b1c6..a0801eb982692 100644 --- a/tests/codegen/cast-target-abi.rs +++ b/tests/codegen/cast-target-abi.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength //@ revisions:aarch64 loongarch64 powerpc64 sparc64 x86_64 //@ min-llvm-version: 19 -//@ compile-flags: -O -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu //@[aarch64] needs-llvm-components: arm diff --git a/tests/codegen/catch-unwind.rs b/tests/codegen/catch-unwind.rs index 48ad486fa03a6..d1ff55bcc285b 100644 --- a/tests/codegen/catch-unwind.rs +++ b/tests/codegen/catch-unwind.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // On x86 the closure is inlined in foo() producing something like // define i32 @foo() [...] { diff --git a/tests/codegen/char-ascii-branchless.rs b/tests/codegen/char-ascii-branchless.rs index 76d2f617ed1cd..f99066aa9aaec 100644 --- a/tests/codegen/char-ascii-branchless.rs +++ b/tests/codegen/char-ascii-branchless.rs @@ -1,6 +1,6 @@ // Checks that these functions are branchless. // -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/checked_ilog.rs b/tests/codegen/checked_ilog.rs index d7dfc7c29e7da..e340a45b6a96d 100644 --- a/tests/codegen/checked_ilog.rs +++ b/tests/codegen/checked_ilog.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/checked_math.rs b/tests/codegen/checked_math.rs index c612ddccdaa46..66667c6948818 100644 --- a/tests/codegen/checked_math.rs +++ b/tests/codegen/checked_math.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(unchecked_shifts)] diff --git a/tests/codegen/clone_as_copy.rs b/tests/codegen/clone_as_copy.rs index 6ba198297e226..c39f120044c09 100644 --- a/tests/codegen/clone_as_copy.rs +++ b/tests/codegen/clone_as_copy.rs @@ -1,7 +1,7 @@ //@ revisions: DEBUGINFO NODEBUGINFO //@ compile-flags: -Zunsound-mir-opts // FIXME: see -//@ compile-flags: -O -Cno-prepopulate-passes +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes //@ [DEBUGINFO] compile-flags: -Cdebuginfo=full // From https://github.com/rust-lang/rust/issues/128081. diff --git a/tests/codegen/common_prim_int_ptr.rs b/tests/codegen/common_prim_int_ptr.rs index aa7ebb4c9119d..8eb0502417417 100644 --- a/tests/codegen/common_prim_int_ptr.rs +++ b/tests/codegen/common_prim_int_ptr.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/const-array.rs b/tests/codegen/const-array.rs index f2b331c315dce..e257d8acc0881 100644 --- a/tests/codegen/const-array.rs +++ b/tests/codegen/const-array.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/always-inline.rs b/tests/codegen/cross-crate-inlining/always-inline.rs index d3a35dadb67bc..df28b3fe197cd 100644 --- a/tests/codegen/cross-crate-inlining/always-inline.rs +++ b/tests/codegen/cross-crate-inlining/always-inline.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ aux-build:always.rs #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/auxiliary/always.rs b/tests/codegen/cross-crate-inlining/auxiliary/always.rs index 7f524e17d34a1..6ee3f81e3c879 100644 --- a/tests/codegen/cross-crate-inlining/auxiliary/always.rs +++ b/tests/codegen/cross-crate-inlining/auxiliary/always.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zcross-crate-inline-threshold=always +//@ compile-flags: -Copt-level=3 -Zcross-crate-inline-threshold=always #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs b/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs index 5895812b5ee51..d059a3d0a73b8 100644 --- a/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs +++ b/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/auxiliary/never.rs b/tests/codegen/cross-crate-inlining/auxiliary/never.rs index 3a391608df849..55c90809ec18f 100644 --- a/tests/codegen/cross-crate-inlining/auxiliary/never.rs +++ b/tests/codegen/cross-crate-inlining/auxiliary/never.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zcross-crate-inline-threshold=never +//@ compile-flags: -Copt-level=3 -Zcross-crate-inline-threshold=never #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/leaf-inlining.rs b/tests/codegen/cross-crate-inlining/leaf-inlining.rs index b47898f750a24..37132312ca94c 100644 --- a/tests/codegen/cross-crate-inlining/leaf-inlining.rs +++ b/tests/codegen/cross-crate-inlining/leaf-inlining.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zcross-crate-inline-threshold=yes +//@ compile-flags: -Copt-level=3 -Zcross-crate-inline-threshold=yes //@ aux-build:leaf.rs #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/never-inline.rs b/tests/codegen/cross-crate-inlining/never-inline.rs index eedf90ceec0fc..759f65d9d42b2 100644 --- a/tests/codegen/cross-crate-inlining/never-inline.rs +++ b/tests/codegen/cross-crate-inlining/never-inline.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ aux-build:never.rs #![crate_type = "lib"] diff --git a/tests/codegen/dealloc-no-unwind.rs b/tests/codegen/dealloc-no-unwind.rs index ead26da610e25..c560d7a993209 100644 --- a/tests/codegen/dealloc-no-unwind.rs +++ b/tests/codegen/dealloc-no-unwind.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/debug-fndef-size.rs b/tests/codegen/debug-fndef-size.rs index c58a8228967a4..8f716c34e7b74 100644 --- a/tests/codegen/debug-fndef-size.rs +++ b/tests/codegen/debug-fndef-size.rs @@ -1,7 +1,7 @@ // Verify that `i32::cmp` FnDef type is declared with a size of 0 and an // alignment of 8 bits (1 byte) in LLVM debuginfo. -//@ compile-flags: -O -g -Cno-prepopulate-passes +//@ compile-flags: -Copt-level=3 -g -Cno-prepopulate-passes //@ ignore-msvc the types are mangled differently use std::cmp::Ordering; diff --git a/tests/codegen/debuginfo-constant-locals.rs b/tests/codegen/debuginfo-constant-locals.rs index c8f1d964722ef..580c69c05a54d 100644 --- a/tests/codegen/debuginfo-constant-locals.rs +++ b/tests/codegen/debuginfo-constant-locals.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -g -O +//@ compile-flags: -g -Copt-level=3 // Check that simple constant values are preserved in debuginfo across both MIR opts and LLVM opts diff --git a/tests/codegen/debuginfo-inline-callsite-location.rs b/tests/codegen/debuginfo-inline-callsite-location.rs index c31788d82db32..59ade52ad3276 100644 --- a/tests/codegen/debuginfo-inline-callsite-location.rs +++ b/tests/codegen/debuginfo-inline-callsite-location.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -g -O -C panic=abort +//@ compile-flags: -g -Copt-level=3 -C panic=abort // Check that each inline call site for the same function uses the same "sub-program" so that LLVM // can correctly merge the debug info if it merges the inlined code (e.g., for merging of tail diff --git a/tests/codegen/deduced-param-attrs.rs b/tests/codegen/deduced-param-attrs.rs index 5e7c571b63f8d..22db090d4d889 100644 --- a/tests/codegen/deduced-param-attrs.rs +++ b/tests/codegen/deduced-param-attrs.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![allow(incomplete_features)] diff --git a/tests/codegen/drop-in-place-noalias.rs b/tests/codegen/drop-in-place-noalias.rs index 2dc769df1c92b..bff2f52781f23 100644 --- a/tests/codegen/drop-in-place-noalias.rs +++ b/tests/codegen/drop-in-place-noalias.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes // Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`. // Note that non-Unpin types should not get `noalias`, matching &mut behavior. diff --git a/tests/codegen/dst-vtable-align-nonzero.rs b/tests/codegen/dst-vtable-align-nonzero.rs index cb07e43238c10..1404bd64f500c 100644 --- a/tests/codegen/dst-vtable-align-nonzero.rs +++ b/tests/codegen/dst-vtable-align-nonzero.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/dst-vtable-size-range.rs b/tests/codegen/dst-vtable-size-range.rs index 69d8e68497ca6..670f5e8d553fa 100644 --- a/tests/codegen/dst-vtable-size-range.rs +++ b/tests/codegen/dst-vtable-size-range.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/emscripten-catch-unwind-js-eh.rs b/tests/codegen/emscripten-catch-unwind-js-eh.rs index b15fb40b68f00..018ad5454fc23 100644 --- a/tests/codegen/emscripten-catch-unwind-js-eh.rs +++ b/tests/codegen/emscripten-catch-unwind-js-eh.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --target wasm32-unknown-emscripten +//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten //@ needs-llvm-components: webassembly // Emscripten has its own unique implementation of catch_unwind (in `codegen_emcc_try`), diff --git a/tests/codegen/emscripten-catch-unwind-wasm-eh.rs b/tests/codegen/emscripten-catch-unwind-wasm-eh.rs index 72395f432d5f8..0fc9ae96720e4 100644 --- a/tests/codegen/emscripten-catch-unwind-wasm-eh.rs +++ b/tests/codegen/emscripten-catch-unwind-wasm-eh.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --target wasm32-unknown-emscripten -Z emscripten-wasm-eh +//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten -Z emscripten-wasm-eh //@ needs-llvm-components: webassembly // Emscripten catch_unwind using wasm exceptions diff --git a/tests/codegen/enum/enum-bounds-check-derived-idx.rs b/tests/codegen/enum/enum-bounds-check-derived-idx.rs index 15280cb2e6c87..a5785f4addf05 100644 --- a/tests/codegen/enum/enum-bounds-check-derived-idx.rs +++ b/tests/codegen/enum/enum-bounds-check-derived-idx.rs @@ -1,6 +1,6 @@ // This test checks an optimization that is not guaranteed to work. This test case should not block // a future LLVM update. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-bounds-check-issue-13926.rs b/tests/codegen/enum/enum-bounds-check-issue-13926.rs index b60ff38ce392c..6e8e5035b0d00 100644 --- a/tests/codegen/enum/enum-bounds-check-issue-13926.rs +++ b/tests/codegen/enum/enum-bounds-check-issue-13926.rs @@ -1,6 +1,6 @@ // This test checks an optimization that is not guaranteed to work. This test case should not block // a future LLVM update. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-bounds-check.rs b/tests/codegen/enum/enum-bounds-check.rs index c44c007ed6a9f..5362598ca7c43 100644 --- a/tests/codegen/enum/enum-bounds-check.rs +++ b/tests/codegen/enum/enum-bounds-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-early-otherwise-branch.rs b/tests/codegen/enum/enum-early-otherwise-branch.rs index 07c8aed2624c1..8d39d8e9b7466 100644 --- a/tests/codegen/enum/enum-early-otherwise-branch.rs +++ b/tests/codegen/enum/enum-early-otherwise-branch.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/unreachable_enum_default_branch.rs b/tests/codegen/enum/unreachable_enum_default_branch.rs index 76a92496c0729..55b165fc111dd 100644 --- a/tests/codegen/enum/unreachable_enum_default_branch.rs +++ b/tests/codegen/enum/unreachable_enum_default_branch.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/error-provide.rs b/tests/codegen/error-provide.rs index 68dd383e5cce0..25a66078fd4a8 100644 --- a/tests/codegen/error-provide.rs +++ b/tests/codegen/error-provide.rs @@ -1,6 +1,6 @@ // Codegen test for #126242 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(error_generic_member_access)] use std::error::Request; diff --git a/tests/codegen/external-no-mangle-statics.rs b/tests/codegen/external-no-mangle-statics.rs index a44867ff9230f..dc4eca8c7b486 100644 --- a/tests/codegen/external-no-mangle-statics.rs +++ b/tests/codegen/external-no-mangle-statics.rs @@ -1,6 +1,6 @@ //@ revisions: lib staticlib //@ ignore-emscripten default visibility is hidden -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ [lib] compile-flags: --crate-type lib //@ [staticlib] compile-flags: --crate-type staticlib // `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their diff --git a/tests/codegen/f128-wasm32-callconv.rs b/tests/codegen/f128-wasm32-callconv.rs index 8b1b5e7fb013f..7dccbda18f1aa 100644 --- a/tests/codegen/f128-wasm32-callconv.rs +++ b/tests/codegen/f128-wasm32-callconv.rs @@ -1,7 +1,7 @@ //! Verify that Rust implements the expected calling convention for `f128` //@ add-core-stubs -//@ compile-flags: -O --target wasm32-wasip1 +//@ compile-flags: -Copt-level=3 --target wasm32-wasip1 //@ needs-llvm-components: webassembly #![crate_type = "lib"] diff --git a/tests/codegen/fastcall-inreg.rs b/tests/codegen/fastcall-inreg.rs index 2459ec1539e43..00b390bf1bf17 100644 --- a/tests/codegen/fastcall-inreg.rs +++ b/tests/codegen/fastcall-inreg.rs @@ -2,7 +2,7 @@ // as "inreg" like the C/C++ compilers for the platforms. // x86 only. -//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ needs-llvm-components: x86 #![crate_type = "lib"] diff --git a/tests/codegen/fewer-names.rs b/tests/codegen/fewer-names.rs index a171629a076b2..ff7a916b619c1 100644 --- a/tests/codegen/fewer-names.rs +++ b/tests/codegen/fewer-names.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Coverflow-checks=no -O +//@ compile-flags: -Coverflow-checks=no -Copt-level=3 //@ revisions: YES NO //@ [YES]compile-flags: -Zfewer-names=yes //@ [NO] compile-flags: -Zfewer-names=no diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 1a211dfe096b3..f0708a7a109f2 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(rustc_attrs)] #![feature(dyn_star)] diff --git a/tests/codegen/hint/cold_path.rs b/tests/codegen/hint/cold_path.rs index dac72073f858b..149abe474f67b 100644 --- a/tests/codegen/hint/cold_path.rs +++ b/tests/codegen/hint/cold_path.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(cold_path)] diff --git a/tests/codegen/hint/likely.rs b/tests/codegen/hint/likely.rs index 2f589cc99d282..75f9e7aae367d 100644 --- a/tests/codegen/hint/likely.rs +++ b/tests/codegen/hint/likely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(likely_unlikely)] diff --git a/tests/codegen/hint/unlikely.rs b/tests/codegen/hint/unlikely.rs index 328533f30816c..248b1e2537e96 100644 --- a/tests/codegen/hint/unlikely.rs +++ b/tests/codegen/hint/unlikely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(likely_unlikely)] diff --git a/tests/codegen/i128-wasm32-callconv.rs b/tests/codegen/i128-wasm32-callconv.rs index c6d25fbe8bea2..9d73d270ef3d0 100644 --- a/tests/codegen/i128-wasm32-callconv.rs +++ b/tests/codegen/i128-wasm32-callconv.rs @@ -1,7 +1,7 @@ //! Verify that Rust implements the expected calling convention for `i128`/`u128`. //@ add-core-stubs -//@ compile-flags: -O --target wasm32-wasip1 +//@ compile-flags: -Copt-level=3 --target wasm32-wasip1 //@ needs-llvm-components: webassembly #![crate_type = "lib"] diff --git a/tests/codegen/i128-x86-align.rs b/tests/codegen/i128-x86-align.rs index ac101b72513dd..75802b0c5056a 100644 --- a/tests/codegen/i128-x86-align.rs +++ b/tests/codegen/i128-x86-align.rs @@ -1,5 +1,5 @@ //@ only-x86_64 -//@ compile-flags: -O -C no-prepopulate-passes --crate-type=lib +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --crate-type=lib // On LLVM 17 and earlier LLVM's own data layout specifies that i128 has 8 byte alignment, // while rustc wants it to have 16 byte alignment. This test checks that we handle this diff --git a/tests/codegen/integer-overflow.rs b/tests/codegen/integer-overflow.rs index a6407476fc209..80362247a86f1 100644 --- a/tests/codegen/integer-overflow.rs +++ b/tests/codegen/integer-overflow.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C overflow-checks=on +//@ compile-flags: -Copt-level=3 -C overflow-checks=on #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/aggregate-thin-pointer.rs b/tests/codegen/intrinsics/aggregate-thin-pointer.rs index aa3bf7e8b14a4..bd590ce91809f 100644 --- a/tests/codegen/intrinsics/aggregate-thin-pointer.rs +++ b/tests/codegen/intrinsics/aggregate-thin-pointer.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z mir-enable-passes=-InstSimplify +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mir-enable-passes=-InstSimplify //@ only-64bit (so I don't need to worry about usize) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/cold_path.rs b/tests/codegen/intrinsics/cold_path.rs index 24ee84e07bf1d..fd75324b671e2 100644 --- a/tests/codegen/intrinsics/cold_path.rs +++ b/tests/codegen/intrinsics/cold_path.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/compare_bytes.rs b/tests/codegen/intrinsics/compare_bytes.rs index cd592918fb0c2..3ab0e4e97e09d 100644 --- a/tests/codegen/intrinsics/compare_bytes.rs +++ b/tests/codegen/intrinsics/compare_bytes.rs @@ -1,5 +1,5 @@ //@ revisions: INT32 INT16 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ [INT32] ignore-16bit //@ [INT16] only-16bit diff --git a/tests/codegen/intrinsics/likely.rs b/tests/codegen/intrinsics/likely.rs index e318390db205c..c5e3c466f4525 100644 --- a/tests/codegen/intrinsics/likely.rs +++ b/tests/codegen/intrinsics/likely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/likely_assert.rs b/tests/codegen/intrinsics/likely_assert.rs index 0ddbd6206aeea..87ffb4ee3fb65 100644 --- a/tests/codegen/intrinsics/likely_assert.rs +++ b/tests/codegen/intrinsics/likely_assert.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/intrinsics/nontemporal.rs b/tests/codegen/intrinsics/nontemporal.rs index ff2d629606688..af8892d30e7f4 100644 --- a/tests/codegen/intrinsics/nontemporal.rs +++ b/tests/codegen/intrinsics/nontemporal.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@revisions: with_nontemporal without_nontemporal //@[with_nontemporal] compile-flags: --target aarch64-unknown-linux-gnu //@[with_nontemporal] needs-llvm-components: aarch64 diff --git a/tests/codegen/intrinsics/offset.rs b/tests/codegen/intrinsics/offset.rs index d4791cd30b0be..d76d3e705abad 100644 --- a/tests/codegen/intrinsics/offset.rs +++ b/tests/codegen/intrinsics/offset.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/ptr_metadata.rs b/tests/codegen/intrinsics/ptr_metadata.rs index f4bf5a1f5f173..87a32fa3d2468 100644 --- a/tests/codegen/intrinsics/ptr_metadata.rs +++ b/tests/codegen/intrinsics/ptr_metadata.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z inline-mir +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z inline-mir //@ only-64bit (so I don't need to worry about usize) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/select_unpredictable.rs b/tests/codegen/intrinsics/select_unpredictable.rs index ea6127a48bf3f..68a02c8342d06 100644 --- a/tests/codegen/intrinsics/select_unpredictable.rs +++ b/tests/codegen/intrinsics/select_unpredictable.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![feature(core_intrinsics)] #![feature(select_unpredictable)] diff --git a/tests/codegen/intrinsics/transmute-x64.rs b/tests/codegen/intrinsics/transmute-x64.rs index ea1c6b0e7e801..fe68f18366701 100644 --- a/tests/codegen/intrinsics/transmute-x64.rs +++ b/tests/codegen/intrinsics/transmute-x64.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-x86_64 (it's using arch-specific types) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index 8c8e975d327a2..541333a52b0df 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-64bit (so I don't need to worry about usize) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/unlikely.rs b/tests/codegen/intrinsics/unlikely.rs index 2d776031a52ef..90ebf070d2700 100644 --- a/tests/codegen/intrinsics/unlikely.rs +++ b/tests/codegen/intrinsics/unlikely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/is_val_statically_known.rs b/tests/codegen/is_val_statically_known.rs index fe432d3bcc4de..8119d3a3bf678 100644 --- a/tests/codegen/is_val_statically_known.rs +++ b/tests/codegen/is_val_statically_known.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --crate-type=lib -Zmerge-functions=disabled -O +//@ compile-flags: --crate-type=lib -Zmerge-functions=disabled -Copt-level=3 #![feature(core_intrinsics)] #![feature(f16, f128)] diff --git a/tests/codegen/issues/issue-101048.rs b/tests/codegen/issues/issue-101048.rs index fa6dc550f301e..cfe65e758fdbd 100644 --- a/tests/codegen/issues/issue-101048.rs +++ b/tests/codegen/issues/issue-101048.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-101082.rs b/tests/codegen/issues/issue-101082.rs index 4be1b6cb168e8..048b69d207b6d 100644 --- a/tests/codegen/issues/issue-101082.rs +++ b/tests/codegen/issues/issue-101082.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ revisions: host x86-64-v3 // This particular CPU regressed in #131563 diff --git a/tests/codegen/issues/issue-101814.rs b/tests/codegen/issues/issue-101814.rs index e3843e9edb0bd..668ec8476e8c0 100644 --- a/tests/codegen/issues/issue-101814.rs +++ b/tests/codegen/issues/issue-101814.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103132.rs b/tests/codegen/issues/issue-103132.rs index 8c1a17c8b78c2..623cab92806dc 100644 --- a/tests/codegen/issues/issue-103132.rs +++ b/tests/codegen/issues/issue-103132.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C overflow-checks +//@ compile-flags: -Copt-level=3 -C overflow-checks #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs b/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs index 122f02fbbc55b..3ada5412e8335 100644 --- a/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs +++ b/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C debug-assertions=yes +//@ compile-flags: -Copt-level=3 -C debug-assertions=yes #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103327.rs b/tests/codegen/issues/issue-103327.rs index f8cf273e4a6c2..4de3cfd12a09a 100644 --- a/tests/codegen/issues/issue-103327.rs +++ b/tests/codegen/issues/issue-103327.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103840.rs b/tests/codegen/issues/issue-103840.rs index 14f157771e077..c6c5098bdd04f 100644 --- a/tests/codegen/issues/issue-103840.rs +++ b/tests/codegen/issues/issue-103840.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] pub fn foo(t: &mut Vec) { diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index db9eeda19a6c6..848aa910b584e 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates +//@ compile-flags: --crate-type=lib -Copt-level=3 -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates // MIR SROA will decompose the closure #![feature(stmt_expr_attributes)] diff --git a/tests/codegen/issues/issue-106369.rs b/tests/codegen/issues/issue-106369.rs index fd375e4e60584..3583d20c9fa1c 100644 --- a/tests/codegen/issues/issue-106369.rs +++ b/tests/codegen/issues/issue-106369.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-107681-unwrap_unchecked.rs b/tests/codegen/issues/issue-107681-unwrap_unchecked.rs index 7d9679d2322b2..fd7296de4c864 100644 --- a/tests/codegen/issues/issue-107681-unwrap_unchecked.rs +++ b/tests/codegen/issues/issue-107681-unwrap_unchecked.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ min-llvm-version: 19 // Test for #107681. diff --git a/tests/codegen/issues/issue-108395-branchy-bool-match.rs b/tests/codegen/issues/issue-108395-branchy-bool-match.rs index 24f5c0f663532..96387e791b03a 100644 --- a/tests/codegen/issues/issue-108395-branchy-bool-match.rs +++ b/tests/codegen/issues/issue-108395-branchy-bool-match.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled //! Test for . Check that //! matching on two bools with wildcards does not produce branches. #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-109328-split_first.rs b/tests/codegen/issues/issue-109328-split_first.rs index 7f7957593d2de..26235edfc190f 100644 --- a/tests/codegen/issues/issue-109328-split_first.rs +++ b/tests/codegen/issues/issue-109328-split_first.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-110797-enum-jump-same.rs b/tests/codegen/issues/issue-110797-enum-jump-same.rs index f114e0e260eb5..b5f7c08795bc6 100644 --- a/tests/codegen/issues/issue-110797-enum-jump-same.rs +++ b/tests/codegen/issues/issue-110797-enum-jump-same.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs index 41bfb493ff580..2ba5a3f876aed 100644 --- a/tests/codegen/issues/issue-111603.rs +++ b/tests/codegen/issues/issue-111603.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(get_mut_unchecked, new_uninit)] diff --git a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs index aee2edd8dfad2..3909b203d0897 100644 --- a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs +++ b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @write_u8_variant_a diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs index be5b999afd0b0..e9418249089dd 100644 --- a/tests/codegen/issues/issue-114312.rs +++ b/tests/codegen/issues/issue-114312.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64-unknown-linux-gnu // We want to check that this function does not mis-optimize to loop jumping. diff --git a/tests/codegen/issues/issue-115385-llvm-jump-threading.rs b/tests/codegen/issues/issue-115385-llvm-jump-threading.rs index 55aa69a7de034..8cabd94f2028c 100644 --- a/tests/codegen/issues/issue-115385-llvm-jump-threading.rs +++ b/tests/codegen/issues/issue-115385-llvm-jump-threading.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Ccodegen-units=1 +//@ compile-flags: -Copt-level=3 -Ccodegen-units=1 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-116878.rs b/tests/codegen/issues/issue-116878.rs index a09fac42c0182..daf46c8bb554a 100644 --- a/tests/codegen/issues/issue-116878.rs +++ b/tests/codegen/issues/issue-116878.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] /// Make sure no bounds checks are emitted after a `get_unchecked`. diff --git a/tests/codegen/issues/issue-118306.rs b/tests/codegen/issues/issue-118306.rs index 0778ab3fde970..f9f3e0c0529cf 100644 --- a/tests/codegen/issues/issue-118306.rs +++ b/tests/codegen/issues/issue-118306.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ min-llvm-version: 19 //@ only-x86_64 diff --git a/tests/codegen/issues/issue-118392.rs b/tests/codegen/issues/issue-118392.rs index ce2332b4c3c75..07de8d9b237a7 100644 --- a/tests/codegen/issues/issue-118392.rs +++ b/tests/codegen/issues/issue-118392.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @div2 diff --git a/tests/codegen/issues/issue-119422.rs b/tests/codegen/issues/issue-119422.rs index 682430a79f4a9..e1a082c377f8b 100644 --- a/tests/codegen/issues/issue-119422.rs +++ b/tests/codegen/issues/issue-119422.rs @@ -1,7 +1,7 @@ //! This test checks that compiler don't generate useless compares to zeros //! for `NonZero` integer types. //! -//@ compile-flags: -O --edition=2021 -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 --edition=2021 -Zmerge-functions=disabled //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-121719-common-field-offset.rs b/tests/codegen/issues/issue-121719-common-field-offset.rs index 11a8aa8dcd144..9f5f44e037555 100644 --- a/tests/codegen/issues/issue-121719-common-field-offset.rs +++ b/tests/codegen/issues/issue-121719-common-field-offset.rs @@ -1,7 +1,7 @@ //! This test checks that match branches which all access a field //! at the same offset are merged together. //! -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[repr(C)] diff --git a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs index 4b520a6206951..fdb8f06df8005 100644 --- a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs +++ b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-13018.rs b/tests/codegen/issues/issue-13018.rs index a29452436d2c1..8040018b93106 100644 --- a/tests/codegen/issues/issue-13018.rs +++ b/tests/codegen/issues/issue-13018.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // A drop([...].clone()) sequence on an Rc should be a no-op // In particular, no call to __rust_dealloc should be emitted diff --git a/tests/codegen/issues/issue-27130.rs b/tests/codegen/issues/issue-27130.rs index 9c22b41e97fe3..594e02af0977f 100644 --- a/tests/codegen/issues/issue-27130.rs +++ b/tests/codegen/issues/issue-27130.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-34634.rs b/tests/codegen/issues/issue-34634.rs index a11f248e7404c..d32fa97ec38ce 100644 --- a/tests/codegen/issues/issue-34634.rs +++ b/tests/codegen/issues/issue-34634.rs @@ -3,7 +3,7 @@ // switch case (the second check present until rustc 1.12). // This test also verifies that a single panic call is generated (for the division by zero case). -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @f diff --git a/tests/codegen/issues/issue-34947-pow-i32.rs b/tests/codegen/issues/issue-34947-pow-i32.rs index c9141c0e92521..b4750cd35bc34 100644 --- a/tests/codegen/issues/issue-34947-pow-i32.rs +++ b/tests/codegen/issues/issue-34947-pow-i32.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-36010-some-box-is_some.rs b/tests/codegen/issues/issue-36010-some-box-is_some.rs index 44c01096f15ae..c9a8262162d65 100644 --- a/tests/codegen/issues/issue-36010-some-box-is_some.rs +++ b/tests/codegen/issues/issue-36010-some-box-is_some.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 use std::mem; diff --git a/tests/codegen/issues/issue-37945.rs b/tests/codegen/issues/issue-37945.rs index 01d1c694ec7c6..23d0eab8ae466 100644 --- a/tests/codegen/issues/issue-37945.rs +++ b/tests/codegen/issues/issue-37945.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled //@ ignore-32bit LLVM has a bug with them // Check that LLVM understands that `Iter` pointer is not null. Issue #37945. diff --git a/tests/codegen/issues/issue-45222.rs b/tests/codegen/issues/issue-45222.rs index d2c1ba421c45e..0201363c41aa6 100644 --- a/tests/codegen/issues/issue-45222.rs +++ b/tests/codegen/issues/issue-45222.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-45466.rs b/tests/codegen/issues/issue-45466.rs index 8a324fa555bb9..164a27ef5d4c4 100644 --- a/tests/codegen/issues/issue-45466.rs +++ b/tests/codegen/issues/issue-45466.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "rlib"] diff --git a/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs b/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs index ea9288564e9d4..a48bb2a1ccf87 100644 --- a/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs +++ b/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs @@ -1,7 +1,7 @@ // This test case checks that slice::{r}position functions do not // prevent optimizing away bounds checks -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "rlib"] diff --git a/tests/codegen/issues/issue-59352.rs b/tests/codegen/issues/issue-59352.rs index 7bedc3ffc4a1c..cb4383d4a309d 100644 --- a/tests/codegen/issues/issue-59352.rs +++ b/tests/codegen/issues/issue-59352.rs @@ -6,7 +6,7 @@ // test case should be removed as it will become redundant. // mir-opt-level=3 enables inlining and enables LLVM to optimize away the unreachable panic call. -//@ compile-flags: -O -Z mir-opt-level=3 +//@ compile-flags: -Copt-level=3 -Z mir-opt-level=3 #![crate_type = "rlib"] diff --git a/tests/codegen/issues/issue-68667-unwrap-combinators.rs b/tests/codegen/issues/issue-68667-unwrap-combinators.rs index 21a5a5bf4ee94..7f4a32109fe9f 100644 --- a/tests/codegen/issues/issue-68667-unwrap-combinators.rs +++ b/tests/codegen/issues/issue-68667-unwrap-combinators.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // MIR inlining now optimizes this code. diff --git a/tests/codegen/issues/issue-69101-bounds-check.rs b/tests/codegen/issues/issue-69101-bounds-check.rs index c014a1c1b1d43..953b79aa263e8 100644 --- a/tests/codegen/issues/issue-69101-bounds-check.rs +++ b/tests/codegen/issues/issue-69101-bounds-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Make sure no bounds checks are emitted in the loop when upfront slicing diff --git a/tests/codegen/issues/issue-73031.rs b/tests/codegen/issues/issue-73031.rs index db9c6d6db2336..80dea9b5bc2b5 100644 --- a/tests/codegen/issues/issue-73031.rs +++ b/tests/codegen/issues/issue-73031.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Test that LLVM can eliminate the unreachable `All::None` branch. diff --git a/tests/codegen/issues/issue-73258.rs b/tests/codegen/issues/issue-73258.rs index e5c622b5656b7..936a75544966b 100644 --- a/tests/codegen/issues/issue-73258.rs +++ b/tests/codegen/issues/issue-73258.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs index 9b3b1318ced12..1e2c25babe0a5 100644 --- a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs +++ b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Make sure no bounds checks are emitted when slicing or indexing diff --git a/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs b/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs index c3eb1a5968af4..e9dd0d1bf2378 100644 --- a/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs +++ b/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs @@ -1,7 +1,7 @@ // This test checks that bounds checks are elided when // index is part of a (x | y) < C style condition -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-74938-array-split-at.rs b/tests/codegen/issues/issue-74938-array-split-at.rs index 2675e404ced3b..9d3e23d642b8a 100644 --- a/tests/codegen/issues/issue-74938-array-split-at.rs +++ b/tests/codegen/issues/issue-74938-array-split-at.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-75525-bounds-checks.rs b/tests/codegen/issues/issue-75525-bounds-checks.rs index fbc10ce3d843e..5dfbd35001010 100644 --- a/tests/codegen/issues/issue-75525-bounds-checks.rs +++ b/tests/codegen/issues/issue-75525-bounds-checks.rs @@ -1,6 +1,6 @@ // Regression test for #75525, verifies that no bounds checks are generated. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-75546.rs b/tests/codegen/issues/issue-75546.rs index 1132c8ab5093e..1e1e6543a889c 100644 --- a/tests/codegen/issues/issue-75546.rs +++ b/tests/codegen/issues/issue-75546.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Test that LLVM can eliminate the impossible `i == 0` check. diff --git a/tests/codegen/issues/issue-75659.rs b/tests/codegen/issues/issue-75659.rs index 1860b73f2a9ad..0960bfdb6b0aa 100644 --- a/tests/codegen/issues/issue-75659.rs +++ b/tests/codegen/issues/issue-75659.rs @@ -1,7 +1,7 @@ // This test checks that the call to memchr/slice_contains is optimized away // when searching in small slices. -//@ compile-flags: -O -Zinline-mir=false +//@ compile-flags: -Copt-level=3 -Zinline-mir=false //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-75978.rs b/tests/codegen/issues/issue-75978.rs index ed953fae76715..f4b0bc36329eb 100644 --- a/tests/codegen/issues/issue-75978.rs +++ b/tests/codegen/issues/issue-75978.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-77812.rs b/tests/codegen/issues/issue-77812.rs index bf84ac21b16d8..09e2376c30dda 100644 --- a/tests/codegen/issues/issue-77812.rs +++ b/tests/codegen/issues/issue-77812.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Test that LLVM can eliminate the unreachable `Variant::Zero` branch. diff --git a/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs b/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs index 49301be776fdb..4023412f23cff 100644 --- a/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs +++ b/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C lto=thin -C prefer-dynamic=no +//@ compile-flags: -Copt-level=3 -C lto=thin -C prefer-dynamic=no //@ only-windows //@ aux-build:static_dllimport_aux.rs diff --git a/tests/codegen/issues/issue-84268.rs b/tests/codegen/issues/issue-84268.rs index 5e852133ed3d8..8a8ea9d1ccf8f 100644 --- a/tests/codegen/issues/issue-84268.rs +++ b/tests/codegen/issues/issue-84268.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --crate-type=rlib +//@ compile-flags: -Copt-level=3 --crate-type=rlib #![feature(intrinsics, repr_simd)] extern "rust-intrinsic" { diff --git a/tests/codegen/issues/issue-85872-multiple-reverse.rs b/tests/codegen/issues/issue-85872-multiple-reverse.rs index fb5ff8309e5c5..6f566ddee6b02 100644 --- a/tests/codegen/issues/issue-85872-multiple-reverse.rs +++ b/tests/codegen/issues/issue-85872-multiple-reverse.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs b/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs index a8fab61b13e92..345c09738b610 100644 --- a/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs +++ b/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //! Test for https://github.com/rust-lang/rust/issues/86109 //! Check LLVM can eliminate the impossible division by zero check by //! ensuring there is no call (to panic) instruction. diff --git a/tests/codegen/issues/issue-93036-assert-index.rs b/tests/codegen/issues/issue-93036-assert-index.rs index 7a2ea08726688..46f45c2f06ee7 100644 --- a/tests/codegen/issues/issue-93036-assert-index.rs +++ b/tests/codegen/issues/issue-93036-assert-index.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-96274.rs b/tests/codegen/issues/issue-96274.rs index ffefd5f43f8ca..2425ec53e4e19 100644 --- a/tests/codegen/issues/issue-96274.rs +++ b/tests/codegen/issues/issue-96274.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs index f922462cc2790..dce156dd42541 100644 --- a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs +++ b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs @@ -2,7 +2,7 @@ // The possibility of wrapping results in an additional branch when dropping boxed slices // in some situations, see https://github.com/rust-lang/rust/issues/96497#issuecomment-1112865218 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs b/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs index 28324bfa90ef3..aecb81caf22b1 100644 --- a/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs +++ b/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs @@ -1,6 +1,6 @@ // This test checks that temporaries for indirectly-passed arguments get lifetime markers. -//@ compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs index 40827e32a0124..76adcf9fd4530 100644 --- a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs +++ b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-99960.rs b/tests/codegen/issues/issue-99960.rs index 9029121d35f49..571a9be967d49 100644 --- a/tests/codegen/issues/issue-99960.rs +++ b/tests/codegen/issues/issue-99960.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/layout-size-checks.rs b/tests/codegen/layout-size-checks.rs index 901f8f822f320..d64a7055e0b1e 100644 --- a/tests/codegen/layout-size-checks.rs +++ b/tests/codegen/layout-size-checks.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/lib-optimizations/iter-sum.rs b/tests/codegen/lib-optimizations/iter-sum.rs index ea8c916bfc1b2..a054ffffe74bd 100644 --- a/tests/codegen/lib-optimizations/iter-sum.rs +++ b/tests/codegen/lib-optimizations/iter-sum.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 (vectorization varies between architectures) #![crate_type = "lib"] diff --git a/tests/codegen/lib-optimizations/slice_rotate.rs b/tests/codegen/lib-optimizations/slice_rotate.rs index d0a7b328d1845..aa4bb3b528c96 100644 --- a/tests/codegen/lib-optimizations/slice_rotate.rs +++ b/tests/codegen/lib-optimizations/slice_rotate.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/lifetime_start_end.rs b/tests/codegen/lifetime_start_end.rs index 99d37c25dcac7..0639e7640aa15 100644 --- a/tests/codegen/lifetime_start_end.rs +++ b/tests/codegen/lifetime_start_end.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index e3e2f7577706b..88d67642b7250 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -O +//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs index b147d01b38e32..b11bd657c18ec 100644 --- a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu //@ needs-llvm-components: loongarch #![feature(no_core, lang_items)] diff --git a/tests/codegen/lto-removes-invokes.rs b/tests/codegen/lto-removes-invokes.rs index 3217c239bf789..3640bd1ab8652 100644 --- a/tests/codegen/lto-removes-invokes.rs +++ b/tests/codegen/lto-removes-invokes.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C lto -C panic=abort -O +//@ compile-flags: -C lto -C panic=abort -Copt-level=3 //@ no-prefer-dynamic fn main() { diff --git a/tests/codegen/macos/i686-macosx-deployment-target.rs b/tests/codegen/macos/i686-macosx-deployment-target.rs index 389434da1f67d..1f44bdfc6485e 100644 --- a/tests/codegen/macos/i686-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. // See issue #60235. -//@ compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=i686-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] diff --git a/tests/codegen/macos/i686-no-macosx-deployment-target.rs b/tests/codegen/macos/i686-no-macosx-deployment-target.rs index 4c6b7656e5937..a09773e0b9e26 100644 --- a/tests/codegen/macos/i686-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-no-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset. // See issue #60235. -//@ compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=i686-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ unset-rustc-env:MACOSX_DEPLOYMENT_TARGET #![feature(no_core, lang_items)] diff --git a/tests/codegen/macos/x86_64-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-macosx-deployment-target.rs index a40deca24bbeb..bd8c027a9fb9d 100644 --- a/tests/codegen/macos/x86_64-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. // See issue #60235. -//@ compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=x86_64-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] diff --git a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs index 26d519ef1a6dc..ff4a8fc46f984 100644 --- a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset. // See issue #60235. -//@ compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=x86_64-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ unset-rustc-env:MACOSX_DEPLOYMENT_TARGET #![feature(no_core, lang_items)] diff --git a/tests/codegen/match-optimized.rs b/tests/codegen/match-optimized.rs index d6893be0b7bef..7b409e619a8c5 100644 --- a/tests/codegen/match-optimized.rs +++ b/tests/codegen/match-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes -O +//@ compile-flags: -Cno-prepopulate-passes -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/match-optimizes-away.rs b/tests/codegen/match-optimizes-away.rs index 82ab5718b3750..8a70d99342316 100644 --- a/tests/codegen/match-optimizes-away.rs +++ b/tests/codegen/match-optimizes-away.rs @@ -1,5 +1,5 @@ // -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] pub enum Three { diff --git a/tests/codegen/maybeuninit-rvo.rs b/tests/codegen/maybeuninit-rvo.rs index db2e33c34bd25..097aa610f1b34 100644 --- a/tests/codegen/maybeuninit-rvo.rs +++ b/tests/codegen/maybeuninit-rvo.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ needs-unwind #![feature(c_unwind)] #![crate_type = "lib"] diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs index 41c3660dc15c0..9f3c6bacb712c 100644 --- a/tests/codegen/mem-replace-simple-type.rs +++ b/tests/codegen/mem-replace-simple-type.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-x86_64 (to not worry about usize differing) //@ ignore-std-debug-assertions // Reason: precondition checks make mem::replace not a candidate for MIR inlining diff --git a/tests/codegen/merge-functions.rs b/tests/codegen/merge-functions.rs index 8e4b65c9ee65c..b9d3727ce112e 100644 --- a/tests/codegen/merge-functions.rs +++ b/tests/codegen/merge-functions.rs @@ -1,6 +1,6 @@ //@ revisions: O Os //@[Os] compile-flags: -Copt-level=s -//@[O] compile-flags: -O +//@[O] compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK: @func{{2|1}} = {{.*}}alias{{.*}}@func{{1|2}} diff --git a/tests/codegen/mir-aggregate-no-alloca.rs b/tests/codegen/mir-aggregate-no-alloca.rs index 37b024a55b373..77d367ed5da9e 100644 --- a/tests/codegen/mir-aggregate-no-alloca.rs +++ b/tests/codegen/mir-aggregate-no-alloca.rs @@ -2,7 +2,7 @@ //@ revisions: bit32 bit64 //@[bit32] only-32bit //@[bit64] only-64bit -//@ compile-flags: -O -C no-prepopulate-passes -Z randomize-layout=no +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z randomize-layout=no #![crate_type = "lib"] diff --git a/tests/codegen/mir-inlined-line-numbers.rs b/tests/codegen/mir-inlined-line-numbers.rs index 57978bc709765..cfe43a6cf89ac 100644 --- a/tests/codegen/mir-inlined-line-numbers.rs +++ b/tests/codegen/mir-inlined-line-numbers.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -g +//@ compile-flags: -Copt-level=3 -g #![crate_type = "lib"] diff --git a/tests/codegen/move-before-nocapture-ref-arg.rs b/tests/codegen/move-before-nocapture-ref-arg.rs index c3448192ea173..2ebd645e1c3d0 100644 --- a/tests/codegen/move-before-nocapture-ref-arg.rs +++ b/tests/codegen/move-before-nocapture-ref-arg.rs @@ -1,6 +1,6 @@ // Verify that move before the call of the function with noalias, nocapture, readonly. // #107436 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/move-operands.rs b/tests/codegen/move-operands.rs index 4f22921b4a3dc..ddad231b762cd 100644 --- a/tests/codegen/move-operands.rs +++ b/tests/codegen/move-operands.rs @@ -1,5 +1,5 @@ // Verify that optimized MIR only copies `a` once. -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/naked-fn/generics.rs b/tests/codegen/naked-fn/generics.rs index a33d213617a8b..64998df64ddb6 100644 --- a/tests/codegen/naked-fn/generics.rs +++ b/tests/codegen/naked-fn/generics.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/noalias-box-off.rs b/tests/codegen/noalias-box-off.rs index 1642103903a0b..664c79502804e 100644 --- a/tests/codegen/noalias-box-off.rs +++ b/tests/codegen/noalias-box-off.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z box-noalias=no +//@ compile-flags: -Copt-level=3 -Z box-noalias=no #![crate_type = "lib"] diff --git a/tests/codegen/noalias-box.rs b/tests/codegen/noalias-box.rs index 06f94691c8956..cccde775977a1 100644 --- a/tests/codegen/noalias-box.rs +++ b/tests/codegen/noalias-box.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/noalias-flag.rs b/tests/codegen/noalias-flag.rs index 35b94d813d5fb..67ba68ee6f80a 100644 --- a/tests/codegen/noalias-flag.rs +++ b/tests/codegen/noalias-flag.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmutable-noalias=no +//@ compile-flags: -Copt-level=3 -Zmutable-noalias=no #![crate_type = "lib"] diff --git a/tests/codegen/noalias-refcell.rs b/tests/codegen/noalias-refcell.rs index 51d13967bece6..b37adf92b9cc3 100644 --- a/tests/codegen/noalias-refcell.rs +++ b/tests/codegen/noalias-refcell.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z mutable-noalias=yes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mutable-noalias=yes #![crate_type = "lib"] diff --git a/tests/codegen/noalias-rwlockreadguard.rs b/tests/codegen/noalias-rwlockreadguard.rs index 7b870cb28b4fc..c676dc32399da 100644 --- a/tests/codegen/noalias-rwlockreadguard.rs +++ b/tests/codegen/noalias-rwlockreadguard.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z mutable-noalias=yes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mutable-noalias=yes #![crate_type = "lib"] diff --git a/tests/codegen/noalias-unpin.rs b/tests/codegen/noalias-unpin.rs index 630a62020c11d..30a8b399b9798 100644 --- a/tests/codegen/noalias-unpin.rs +++ b/tests/codegen/noalias-unpin.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z mutable-noalias=yes +//@ compile-flags: -Copt-level=3 -Z mutable-noalias=yes #![crate_type = "lib"] diff --git a/tests/codegen/nrvo.rs b/tests/codegen/nrvo.rs index aa8bed941f545..7972186bfe5d1 100644 --- a/tests/codegen/nrvo.rs +++ b/tests/codegen/nrvo.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/option-as-slice.rs b/tests/codegen/option-as-slice.rs index 0edbbac11762d..39b34a2035b74 100644 --- a/tests/codegen/option-as-slice.rs +++ b/tests/codegen/option-as-slice.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z randomize-layout=no +//@ compile-flags: -Copt-level=3 -Z randomize-layout=no //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/option-niche-eq.rs b/tests/codegen/option-niche-eq.rs index caef0598b4bed..9c5ed9ce57a5e 100644 --- a/tests/codegen/option-niche-eq.rs +++ b/tests/codegen/option-niche-eq.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] extern crate core; diff --git a/tests/codegen/packed.rs b/tests/codegen/packed.rs index 66df978d48ca2..6f62719282eac 100644 --- a/tests/codegen/packed.rs +++ b/tests/codegen/packed.rs @@ -1,5 +1,5 @@ // -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/panic-abort-windows.rs b/tests/codegen/panic-abort-windows.rs index eb61e649f04a2..17fdd9cc72609 100644 --- a/tests/codegen/panic-abort-windows.rs +++ b/tests/codegen/panic-abort-windows.rs @@ -1,7 +1,7 @@ // This test is for *-windows only. //@ only-windows -//@ compile-flags: -C no-prepopulate-passes -C panic=abort -O +//@ compile-flags: -C no-prepopulate-passes -C panic=abort -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/panic-in-drop-abort.rs b/tests/codegen/panic-in-drop-abort.rs index b150c537ad550..e89170e56ed08 100644 --- a/tests/codegen/panic-in-drop-abort.rs +++ b/tests/codegen/panic-in-drop-abort.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z panic-in-drop=abort -O +//@ compile-flags: -Z panic-in-drop=abort -Copt-level=3 //@ ignore-msvc // Ensure that unwinding code paths are eliminated from the output after diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs index 828af05436b42..cd81db6395349 100644 --- a/tests/codegen/personality_lifetimes.rs +++ b/tests/codegen/personality_lifetimes.rs @@ -1,7 +1,7 @@ //@ ignore-msvc //@ needs-unwind -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/placement-new.rs b/tests/codegen/placement-new.rs index 0ec2b6a6f20e7..7f7f0033bece3 100644 --- a/tests/codegen/placement-new.rs +++ b/tests/codegen/placement-new.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ compile-flags: -Zmerge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/ptr-arithmetic.rs b/tests/codegen/ptr-arithmetic.rs index 6f115d33d8ddf..ecb44b30f5cad 100644 --- a/tests/codegen/ptr-arithmetic.rs +++ b/tests/codegen/ptr-arithmetic.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/ptr-read-metadata.rs b/tests/codegen/ptr-read-metadata.rs index e3565c962f738..b38cfdbff8835 100644 --- a/tests/codegen/ptr-read-metadata.rs +++ b/tests/codegen/ptr-read-metadata.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/range-attribute.rs b/tests/codegen/range-attribute.rs index a44ec1026b164..e23f5e6bb748a 100644 --- a/tests/codegen/range-attribute.rs +++ b/tests/codegen/range-attribute.rs @@ -5,7 +5,7 @@ //@ revisions: bit32 bit64 //@[bit32] only-32bit //@[bit64] only-64bit -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/range_to_inclusive.rs b/tests/codegen/range_to_inclusive.rs index f3001897f88d9..6d939f40f5582 100644 --- a/tests/codegen/range_to_inclusive.rs +++ b/tests/codegen/range_to_inclusive.rs @@ -1,6 +1,6 @@ //! Test that `RangeTo` and `RangeToInclusive` generate identical //! (and optimal) code; #63646 -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/reg-struct-return.rs b/tests/codegen/reg-struct-return.rs index 73816745ea86d..dfc9f8c519c2a 100644 --- a/tests/codegen/reg-struct-return.rs +++ b/tests/codegen/reg-struct-return.rs @@ -5,7 +5,7 @@ //@ revisions: ENABLED DISABLED //@ add-core-stubs -//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ [ENABLED] compile-flags: -Zreg-struct-return //@ needs-llvm-components: x86 diff --git a/tests/codegen/regparm-inreg.rs b/tests/codegen/regparm-inreg.rs index c8c647bcc87c0..82e157311287a 100644 --- a/tests/codegen/regparm-inreg.rs +++ b/tests/codegen/regparm-inreg.rs @@ -2,7 +2,7 @@ // marks function arguments as "inreg" like the C/C++ compilers for the platforms. // x86 only. -//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ needs-llvm-components: x86 //@ revisions:regparm0 regparm1 regparm2 regparm3 diff --git a/tests/codegen/repeat-trusted-len.rs b/tests/codegen/repeat-trusted-len.rs index fa01f2b4969d6..95379535971f2 100644 --- a/tests/codegen/repeat-trusted-len.rs +++ b/tests/codegen/repeat-trusted-len.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // #![crate_type = "lib"] diff --git a/tests/codegen/repr/transparent-byval-struct-ptr.rs b/tests/codegen/repr/transparent-byval-struct-ptr.rs index 92ef937d734b4..f9cfeb90390c9 100644 --- a/tests/codegen/repr/transparent-byval-struct-ptr.rs +++ b/tests/codegen/repr/transparent-byval-struct-ptr.rs @@ -1,5 +1,5 @@ //@ revisions: i686-linux i686-freebsd x64-linux x64-apple -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[i686-linux] compile-flags: --target i686-unknown-linux-gnu //@[i686-linux] needs-llvm-components: x86 diff --git a/tests/codegen/repr/transparent-imm-array.rs b/tests/codegen/repr/transparent-imm-array.rs index 99828e4e80a5f..f790d093cf4a8 100644 --- a/tests/codegen/repr/transparent-imm-array.rs +++ b/tests/codegen/repr/transparent-imm-array.rs @@ -1,5 +1,5 @@ //@ revisions: arm-linux arm-android armv7-linux armv7-android mips thumb sparc -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[arm-linux] compile-flags: --target arm-unknown-linux-gnueabi //@[arm-linux] needs-llvm-components: arm diff --git a/tests/codegen/repr/transparent-mips64.rs b/tests/codegen/repr/transparent-mips64.rs index 588d440b4d7bf..7282654b8562d 100644 --- a/tests/codegen/repr/transparent-mips64.rs +++ b/tests/codegen/repr/transparent-mips64.rs @@ -1,5 +1,5 @@ //@ revisions: mips64 mips64el -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 //@[mips64] needs-llvm-components: mips diff --git a/tests/codegen/repr/transparent-opaque-ptr.rs b/tests/codegen/repr/transparent-opaque-ptr.rs index 29c03f0d5d96f..798b7e01bba5b 100644 --- a/tests/codegen/repr/transparent-opaque-ptr.rs +++ b/tests/codegen/repr/transparent-opaque-ptr.rs @@ -1,5 +1,5 @@ //@ revisions: aarch64-linux aarch64-darwin wasm32-wasip1 -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[aarch64-linux] compile-flags: --target aarch64-unknown-linux-gnu //@[aarch64-linux] needs-llvm-components: aarch64 diff --git a/tests/codegen/repr/transparent-sparc64.rs b/tests/codegen/repr/transparent-sparc64.rs index 8e4c8ce2ee9b1..05c090bd67215 100644 --- a/tests/codegen/repr/transparent-sparc64.rs +++ b/tests/codegen/repr/transparent-sparc64.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target sparc64-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target sparc64-unknown-linux-gnu //@ needs-llvm-components: sparc // See ./transparent.rs diff --git a/tests/codegen/repr/transparent-sysv64.rs b/tests/codegen/repr/transparent-sysv64.rs index 068414976c523..99c855db96200 100644 --- a/tests/codegen/repr/transparent-sysv64.rs +++ b/tests/codegen/repr/transparent-sysv64.rs @@ -1,5 +1,5 @@ //@ revisions: linux apple win -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[linux] compile-flags: --target x86_64-unknown-linux-gnu //@[linux] needs-llvm-components: x86 diff --git a/tests/codegen/repr/transparent.rs b/tests/codegen/repr/transparent.rs index adcd3aacd2ace..e7e4c40a09917 100644 --- a/tests/codegen/repr/transparent.rs +++ b/tests/codegen/repr/transparent.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ ignore-riscv64 riscv64 has an i128 type used with test_Vector //@ ignore-s390x s390x with default march passes vector types per reference //@ ignore-loongarch64 see codegen/loongarch-abi for loongarch function call tests diff --git a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs index 520192b5d5915..46f747ad40750 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --target riscv64gc-unknown-linux-gnu -O -C no-prepopulate-passes -C panic=abort +//@ compile-flags: --target riscv64gc-unknown-linux-gnu -Copt-level=3 -C no-prepopulate-passes -C panic=abort //@ needs-llvm-components: riscv #![crate_type = "lib"] diff --git a/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs index c14d5c01450bc..bef8fe0c04418 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu //@ needs-llvm-components: riscv #![feature(no_core, lang_items)] diff --git a/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs index 27018d2e6d203..214370f424c25 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu //@ needs-llvm-components: riscv #![feature(no_core, lang_items)] diff --git a/tests/codegen/rust-abi-arch-specific-adjustment.rs b/tests/codegen/rust-abi-arch-specific-adjustment.rs index 9da10f662b0e6..561f081c700ea 100644 --- a/tests/codegen/rust-abi-arch-specific-adjustment.rs +++ b/tests/codegen/rust-abi-arch-specific-adjustment.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ revisions: riscv64 loongarch64 //@[riscv64] only-riscv64 diff --git a/tests/codegen/s390x-simd.rs b/tests/codegen/s390x-simd.rs index 23181e6a10308..ac39357519e4c 100644 --- a/tests/codegen/s390x-simd.rs +++ b/tests/codegen/s390x-simd.rs @@ -1,7 +1,7 @@ //! test that s390x vector types are passed using `PassMode::Direct` //! see also https://github.com/rust-lang/rust/issues/135744 //@ add-core-stubs -//@ compile-flags: --target s390x-unknown-linux-gnu -O +//@ compile-flags: --target s390x-unknown-linux-gnu -Copt-level=3 //@ needs-llvm-components: systemz #![crate_type = "rlib"] diff --git a/tests/codegen/scalar-pair-bool.rs b/tests/codegen/scalar-pair-bool.rs index fce0648e45074..def3b32f71aa4 100644 --- a/tests/codegen/scalar-pair-bool.rs +++ b/tests/codegen/scalar-pair-bool.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/simd/swap-simd-types.rs b/tests/codegen/simd/swap-simd-types.rs index cd6e84286e1c9..69767d0a75580 100644 --- a/tests/codegen/simd/swap-simd-types.rs +++ b/tests/codegen/simd/swap-simd-types.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C target-feature=+avx +//@ compile-flags: -Copt-level=3 -C target-feature=+avx //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/slice-as_chunks.rs b/tests/codegen/slice-as_chunks.rs index 631d18d780951..a90ee7c628ece 100644 --- a/tests/codegen/slice-as_chunks.rs +++ b/tests/codegen/slice-as_chunks.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] diff --git a/tests/codegen/slice-indexing.rs b/tests/codegen/slice-indexing.rs index 75112bb0c24e5..d957ccfb5ef7d 100644 --- a/tests/codegen/slice-indexing.rs +++ b/tests/codegen/slice-indexing.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] diff --git a/tests/codegen/slice-iter-fold.rs b/tests/codegen/slice-iter-fold.rs index 1770cd4a11994..55ab34661c36e 100644 --- a/tests/codegen/slice-iter-fold.rs +++ b/tests/codegen/slice-iter-fold.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @slice_fold_to_last diff --git a/tests/codegen/slice-iter-len-eq-zero.rs b/tests/codegen/slice-iter-len-eq-zero.rs index b2a4b2495b6a2..c85861d47f852 100644 --- a/tests/codegen/slice-iter-len-eq-zero.rs +++ b/tests/codegen/slice-iter-len-eq-zero.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] type Demo = [u8; 3]; diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs index 307020b42c06f..98a1b961a6443 100644 --- a/tests/codegen/slice-iter-nonnull.rs +++ b/tests/codegen/slice-iter-nonnull.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ needs-deterministic-layouts #![crate_type = "lib"] #![feature(exact_size_is_empty)] diff --git a/tests/codegen/slice-pointer-nonnull-unwrap.rs b/tests/codegen/slice-pointer-nonnull-unwrap.rs index 202edb98c7329..35e4bf2c6615f 100644 --- a/tests/codegen/slice-pointer-nonnull-unwrap.rs +++ b/tests/codegen/slice-pointer-nonnull-unwrap.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] use std::ptr::NonNull; diff --git a/tests/codegen/slice-position-bounds-check.rs b/tests/codegen/slice-position-bounds-check.rs index f83e2f2ec440e..0d1d1d869ae25 100644 --- a/tests/codegen/slice-position-bounds-check.rs +++ b/tests/codegen/slice-position-bounds-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C panic=abort +//@ compile-flags: -Copt-level=3 -C panic=abort #![crate_type = "lib"] fn search(arr: &mut [T], a: &T) -> Result { diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 1153d7817b278..a5046a7594458 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] use std::num::NonZero; diff --git a/tests/codegen/slice-reverse.rs b/tests/codegen/slice-reverse.rs index 87cdad479628a..e58d1c1d9d8ea 100644 --- a/tests/codegen/slice-reverse.rs +++ b/tests/codegen/slice-reverse.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 //@ ignore-std-debug-assertions (debug assertions prevent generating shufflevector) diff --git a/tests/codegen/slice-windows-no-bounds-check.rs b/tests/codegen/slice-windows-no-bounds-check.rs index db3211c8defdb..87e89b14f06c8 100644 --- a/tests/codegen/slice-windows-no-bounds-check.rs +++ b/tests/codegen/slice-windows-no-bounds-check.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 use std::slice::Windows; diff --git a/tests/codegen/slice_as_from_ptr_range.rs b/tests/codegen/slice_as_from_ptr_range.rs index 47c60461c0e81..2073f05c07f0c 100644 --- a/tests/codegen/slice_as_from_ptr_range.rs +++ b/tests/codegen/slice_as_from_ptr_range.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit (because we're using [ui]size) #![crate_type = "lib"] diff --git a/tests/codegen/some-global-nonnull.rs b/tests/codegen/some-global-nonnull.rs index 8e9308a726582..bb4d12e1c7621 100644 --- a/tests/codegen/some-global-nonnull.rs +++ b/tests/codegen/some-global-nonnull.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/sparc-struct-abi.rs b/tests/codegen/sparc-struct-abi.rs index 5d9781663570a..0a8720c4fcae3 100644 --- a/tests/codegen/sparc-struct-abi.rs +++ b/tests/codegen/sparc-struct-abi.rs @@ -1,7 +1,7 @@ // Checks that we correctly codegen extern "C" functions returning structs. // See issues #52638 and #86163. -//@ compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=sparc64-unknown-linux-gnu --crate-type=rlib //@ needs-llvm-components: sparc #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/codegen/static-relocation-model-msvc.rs b/tests/codegen/static-relocation-model-msvc.rs index 8ed8331466c73..4d30e6ec505d4 100644 --- a/tests/codegen/static-relocation-model-msvc.rs +++ b/tests/codegen/static-relocation-model-msvc.rs @@ -1,6 +1,6 @@ // Verify linkage of external symbols in the static relocation model on MSVC. // -//@ compile-flags: -O -C relocation-model=static +//@ compile-flags: -Copt-level=3 -C relocation-model=static //@ aux-build: extern_decl.rs //@ only-x86_64-pc-windows-msvc diff --git a/tests/codegen/step_by-overflow-checks.rs b/tests/codegen/step_by-overflow-checks.rs index 43e8514a8b7c2..53800e9f879d9 100644 --- a/tests/codegen/step_by-overflow-checks.rs +++ b/tests/codegen/step_by-overflow-checks.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/swap-large-types.rs b/tests/codegen/swap-large-types.rs index 761d48969dad9..49a41bb14692f 100644 --- a/tests/codegen/swap-large-types.rs +++ b/tests/codegen/swap-large-types.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/swap-small-types.rs b/tests/codegen/swap-small-types.rs index 1a48c63d8139f..76bb853e64238 100644 --- a/tests/codegen/swap-small-types.rs +++ b/tests/codegen/swap-small-types.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/thread-local.rs b/tests/codegen/thread-local.rs index 3cd81652f5ace..9ce34473b9150 100644 --- a/tests/codegen/thread-local.rs +++ b/tests/codegen/thread-local.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ aux-build:thread_local_aux.rs //@ ignore-windows FIXME(#134939) //@ ignore-wasm globals are used instead of thread locals diff --git a/tests/codegen/to_vec.rs b/tests/codegen/to_vec.rs index 4666f8d6f1532..4f6e77188d81b 100644 --- a/tests/codegen/to_vec.rs +++ b/tests/codegen/to_vec.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/trailing_zeros.rs b/tests/codegen/trailing_zeros.rs index b659e061821ea..0816a98099269 100644 --- a/tests/codegen/trailing_zeros.rs +++ b/tests/codegen/trailing_zeros.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs index de54eecf0c049..477fdc6de90d4 100644 --- a/tests/codegen/transmute-optimized.rs +++ b/tests/codegen/transmute-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index 36a0d9066c895..751d7ca931160 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled --edition=2021 +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled --edition=2021 //@ only-x86_64 // FIXME: Remove the `min-llvm-version`. //@ revisions: NINETEEN TWENTY diff --git a/tests/codegen/ub-checks.rs b/tests/codegen/ub-checks.rs index de48d74e652f1..67f5bff08d5bb 100644 --- a/tests/codegen/ub-checks.rs +++ b/tests/codegen/ub-checks.rs @@ -8,7 +8,7 @@ //@ revisions: DEBUG NOCHECKS //@ [DEBUG] compile-flags: //@ [NOCHECKS] compile-flags: -Zub-checks=no -//@ compile-flags: -O -Cdebug-assertions=yes +//@ compile-flags: -Copt-level=3 -Cdebug-assertions=yes #![crate_type = "lib"] diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs index 86517c896276d..b27eb73c0cc94 100644 --- a/tests/codegen/unchecked_shifts.rs +++ b/tests/codegen/unchecked_shifts.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(unchecked_shifts)] diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs index 2f14682dfa57c..92d40d8ac14cb 100644 --- a/tests/codegen/union-abi.rs +++ b/tests/codegen/union-abi.rs @@ -1,5 +1,5 @@ //@ ignore-emscripten vectors passed directly -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes // 32-bit x86 returns `f32` differently to avoid the x87 stack. // 32-bit systems will return 128bit values using a return area pointer. //@ revisions: x86 bit32 bit64 diff --git a/tests/codegen/var-names.rs b/tests/codegen/var-names.rs index 4ea5b3b436d81..40720e197614e 100644 --- a/tests/codegen/var-names.rs +++ b/tests/codegen/var-names.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/vec-as-ptr.rs b/tests/codegen/vec-as-ptr.rs index 17869c21c8321..5c997802640d2 100644 --- a/tests/codegen/vec-as-ptr.rs +++ b/tests/codegen/vec-as-ptr.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/vec-calloc.rs b/tests/codegen/vec-calloc.rs index f88ed7ae8a555..2e2769ce1301a 100644 --- a/tests/codegen/vec-calloc.rs +++ b/tests/codegen/vec-calloc.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/vec-in-place.rs b/tests/codegen/vec-in-place.rs index e835a7ef69bd8..1f6836f6dfabb 100644 --- a/tests/codegen/vec-in-place.rs +++ b/tests/codegen/vec-in-place.rs @@ -1,5 +1,5 @@ //@ ignore-std-debug-assertions (FIXME: checks for call detect scoped noalias metadata) -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] // Ensure that trivial casts of vec elements are O(1) diff --git a/tests/codegen/vec-iter-collect-len.rs b/tests/codegen/vec-iter-collect-len.rs index 8c5d2f6f9a74f..a88573522d4d8 100644 --- a/tests/codegen/vec-iter-collect-len.rs +++ b/tests/codegen/vec-iter-collect-len.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/vec-iter.rs b/tests/codegen/vec-iter.rs index 310680969c4fe..4ed00d2d34f0b 100644 --- a/tests/codegen/vec-iter.rs +++ b/tests/codegen/vec-iter.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(exact_size_is_empty)] diff --git a/tests/codegen/vec-len-invariant.rs b/tests/codegen/vec-len-invariant.rs index 780c86bab9569..033181c2bfb72 100644 --- a/tests/codegen/vec-len-invariant.rs +++ b/tests/codegen/vec-len-invariant.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit // // This test confirms that we do not reload the length of a Vec after growing it in push. diff --git a/tests/codegen/vec-optimizes-away.rs b/tests/codegen/vec-optimizes-away.rs index 77a94b0b4294a..39d5c1614c82a 100644 --- a/tests/codegen/vec-optimizes-away.rs +++ b/tests/codegen/vec-optimizes-away.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/vec-reserve-extend.rs b/tests/codegen/vec-reserve-extend.rs index 1f00f7d206339..4d3f23ccecfc8 100644 --- a/tests/codegen/vec-reserve-extend.rs +++ b/tests/codegen/vec-reserve-extend.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/vec-shrink-panik.rs b/tests/codegen/vec-shrink-panik.rs index 873904c2569e4..23dd300d48cd6 100644 --- a/tests/codegen/vec-shrink-panik.rs +++ b/tests/codegen/vec-shrink-panik.rs @@ -1,6 +1,6 @@ // LLVM 17 realizes double panic is not possible and doesn't generate calls // to panic_cannot_unwind. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions (plain old debug assertions) //@ needs-unwind #![crate_type = "lib"] diff --git a/tests/codegen/vec-with-capacity.rs b/tests/codegen/vec-with-capacity.rs index e8c5bc88bd0db..777bbcc4fcb47 100644 --- a/tests/codegen/vec-with-capacity.rs +++ b/tests/codegen/vec-with-capacity.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions // (with debug assertions turned on, `assert_unchecked` generates a real assertion) diff --git a/tests/codegen/vec_pop_push_noop.rs b/tests/codegen/vec_pop_push_noop.rs index 4821e84088408..2635660596ab1 100644 --- a/tests/codegen/vec_pop_push_noop.rs +++ b/tests/codegen/vec_pop_push_noop.rs @@ -1,7 +1,7 @@ //@ revisions: llvm-pre-19 llvm-19 //@ [llvm-19] min-llvm-version: 19 //@ [llvm-pre-19] max-llvm-major-version: 18 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/vecdeque-drain.rs b/tests/codegen/vecdeque-drain.rs index 8a34ba0674b1b..a5e5da6501332 100644 --- a/tests/codegen/vecdeque-drain.rs +++ b/tests/codegen/vecdeque-drain.rs @@ -1,6 +1,6 @@ // Check that draining at the front or back doesn't copy memory. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ needs-deterministic-layouts //@ ignore-std-debug-assertions (FIXME: checks for call detect scoped noalias metadata) diff --git a/tests/codegen/vecdeque-nonempty-get-no-panic.rs b/tests/codegen/vecdeque-nonempty-get-no-panic.rs index 3f802de9eeed7..1f886b096bbbf 100644 --- a/tests/codegen/vecdeque-nonempty-get-no-panic.rs +++ b/tests/codegen/vecdeque-nonempty-get-no-panic.rs @@ -1,6 +1,6 @@ // Guards against regression for optimization discussed in issue #80836 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/vecdeque_no_panic.rs b/tests/codegen/vecdeque_no_panic.rs index da948d12254cd..3166842afca0e 100644 --- a/tests/codegen/vecdeque_no_panic.rs +++ b/tests/codegen/vecdeque_no_panic.rs @@ -1,6 +1,6 @@ // This test checks that `VecDeque::front[_mut]()` and `VecDeque::back[_mut]()` can't panic. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions (plain old debug assertions) #![crate_type = "lib"] diff --git a/tests/codegen/vecdeque_pop_push.rs b/tests/codegen/vecdeque_pop_push.rs index 040d5a279dcab..5afa1b2248b0e 100644 --- a/tests/codegen/vecdeque_pop_push.rs +++ b/tests/codegen/vecdeque_pop_push.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/virtual-function-elimination-32bit.rs b/tests/codegen/virtual-function-elimination-32bit.rs index 76223be1f3dad..c9919cecccf9b 100644 --- a/tests/codegen/virtual-function-elimination-32bit.rs +++ b/tests/codegen/virtual-function-elimination-32bit.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0 +//@ compile-flags: -Zvirtual-function-elimination -Clto -Copt-level=3 -Csymbol-mangling-version=v0 //@ ignore-64bit // CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] diff --git a/tests/codegen/virtual-function-elimination.rs b/tests/codegen/virtual-function-elimination.rs index 23d7657baa99b..d2d0c4b78abd1 100644 --- a/tests/codegen/virtual-function-elimination.rs +++ b/tests/codegen/virtual-function-elimination.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0 +//@ compile-flags: -Zvirtual-function-elimination -Clto -Copt-level=3 -Csymbol-mangling-version=v0 //@ ignore-32bit // CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] diff --git a/tests/codegen/vtable-loads.rs b/tests/codegen/vtable-loads.rs index 1dd6ca51063b1..aa103ec6f7cb8 100644 --- a/tests/codegen/vtable-loads.rs +++ b/tests/codegen/vtable-loads.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/zip.rs b/tests/codegen/zip.rs index ea8caba61f396..38ecf7c15c675 100644 --- a/tests/codegen/zip.rs +++ b/tests/codegen/zip.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes -O +//@ compile-flags: -Cno-prepopulate-passes -Copt-level=3 #![crate_type = "lib"] From f94ada13deab495c48984a46cac56151a1e98f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Thu, 2 Jan 2025 00:33:04 +0900 Subject: [PATCH 11/15] Add cygwin target. Co-authored-by: Ookiineko Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com> Co-authored-by: Jubilee --- compiler/rustc_target/src/spec/base/cygwin.rs | 51 +++++++++++++++++++ compiler/rustc_target/src/spec/base/mod.rs | 1 + compiler/rustc_target/src/spec/mod.rs | 5 +- .../src/spec/targets/x86_64_pc_cygwin.rs | 32 ++++++++++++ src/bootstrap/src/core/builder/cargo.rs | 6 ++- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 1 + .../src/platform-support/x86_64-pc-cygwin.md | 39 ++++++++++++++ tests/assembly/targets/targets-pe.rs | 3 ++ tests/ui/check-cfg/well-known-values.stderr | 4 +- 10 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 compiler/rustc_target/src/spec/base/cygwin.rs create mode 100644 compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs create mode 100644 src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md diff --git a/compiler/rustc_target/src/spec/base/cygwin.rs b/compiler/rustc_target/src/spec/base/cygwin.rs new file mode 100644 index 0000000000000..2d29060c47a39 --- /dev/null +++ b/compiler/rustc_target/src/spec/base/cygwin.rs @@ -0,0 +1,51 @@ +use std::borrow::Cow; + +use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs}; + +pub(crate) fn opts() -> TargetOptions { + let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ + // FIXME: Disable ASLR for now to fix relocation error + "--disable-dynamicbase", + "--enable-auto-image-base", + ]); + crate::spec::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ + // Tell GCC to avoid linker plugins, because we are not bundling + // them with Windows installer, and Rust does its own LTO anyways. + "-fno-use-linker-plugin", + "-Wl,--disable-dynamicbase", + "-Wl,--enable-auto-image-base", + ]); + let cygwin_libs = &["-lcygwin", "-lgcc", "-lcygwin", "-luser32", "-lkernel32", "-lgcc_s"]; + let mut late_link_args = + TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), cygwin_libs); + crate::spec::add_link_args( + &mut late_link_args, + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + cygwin_libs, + ); + TargetOptions { + os: "cygwin".into(), + vendor: "pc".into(), + // FIXME(#13846) this should be enabled for cygwin + function_sections: false, + linker: Some("gcc".into()), + dynamic_linking: true, + dll_prefix: "".into(), + dll_suffix: ".dll".into(), + exe_suffix: ".exe".into(), + families: cvs!["unix"], + is_like_windows: true, + allows_weak_linkage: false, + pre_link_args, + late_link_args, + abi_return_struct_as_int: true, + emit_debug_gdb_scripts: false, + requires_uwtable: true, + eh_frame_header: false, + // FIXME(davidtwco): Support Split DWARF on Cygwin - may require LLVM changes to + // output DWO, despite using DWARF, doesn't use ELF.. + debuginfo_kind: DebuginfoKind::Pdb, + supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), + ..Default::default() + } +} diff --git a/compiler/rustc_target/src/spec/base/mod.rs b/compiler/rustc_target/src/spec/base/mod.rs index 28d10dcf2ff3a..b9139c8452c5f 100644 --- a/compiler/rustc_target/src/spec/base/mod.rs +++ b/compiler/rustc_target/src/spec/base/mod.rs @@ -3,6 +3,7 @@ pub(crate) mod android; pub(crate) mod apple; pub(crate) mod avr_gnu; pub(crate) mod bpf; +pub(crate) mod cygwin; pub(crate) mod dragonfly; pub(crate) mod freebsd; pub(crate) mod fuchsia; diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index df1862ec27eee..91154edbd0092 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2020,6 +2020,7 @@ supported_targets! { ("riscv64imac-unknown-nuttx-elf", riscv64imac_unknown_nuttx_elf), ("riscv64gc-unknown-nuttx-elf", riscv64gc_unknown_nuttx_elf), + ("x86_64-pc-cygwin", x86_64_pc_cygwin), } /// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]> @@ -3001,8 +3002,8 @@ impl Target { ); check_eq!( self.is_like_windows, - self.os == "windows" || self.os == "uefi", - "`is_like_windows` must be set if and only if `os` is `windows` or `uefi`" + self.os == "windows" || self.os == "uefi" || self.os == "cygwin", + "`is_like_windows` must be set if and only if `os` is `windows`, `uefi` or `cygwin`" ); check_eq!( self.is_like_wasm, diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs new file mode 100644 index 0000000000000..a5bedd07e6be8 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs @@ -0,0 +1,32 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, Target, base}; + +pub(crate) fn target() -> Target { + let mut base = base::cygwin::opts(); + base.cpu = "x86-64".into(); + // FIXME: Disable ASLR for now to fix relocation error + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ + "-m", + "i386pep", + "--disable-high-entropy-va", + ]); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ + "-m64", + "-Wl,--disable-high-entropy-va", + ]); + base.max_atomic_width = Some(64); + base.linker = Some("x86_64-pc-cygwin-gcc".into()); + Target { + llvm_target: "x86_64-pc-cygwin".into(), + pointer_width: 64, + data_layout: + "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), + arch: "x86_64".into(), + options: base, + metadata: crate::spec::TargetMetadata { + description: Some("64-bit x86 Cygwin".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(true), + }, + } +} diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 2ecab262413fa..dc1ef7ce245cf 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -245,7 +245,11 @@ impl Cargo { // flesh out rpath support more fully in the future. self.rustflags.arg("-Zosx-rpath-install-name"); Some(format!("-Wl,-rpath,@loader_path/../{libdir}")) - } else if !target.is_windows() && !target.contains("aix") && !target.contains("xous") { + } else if !target.is_windows() + && !target.contains("cygwin") + && !target.contains("aix") + && !target.contains("xous") + { self.rustflags.arg("-Clink-args=-Wl,-z,origin"); Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}")) } else { diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index f78d3d4aee830..6c7cdec348024 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -102,6 +102,7 @@ - [\*-win7-windows-gnu](platform-support/win7-windows-gnu.md) - [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md) - [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md) + - [x86_64-pc-cygwin](platform-support/x86_64-pc-cygwin.md) - [x86_64-pc-solaris](platform-support/solaris.md) - [x86_64-unknown-linux-none.md](platform-support/x86_64-unknown-linux-none.md) - [x86_64-unknown-none](platform-support/x86_64-unknown-none.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index bb89d97a7984d..8b0f9f8b22968 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -407,6 +407,7 @@ target | std | host | notes [`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly [`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS [`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator +[`x86_64-pc-cygwin`](platform-support/x86_64-pc-cygwin.md) | ? | | 64-bit x86 Cygwin | [`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with default network stack (io-pkt) | [`x86_64-pc-nto-qnx710_iosock`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with new network stack (io-sock) | [`x86_64-pc-nto-qnx800`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 8.0 RTOS | diff --git a/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md b/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md new file mode 100644 index 0000000000000..a8fc4f181d8ad --- /dev/null +++ b/src/doc/rustc/src/platform-support/x86_64-pc-cygwin.md @@ -0,0 +1,39 @@ +# `x86_64-pc-cygwin` + +**Tier: 3** + +Windows targets supporting Cygwin. +The `*-cygwin` targets are **not** intended as native target for applications, +a developer writing Windows applications should use the `*-pc-windows-*` targets instead, which are *native* Windows. + +Cygwin is only intended as an emulation layer for Unix-only programs which do not support the native Windows targets. + +## Target maintainers + +- [Berrysoft](https://github.com/Berrysoft) + +## Requirements + +This target is cross compiled. It needs `x86_64-pc-cygwin-gcc` as linker. + +The `target_os` of the target is `cygwin`, and it is `unix`. + +## Building the target + +For cross-compilation you want LLVM with [llvm/llvm-project#121439 (merged)](https://github.com/llvm/llvm-project/pull/121439) applied to fix the LLVM codegen on importing external global variables from DLLs. +No native builds on Cygwin now. It should be possible theoretically though, but might need a lot of patches. + +## Building Rust programs + +Rust does not yet ship pre-compiled artifacts for this target. To compile for +this target, you will either need to build Rust with the target enabled (see +"Building the target" above), or build your own copy of `core` by using +`build-std` or similar. + +## Testing + +Created binaries work fine on Windows with Cygwin. + +## Cross-compilation toolchains and C code + +Compatible C code can be built with GCC shipped with Cygwin. Clang is untested. diff --git a/tests/assembly/targets/targets-pe.rs b/tests/assembly/targets/targets-pe.rs index ab74de5c8ec42..1fa4dc821dd37 100644 --- a/tests/assembly/targets/targets-pe.rs +++ b/tests/assembly/targets/targets-pe.rs @@ -84,6 +84,9 @@ //@ revisions: x86_64_win7_windows_msvc //@ [x86_64_win7_windows_msvc] compile-flags: --target x86_64-win7-windows-msvc //@ [x86_64_win7_windows_msvc] needs-llvm-components: x86 +//@ revisions: x86_64_pc_cygwin +//@ [x86_64_pc_cygwin] compile-flags: --target x86_64-pc-cygwin +//@ [x86_64_pc_cygwin] needs-llvm-components: x86 // Sanity-check that each target can produce assembly code. diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 6421cb8f2c2e7..ba1900fcddb2d 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -274,7 +274,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration warning: 28 warnings emitted From 33d0f386f697ecf870df6fade85cf7183931b9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Wed, 5 Feb 2025 09:26:17 +0800 Subject: [PATCH 12/15] Apply suggestions --- compiler/rustc_target/src/spec/base/cygwin.rs | 8 +------- .../src/spec/targets/x86_64_pc_cygwin.rs | 14 +++----------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/cygwin.rs b/compiler/rustc_target/src/spec/base/cygwin.rs index 2d29060c47a39..8cb3cceb2d59b 100644 --- a/compiler/rustc_target/src/spec/base/cygwin.rs +++ b/compiler/rustc_target/src/spec/base/cygwin.rs @@ -4,14 +4,10 @@ use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOp pub(crate) fn opts() -> TargetOptions { let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ - // FIXME: Disable ASLR for now to fix relocation error "--disable-dynamicbase", "--enable-auto-image-base", ]); crate::spec::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ - // Tell GCC to avoid linker plugins, because we are not bundling - // them with Windows installer, and Rust does its own LTO anyways. - "-fno-use-linker-plugin", "-Wl,--disable-dynamicbase", "-Wl,--enable-auto-image-base", ]); @@ -42,9 +38,7 @@ pub(crate) fn opts() -> TargetOptions { emit_debug_gdb_scripts: false, requires_uwtable: true, eh_frame_header: false, - // FIXME(davidtwco): Support Split DWARF on Cygwin - may require LLVM changes to - // output DWO, despite using DWARF, doesn't use ELF.. - debuginfo_kind: DebuginfoKind::Pdb, + debuginfo_kind: DebuginfoKind::Dwarf, supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), ..Default::default() } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs index a5bedd07e6be8..8da4fe6b8b152 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs @@ -3,16 +3,8 @@ use crate::spec::{Cc, LinkerFlavor, Lld, Target, base}; pub(crate) fn target() -> Target { let mut base = base::cygwin::opts(); base.cpu = "x86-64".into(); - // FIXME: Disable ASLR for now to fix relocation error - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ - "-m", - "i386pep", - "--disable-high-entropy-va", - ]); - base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ - "-m64", - "-Wl,--disable-high-entropy-va", - ]); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "i386pep"]); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); base.max_atomic_width = Some(64); base.linker = Some("x86_64-pc-cygwin-gcc".into()); Target { @@ -26,7 +18,7 @@ pub(crate) fn target() -> Target { description: Some("64-bit x86 Cygwin".into()), tier: Some(3), host_tools: Some(false), - std: Some(true), + std: None, }, } } From 8e5207e75c63e2b341e9a38ddd511422c274da5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Mon, 10 Feb 2025 17:55:54 +0800 Subject: [PATCH 13/15] Reformat files --- compiler/rustc_target/src/spec/base/cygwin.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/cygwin.rs b/compiler/rustc_target/src/spec/base/cygwin.rs index 8cb3cceb2d59b..fe3efb3f46ba0 100644 --- a/compiler/rustc_target/src/spec/base/cygwin.rs +++ b/compiler/rustc_target/src/spec/base/cygwin.rs @@ -3,14 +3,15 @@ use std::borrow::Cow; use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs}; pub(crate) fn opts() -> TargetOptions { - let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[ - "--disable-dynamicbase", - "--enable-auto-image-base", - ]); - crate::spec::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ - "-Wl,--disable-dynamicbase", - "-Wl,--enable-auto-image-base", - ]); + let mut pre_link_args = TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::No, Lld::No), + &["--disable-dynamicbase", "--enable-auto-image-base"], + ); + crate::spec::add_link_args( + &mut pre_link_args, + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-Wl,--disable-dynamicbase", "-Wl,--enable-auto-image-base"], + ); let cygwin_libs = &["-lcygwin", "-lgcc", "-lcygwin", "-luser32", "-lkernel32", "-lgcc_s"]; let mut late_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), cygwin_libs); From 17716be86e36720885a9918a1e08da7a5669ceca Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Mon, 10 Feb 2025 10:30:41 -0800 Subject: [PATCH 14/15] compiler: die immediately instead of handling unknown target codegen We cannot produce anything useful if asked to compile unknown targets. We should handle the error immediately at the point of discovery instead of propagating it upward, and preferably in the simplest way: Die. This allows cleaning up our "error-handling" spread across 5 crates. --- compiler/rustc_const_eval/src/errors.rs | 10 -------- .../src/interpret/eval_context.rs | 3 --- .../rustc_middle/src/mir/interpret/error.rs | 4 --- compiler/rustc_middle/src/ty/layout.rs | 7 ------ compiler/rustc_passes/src/abi_test.rs | 9 ------- compiler/rustc_target/src/callconv/mod.rs | 25 +++---------------- compiler/rustc_ty_utils/src/abi.rs | 12 +++------ 7 files changed, 7 insertions(+), 63 deletions(-) diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 8df9877cabca2..c08495c012f83 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -16,7 +16,6 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::ty::{self, Mutability, Ty}; use rustc_span::{Span, Symbol}; -use rustc_target::callconv::AdjustForForeignAbiError; use crate::interpret::InternKind; @@ -936,9 +935,6 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> { InvalidProgramInfo::TooGeneric => const_eval_too_generic, InvalidProgramInfo::AlreadyReported(_) => const_eval_already_reported, InvalidProgramInfo::Layout(e) => e.diagnostic_message(), - InvalidProgramInfo::FnAbiAdjustForForeignAbi(_) => { - rustc_middle::error::middle_adjust_for_foreign_abi_error - } } } fn add_args(self, diag: &mut Diag<'_, G>) { @@ -953,12 +949,6 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> { } dummy_diag.cancel(); } - InvalidProgramInfo::FnAbiAdjustForForeignAbi( - AdjustForForeignAbiError::Unsupported { arch, abi }, - ) => { - diag.arg("arch", arch); - diag.arg("abi", abi.name()); - } } } } diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 95a72d3cbc1d7..66a75113652f1 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -106,9 +106,6 @@ impl<'tcx, M: Machine<'tcx>> FnAbiOfHelpers<'tcx> for InterpCx<'tcx, M> { ) -> InterpErrorKind<'tcx> { match err { FnAbiError::Layout(err) => err_inval!(Layout(err)), - FnAbiError::AdjustForForeignAbi(err) => { - err_inval!(FnAbiAdjustForForeignAbi(err)) - } } } } diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 1222ba052cceb..8861e31b0991c 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -216,10 +216,6 @@ pub enum InvalidProgramInfo<'tcx> { AlreadyReported(ReportedErrorInfo), /// An error occurred during layout computation. Layout(layout::LayoutError<'tcx>), - /// An error occurred during FnAbi computation: the passed --target lacks FFI support - /// (which unfortunately typeck does not reject). - /// Not using `FnAbiError` as that contains a nested `LayoutError`. - FnAbiAdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError), } /// Details of why a pointer had to be in-bounds. diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index e5015ea3c3d1f..4b3e29b7c6cc8 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -24,7 +24,6 @@ use rustc_target::spec::{ use tracing::debug; use {rustc_abi as abi, rustc_hir as hir}; -use crate::error::UnsupportedFnAbi; use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::query::TyCtxtAt; use crate::ty::normalize_erasing_regions::NormalizationError; @@ -1275,18 +1274,12 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: ExternAbi) pub enum FnAbiError<'tcx> { /// Error produced by a `layout_of` call, while computing `FnAbi` initially. Layout(LayoutError<'tcx>), - - /// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI. - AdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError), } impl<'a, 'b, G: EmissionGuarantee> Diagnostic<'a, G> for FnAbiError<'b> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { match self { Self::Layout(e) => e.into_diagnostic().into_diag(dcx, level), - Self::AdjustForForeignAbi( - rustc_target::callconv::AdjustForForeignAbiError::Unsupported { arch, abi }, - ) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diag(dcx, level), } } } diff --git a/compiler/rustc_passes/src/abi_test.rs b/compiler/rustc_passes/src/abi_test.rs index 4601bb87b76f9..671b7d7ad76cf 100644 --- a/compiler/rustc_passes/src/abi_test.rs +++ b/compiler/rustc_passes/src/abi_test.rs @@ -46,15 +46,6 @@ fn unwrap_fn_abi<'tcx>( span: tcx.def_span(item_def_id), }); } - Err(FnAbiError::AdjustForForeignAbi(e)) => { - // Sadly there seems to be no `into_diagnostic` for this case... and I am not sure if - // this can even be reached. Anyway this is a perma-unstable debug attribute, an ICE - // isn't the worst thing. Also this matches what codegen does. - span_bug!( - tcx.def_span(item_def_id), - "error computing fn_abi_of_instance, cannot adjust for foreign ABI: {e:?}", - ) - } } } diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 50ac6c8fcde16..b49dd2588692d 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -6,7 +6,6 @@ use rustc_abi::{ Size, TyAbiInterface, TyAndLayout, }; use rustc_macros::HashStable_Generic; -use rustc_span::Symbol; use crate::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, WasmCAbi}; @@ -623,19 +622,8 @@ impl<'a, Ty: fmt::Display> fmt::Debug for FnAbi<'a, Ty> { } } -/// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI. -#[derive(Copy, Clone, Debug, HashStable_Generic)] -pub enum AdjustForForeignAbiError { - /// Target architecture doesn't support "foreign" (i.e. non-Rust) ABIs. - Unsupported { arch: Symbol, abi: ExternAbi }, -} - impl<'a, Ty> FnAbi<'a, Ty> { - pub fn adjust_for_foreign_abi( - &mut self, - cx: &C, - abi: ExternAbi, - ) -> Result<(), AdjustForForeignAbiError> + pub fn adjust_for_foreign_abi(&mut self, cx: &C, abi: ExternAbi) where Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout + HasTargetSpec + HasWasmCAbiOpt + HasX86AbiOpt, @@ -644,7 +632,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { if let Some(arg) = self.args.first_mut() { arg.pass_by_stack_offset(None); } - return Ok(()); + return; } let spec = cx.target_spec(); @@ -719,15 +707,8 @@ impl<'a, Ty> FnAbi<'a, Ty> { } "wasm64" => wasm::compute_c_abi_info(cx, self), "bpf" => bpf::compute_abi_info(self), - arch => { - return Err(AdjustForForeignAbiError::Unsupported { - arch: Symbol::intern(arch), - abi, - }); - } + arch => panic!("no lowering implemented for {arch}"), } - - Ok(()) } pub fn adjust_for_rust_abi(&mut self, cx: &C, abi: ExternAbi) diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 169f3a78c26a7..332b00e8423bb 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -650,7 +650,7 @@ fn fn_abi_new_uncached<'tcx>( conv, can_unwind: fn_can_unwind(cx.tcx(), fn_def_id, sig.abi), }; - fn_abi_adjust_for_abi(cx, &mut fn_abi, sig.abi, fn_def_id)?; + fn_abi_adjust_for_abi(cx, &mut fn_abi, sig.abi, fn_def_id); debug!("fn_abi_new_uncached = {:?}", fn_abi); fn_abi_sanity_check(cx, &fn_abi, sig.abi); Ok(tcx.arena.alloc(fn_abi)) @@ -662,7 +662,7 @@ fn fn_abi_adjust_for_abi<'tcx>( fn_abi: &mut FnAbi<'tcx, Ty<'tcx>>, abi: ExternAbi, fn_def_id: Option, -) -> Result<(), &'tcx FnAbiError<'tcx>> { +) { if abi == ExternAbi::Unadjusted { // The "unadjusted" ABI passes aggregates in "direct" mode. That's fragile but needed for // some LLVM intrinsics. @@ -682,7 +682,7 @@ fn fn_abi_adjust_for_abi<'tcx>( for arg in fn_abi.args.iter_mut() { unadjust(arg); } - return Ok(()); + return; } let tcx = cx.tcx(); @@ -723,12 +723,8 @@ fn fn_abi_adjust_for_abi<'tcx>( } } } else { - fn_abi - .adjust_for_foreign_abi(cx, abi) - .map_err(|err| &*tcx.arena.alloc(FnAbiError::AdjustForForeignAbi(err)))?; + fn_abi.adjust_for_foreign_abi(cx, abi); } - - Ok(()) } #[tracing::instrument(level = "debug", skip(cx))] From fd58652a7de3c04ca957dd8fdc580c16ad17a8d3 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Mon, 10 Feb 2025 11:19:02 -0800 Subject: [PATCH 15/15] cg_gcc: stop caring about compiling for unknown targets --- compiler/rustc_codegen_gcc/src/int.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_gcc/src/int.rs b/compiler/rustc_codegen_gcc/src/int.rs index 4a1db8d662a9f..f3552d9b12fcb 100644 --- a/compiler/rustc_codegen_gcc/src/int.rs +++ b/compiler/rustc_codegen_gcc/src/int.rs @@ -400,7 +400,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { conv: Conv::C, can_unwind: false, }; - fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false }).unwrap(); + fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false }); let ret_indirect = matches!(fn_abi.ret.mode, PassMode::Indirect { .. });