Skip to content

Commit 55cc776

Browse files
committed
Introduce asm_supported() helper
1 parent 46388c1 commit 55cc776

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/global_asm.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
8181
}
8282
}
8383

84+
pub(crate) fn asm_supported(tcx: TyCtxt<'_>) -> bool {
85+
cfg!(feature = "inline_asm") && !tcx.sess.target.is_like_windows
86+
}
87+
8488
#[derive(Debug)]
8589
pub(crate) struct GlobalAsmConfig {
8690
asm_enabled: bool,
@@ -90,10 +94,8 @@ pub(crate) struct GlobalAsmConfig {
9094

9195
impl GlobalAsmConfig {
9296
pub(crate) fn new(tcx: TyCtxt<'_>) -> Self {
93-
let asm_enabled = cfg!(feature = "inline_asm") && !tcx.sess.target.is_like_windows;
94-
9597
GlobalAsmConfig {
96-
asm_enabled,
98+
asm_enabled: asm_supported(tcx),
9799
assembler: crate::toolchain::get_toolchain_binary(tcx.sess, "as"),
98100
output_filenames: tcx.output_filenames(()).clone(),
99101
}

src/inline_asm.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_span::sym;
88
use rustc_target::asm::*;
99
use target_lexicon::BinaryFormat;
1010

11+
use crate::global_asm::asm_supported;
1112
use crate::prelude::*;
1213

1314
enum CInlineAsmOperand<'tcx> {
@@ -44,9 +45,13 @@ pub(crate) fn codegen_inline_asm<'tcx>(
4445
) {
4546
// FIXME add .eh_frame unwind info directives
4647

47-
if !template.is_empty()
48-
&& (cfg!(not(feature = "inline_asm")) || fx.tcx.sess.target.is_like_windows)
49-
{
48+
if !asm_supported(fx.tcx) {
49+
if template.is_empty() {
50+
let destination_block = fx.get_block(destination.unwrap());
51+
fx.bcx.ins().jump(destination_block, &[]);
52+
return;
53+
}
54+
5055
// Used by panic_abort
5156
if template[0] == InlineAsmTemplatePiece::String("int $$0x29".to_string()) {
5257
fx.bcx.ins().trap(TrapCode::User(1));

0 commit comments

Comments
 (0)