Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Deprecate llvm_asm! #87590

Merged
merged 3 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub fn spin_loop() {
#[inline]
#[unstable(feature = "bench_black_box", issue = "64102")]
#[cfg_attr(not(bootstrap), allow(unused_mut))]
#[cfg_attr(bootstrap, allow(deprecated))]
pub fn black_box<T>(mut dummy: T) -> T {
#[cfg(bootstrap)]
// SAFETY: the inline assembly is a no-op.
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,10 @@ pub(crate) mod builtin {
issue = "70173",
reason = "prefer using the new asm! syntax instead"
)]
#[rustc_deprecated(
since = "1.56",
reason = "will be removed from the compiler, use asm! instead"
)]
#[rustc_builtin_macro]
#[macro_export]
macro_rules! llvm_asm {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/abi/abi-sysv64-register-usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// ignore-aarch64

#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this test be modified to use asm! instead? This test isn't testing llvm_asm! itself

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfectly fine to leave removal to a follow-up PR (potentially the same one that removes llvm_asm entirely.


#[cfg(target_arch = "x86_64")]
pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64,
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/asm/naked-functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![feature(naked_functions)]
#![feature(or_patterns)]
#![crate_type = "lib"]
#![allow(deprecated)] // llvm_asm!

#[repr(C)]
pub struct P { x: u8, y: u16 }
Expand Down
66 changes: 33 additions & 33 deletions src/test/ui/asm/naked-functions.stderr
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
error: asm with the `pure` option must have at least one output
--> $DIR/naked-functions.rs:126:14
--> $DIR/naked-functions.rs:127:14
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^

error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:13:5
--> $DIR/naked-functions.rs:14:5
|
LL | mut a: u32,
| ^^^^^

error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:15:5
--> $DIR/naked-functions.rs:16:5
|
LL | &b: &i32,
| ^^

error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:17:6
--> $DIR/naked-functions.rs:18:6
|
LL | (None | Some(_)): Option<std::ptr::NonNull<u8>>,
| ^^^^^^^^^^^^^^

error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:19:5
--> $DIR/naked-functions.rs:20:5
|
LL | P { x, y }: P,
| ^^^^^^^^^^

error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:29:5
--> $DIR/naked-functions.rs:30:5
|
LL | a + 1
| ^
|
= help: follow the calling convention in asm block to use parameters

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:26:1
--> $DIR/naked-functions.rs:27:1
|
LL | / pub unsafe extern "C" fn inc(a: u32) -> u32 {
LL | |
Expand All @@ -53,15 +53,15 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:35:31
--> $DIR/naked-functions.rs:36:31
|
LL | asm!("/* {0} */", in(reg) a, options(noreturn));
| ^
|
= help: follow the calling convention in asm block to use parameters

warning: only `const` and `sym` operands are supported in naked functions
--> $DIR/naked-functions.rs:35:23
--> $DIR/naked-functions.rs:36:23
|
LL | asm!("/* {0} */", in(reg) a, options(noreturn));
| ^^^^^^^^^
Expand All @@ -70,7 +70,7 @@ LL | asm!("/* {0} */", in(reg) a, options(noreturn));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:42:1
--> $DIR/naked-functions.rs:43:1
|
LL | / pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
LL | |
Expand All @@ -84,7 +84,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: only `const` and `sym` operands are supported in naked functions
--> $DIR/naked-functions.rs:62:10
--> $DIR/naked-functions.rs:63:10
|
LL | in(reg) a,
| ^^^^^^^^^
Expand All @@ -102,7 +102,7 @@ LL | out(reg) e,
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:59:5
--> $DIR/naked-functions.rs:60:5
|
LL | / asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
LL | |
Expand All @@ -117,7 +117,7 @@ LL | | );
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:49:1
--> $DIR/naked-functions.rs:50:1
|
LL | / pub unsafe extern "C" fn unsupported_operands() {
LL | |
Expand All @@ -141,7 +141,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:75:1
--> $DIR/naked-functions.rs:76:1
|
LL | / pub extern "C" fn missing_assembly() {
LL | |
Expand All @@ -153,7 +153,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:84:5
--> $DIR/naked-functions.rs:85:5
|
LL | asm!("");
| ^^^^^^^^^
Expand All @@ -162,7 +162,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:87:5
--> $DIR/naked-functions.rs:88:5
|
LL | asm!("");
| ^^^^^^^^^
Expand All @@ -171,7 +171,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:90:5
--> $DIR/naked-functions.rs:91:5
|
LL | asm!("");
| ^^^^^^^^^
Expand All @@ -180,7 +180,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:81:1
--> $DIR/naked-functions.rs:82:1
|
LL | / pub extern "C" fn too_many_asm_blocks() {
LL | |
Expand All @@ -202,15 +202,15 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:101:11
--> $DIR/naked-functions.rs:102:11
|
LL | *&y
| ^
|
= help: follow the calling convention in asm block to use parameters

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:98:5
--> $DIR/naked-functions.rs:99:5
|
LL | / pub extern "C" fn inner(y: usize) -> usize {
LL | |
Expand All @@ -225,7 +225,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: the LLVM-style inline assembly is unsupported in naked functions
--> $DIR/naked-functions.rs:111:5
--> $DIR/naked-functions.rs:112:5
|
LL | llvm_asm!("");
| ^^^^^^^^^^^^^^
Expand All @@ -236,7 +236,7 @@ LL | llvm_asm!("");
= note: this warning originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:108:1
--> $DIR/naked-functions.rs:109:1
|
LL | / unsafe extern "C" fn llvm() -> ! {
LL | |
Expand All @@ -252,7 +252,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm options unsupported in naked functions: `nomem`, `preserves_flags`
--> $DIR/naked-functions.rs:119:5
--> $DIR/naked-functions.rs:120:5
|
LL | asm!("", options(nomem, preserves_flags, noreturn));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -261,7 +261,7 @@ LL | asm!("", options(nomem, preserves_flags, noreturn));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
--> $DIR/naked-functions.rs:126:5
--> $DIR/naked-functions.rs:127:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -270,7 +270,7 @@ LL | asm!("", options(readonly, nostack), options(pure));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:126:5
--> $DIR/naked-functions.rs:127:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -279,21 +279,21 @@ LL | asm!("", options(readonly, nostack), options(pure));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:135:15
--> $DIR/naked-functions.rs:136:15
|
LL | pub unsafe fn default_abi() {
| ^^^^^^^^^^^
|
= note: `#[warn(undefined_naked_function_abi)]` on by default

warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:141:29
--> $DIR/naked-functions.rs:142:29
|
LL | pub unsafe extern "Rust" fn rust_abi() {
| ^^^^^^^^

warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:175:1
--> $DIR/naked-functions.rs:176:1
|
LL | #[inline]
| ^^^^^^^^^
Expand All @@ -302,7 +302,7 @@ LL | #[inline]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:183:1
--> $DIR/naked-functions.rs:184:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
Expand All @@ -311,7 +311,7 @@ LL | #[inline(always)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:191:1
--> $DIR/naked-functions.rs:192:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^
Expand All @@ -320,7 +320,7 @@ LL | #[inline(never)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:199:1
--> $DIR/naked-functions.rs:200:1
|
LL | #[inline]
| ^^^^^^^^^
Expand All @@ -329,7 +329,7 @@ LL | #[inline]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:202:1
--> $DIR/naked-functions.rs:203:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
Expand All @@ -338,7 +338,7 @@ LL | #[inline(always)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>

warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:205:1
--> $DIR/naked-functions.rs:206:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/asm/rustfix-asm.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// only-x86_64

#![feature(asm, llvm_asm)]
#![allow(deprecated)] // llvm_asm!

fn main() {
unsafe {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/asm/rustfix-asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// only-x86_64

#![feature(asm, llvm_asm)]
#![allow(deprecated)] // llvm_asm!

fn main() {
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/asm/rustfix-asm.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: the legacy LLVM-style asm! syntax is no longer supported
--> $DIR/rustfix-asm.rs:10:9
--> $DIR/rustfix-asm.rs:11:9
|
LL | asm!("" :: "r" (x));
| ----^^^^^^^^^^^^^^^^
Expand All @@ -10,7 +10,7 @@ LL | asm!("" :: "r" (x));
= note: alternatively, switch to llvm_asm! to keep your code working as it is

error: the legacy LLVM-style asm! syntax is no longer supported
--> $DIR/rustfix-asm.rs:12:9
--> $DIR/rustfix-asm.rs:13:9
|
LL | asm!("" : "=r" (y));
| ----^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/ast-json/ast-json-ice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// dont-check-compiler-stdout - don't check for any AST change.

#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!

enum V {
A(i32),
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/borrowck/borrowck-asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// ignore-sparc64

#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!

#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
Expand Down
Loading