Skip to content

Commit f7fe6ef

Browse files
committed
Move inline_asm_index from CodegenCx to FunctionCx
1 parent 9f5fc01 commit f7fe6ef

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub(crate) fn codegen_fn<'tcx>(
104104

105105
clif_comments,
106106
next_ssa_var: 0,
107+
inline_asm_index: 0,
107108
};
108109

109110
tcx.prof.generic_activity("codegen clif ir").run(|| codegen_fn_body(&mut fx, start_block));

src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
292292

293293
/// This should only be accessed by `CPlace::new_var`.
294294
pub(crate) next_ssa_var: u32,
295+
296+
pub(crate) inline_asm_index: u32,
295297
}
296298

297299
impl<'tcx> LayoutOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> {

src/inline_asm.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>(
103103
// be exported from the main codegen unit and may thus be unreachable from the
104104
// object file created by an external assembler.
105105
let wrapper_name = format!(
106-
"__inline_asm_{}_wrapper_n{}",
106+
"{}__inline_asm_{}_wrapper_n{}",
107+
fx.symbol_name,
107108
fx.cx.cgu_name.as_str().replace('.', "__").replace('-', "_"),
108-
fx.cx.inline_asm_index
109+
fx.inline_asm_index,
109110
);
110-
fx.cx.inline_asm_index += 1;
111+
fx.inline_asm_index += 1;
111112
let sig =
112113
get_function_sig(fx.tcx, fx.target_config.default_call_conv, instance);
113114
create_wrapper_function(fx.module, sig, &wrapper_name, symbol.name);
@@ -166,11 +167,12 @@ pub(crate) fn codegen_inline_asm_inner<'tcx>(
166167
asm_gen.allocate_stack_slots();
167168

168169
let asm_name = format!(
169-
"__inline_asm_{}_n{}",
170+
"{}__inline_asm_{}_n{}",
171+
fx.symbol_name,
170172
fx.cx.cgu_name.as_str().replace('.', "__").replace('-', "_"),
171-
fx.cx.inline_asm_index
173+
fx.inline_asm_index,
172174
);
173-
fx.cx.inline_asm_index += 1;
175+
fx.inline_asm_index += 1;
174176

175177
let generated_asm = asm_gen.generate_asm_wrapper(&asm_name);
176178
fx.cx.global_asm.push_str(&generated_asm);

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ struct CodegenCx {
129129
invocation_temp: Option<String>,
130130
should_write_ir: bool,
131131
global_asm: String,
132-
inline_asm_index: usize,
133132
debug_context: Option<DebugContext>,
134133
cgu_name: Symbol,
135134
}
@@ -148,7 +147,6 @@ impl CodegenCx {
148147
invocation_temp: tcx.sess.invocation_temp.clone(),
149148
should_write_ir: crate::pretty_clif::should_write_ir(tcx),
150149
global_asm: String::new(),
151-
inline_asm_index: 0,
152150
debug_context,
153151
cgu_name,
154152
}

0 commit comments

Comments
 (0)