Skip to content

Commit 2811ce7

Browse files
committed
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
1 parent 0bd0b99 commit 2811ce7

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

example/mini_core.rs

+6
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,12 @@ pub macro global_asm() {
726726
/* compiler built-in */
727727
}
728728

729+
#[rustc_builtin_macro]
730+
#[rustc_macro_transparency = "semitransparent"]
731+
pub macro naked_asm() {
732+
/* compiler built-in */
733+
}
734+
729735
pub static A_STATIC: u8 = 42;
730736

731737
#[lang = "panic_location"]

example/mini_core_hello_world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ global_asm! {
390390
#[naked]
391391
extern "C" fn naked_test() {
392392
unsafe {
393-
asm!("ret", options(noreturn));
393+
naked_asm!("ret");
394394
}
395395
}
396396

src/base.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_ast::InlineAsmOptions;
88
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
99
use rustc_index::IndexVec;
1010
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
11+
use rustc_middle::mir::InlineAsmMacro;
1112
use rustc_middle::ty::TypeVisitableExt;
1213
use rustc_middle::ty::adjustment::PointerCoercion;
1314
use rustc_middle::ty::layout::FnAbiOf;
@@ -57,6 +58,7 @@ pub(crate) fn codegen_fn<'tcx>(
5758

5859
match &mir.basic_blocks[START_BLOCK].terminator().kind {
5960
TerminatorKind::InlineAsm {
61+
asm_macro: InlineAsmMacro::NakedAsm,
6062
template,
6163
operands,
6264
options,
@@ -498,6 +500,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
498500
"tail calls are not yet supported in `rustc_codegen_cranelift` backend"
499501
),
500502
TerminatorKind::InlineAsm {
503+
asm_macro: _,
501504
template,
502505
operands,
503506
options,

0 commit comments

Comments
 (0)