Fix multiple inline asm blocks in the same function

This commit is contained in:
bjorn3 2020-07-23 12:37:03 +02:00
parent 1ffc3079b0
commit 3f2589acd9
3 changed files with 7 additions and 1 deletions

View File

@ -53,6 +53,8 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>(
vtables: &mut cx.vtables,
source_info_set: indexmap::IndexSet::new(),
next_ssa_var: 0,
inline_asm_index: 0,
};
let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited());

View File

@ -278,6 +278,8 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> {
/// This should only be accessed by `CPlace::new_var`.
pub(crate) next_ssa_var: u32,
pub(crate) inline_asm_index: u32,
}
impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> {

View File

@ -68,7 +68,9 @@ pub(crate) fn codegen_inline_asm<'tcx>(
}
}
let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, /*FIXME*/0);
let inline_asm_index = fx.inline_asm_index;
fx.inline_asm_index += 1;
let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, inline_asm_index);
let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs);
fx.global_asm.push_str(&generated_asm);