Skip to content

Commit f2b8312

Browse files
committed
1 parent a7e645c commit f2b8312

File tree

4 files changed

+9
-23
lines changed

4 files changed

+9
-23
lines changed

compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
3333
let (begin, end) = crate::mir::naked_asm::prefix_and_suffix(cx.tcx(), instance, item_data);
3434

3535
let mut template_vec = Vec::new();
36-
template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin));
36+
template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin.into()));
3737
template_vec.extend(template.iter().cloned());
38-
template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(end));
38+
template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(end.into()));
3939

4040
cx.codegen_global_asm(&template_vec, &operands, options, line_spans);
4141
}
@@ -178,9 +178,6 @@ fn prefix_and_suffix<'tcx>(
178178
writeln!(begin, ".hidden {asm_name}").unwrap();
179179
}
180180
writeln!(begin, ".type {asm_name}, {function}").unwrap();
181-
if let Some(instruction_set) = attrs.instruction_set {
182-
writeln!(begin, "{}", instruction_set.as_str()).unwrap();
183-
}
184181
if !arch_prefix.is_empty() {
185182
writeln!(begin, "{}", arch_prefix).unwrap();
186183
}
@@ -203,9 +200,6 @@ fn prefix_and_suffix<'tcx>(
203200
if let Visibility::Hidden = item_data.visibility {
204201
writeln!(begin, ".private_extern {asm_name}").unwrap();
205202
}
206-
if let Some(instruction_set) = attrs.instruction_set {
207-
writeln!(begin, "{}", instruction_set.as_str()).unwrap();
208-
}
209203
writeln!(begin, "{asm_name}:").unwrap();
210204

211205
writeln!(end).unwrap();
@@ -225,9 +219,6 @@ fn prefix_and_suffix<'tcx>(
225219
writeln!(begin, ".scl 2").unwrap();
226220
writeln!(begin, ".type 32").unwrap();
227221
writeln!(begin, ".endef {asm_name}").unwrap();
228-
if let Some(instruction_set) = attrs.instruction_set {
229-
writeln!(begin, "{}", instruction_set.as_str()).unwrap();
230-
}
231222
writeln!(begin, "{asm_name}:").unwrap();
232223

233224
writeln!(end).unwrap();

tests/crashes/124375.rs

-11
This file was deleted.

tests/ui/asm/naked-functions-instruction-set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ unsafe extern "C" fn test_thumb() {
2424

2525
#[no_mangle]
2626
#[naked]
27-
#[instruction_set(arm::t32)]
27+
#[instruction_set(arm::a32)]
2828
unsafe extern "C" fn test_arm() {
2929
asm!("bx lr", options(noreturn));
3030
}

tests/ui/asm/naked-functions.rs

+6
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
182182
//~^ ERROR asm template must be a string literal
183183
}
184184

185+
// this previously ICE'd, see https://github.com./rust-lang/rust/issues/124375
186+
#[naked]
187+
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
188+
asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
189+
}
190+
185191
#[cfg(target_arch = "x86_64")]
186192
#[cfg_attr(target_pointer_width = "64", no_mangle)]
187193
#[naked]

0 commit comments

Comments
 (0)