Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3f2589a

Browse files
committed
Fix multiple inline asm blocks in the same function
1 parent 1ffc307 commit 3f2589a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>(
5353
vtables: &mut cx.vtables,
5454
source_info_set: indexmap::IndexSet::new(),
5555
next_ssa_var: 0,
56+
57+
inline_asm_index: 0,
5658
};
5759

5860
let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited());

src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> {
278278

279279
/// This should only be accessed by `CPlace::new_var`.
280280
pub(crate) next_ssa_var: u32,
281+
282+
pub(crate) inline_asm_index: u32,
281283
}
282284

283285
impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> {

src/inline_asm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ pub(crate) fn codegen_inline_asm<'tcx>(
6868
}
6969
}
7070

71-
let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, /*FIXME*/0);
71+
let inline_asm_index = fx.inline_asm_index;
72+
fx.inline_asm_index += 1;
73+
let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, inline_asm_index);
7274

7375
let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs);
7476
fx.global_asm.push_str(&generated_asm);

0 commit comments

Comments
 (0)