diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2024-09-05 19:45:40 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2024-10-06 19:00:09 +0200 |
| commit | 2811ce715dee288f83a56bbb96aac8955efbcd93 (patch) | |
| tree | fbba1ece98d2b5fae6ff77d9022a7a6731c7688b | |
| parent | 0bd0b997299a919a00442f2f8c5a244b7b847d58 (diff) | |
| download | rust-2811ce715dee288f83a56bbb96aac8955efbcd93.tar.gz rust-2811ce715dee288f83a56bbb96aac8955efbcd93.zip | |
various fixes for `naked_asm!` implementation
- fix for divergence - fix error message - fix another cranelift test - fix some cranelift things - don't set the NORETURN option for naked asm - fix use of naked_asm! in doc comment - fix use of naked_asm! in run-make test - use `span_bug` in unreachable branch
| -rw-r--r-- | example/mini_core.rs | 6 | ||||
| -rw-r--r-- | example/mini_core_hello_world.rs | 2 | ||||
| -rw-r--r-- | src/base.rs | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs index 5e535ff62e1..9fc0318df5d 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -726,6 +726,12 @@ pub macro global_asm() { /* compiler built-in */ } +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro naked_asm() { + /* compiler built-in */ +} + pub static A_STATIC: u8 = 42; #[lang = "panic_location"] diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index ccbd5a78485..e47431e0f87 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -390,7 +390,7 @@ global_asm! { #[naked] extern "C" fn naked_test() { unsafe { - asm!("ret", options(noreturn)); + naked_asm!("ret"); } } diff --git a/src/base.rs b/src/base.rs index 09680622069..a681e6d9f3c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,6 +8,7 @@ use rustc_ast::InlineAsmOptions; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_index::IndexVec; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +use rustc_middle::mir::InlineAsmMacro; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; @@ -57,6 +58,7 @@ pub(crate) fn codegen_fn<'tcx>( match &mir.basic_blocks[START_BLOCK].terminator().kind { TerminatorKind::InlineAsm { + asm_macro: InlineAsmMacro::NakedAsm, template, operands, options, @@ -498,6 +500,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { "tail calls are not yet supported in `rustc_codegen_cranelift` backend" ), TerminatorKind::InlineAsm { + asm_macro: _, template, operands, options, |
