Store symbol name as owned string
This commit is contained in:
parent
b1e9d2e1a2
commit
5896e5cdfa
2 changed files with 13 additions and 14 deletions
24
src/base.rs
24
src/base.rs
|
|
@ -5,15 +5,14 @@ use rustc_index::vec::IndexVec;
|
|||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::FnAbiOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::SymbolName;
|
||||
|
||||
use crate::constant::ConstantCx;
|
||||
use crate::debuginfo::FunctionDebugContext;
|
||||
use crate::prelude::*;
|
||||
use crate::pretty_clif::CommentWriter;
|
||||
|
||||
struct CodegenedFunction<'tcx> {
|
||||
symbol_name: SymbolName<'tcx>,
|
||||
struct CodegenedFunction {
|
||||
symbol_name: String,
|
||||
func_id: FuncId,
|
||||
func: Function,
|
||||
clif_comments: CommentWriter,
|
||||
|
|
@ -42,7 +41,7 @@ fn codegen_fn<'tcx>(
|
|||
cached_func: Function,
|
||||
module: &mut dyn Module,
|
||||
instance: Instance<'tcx>,
|
||||
) -> CodegenedFunction<'tcx> {
|
||||
) -> CodegenedFunction {
|
||||
debug_assert!(!instance.substs.needs_infer());
|
||||
|
||||
let mir = tcx.instance_mir(instance.def);
|
||||
|
|
@ -56,9 +55,9 @@ fn codegen_fn<'tcx>(
|
|||
});
|
||||
|
||||
// Declare function
|
||||
let symbol_name = tcx.symbol_name(instance);
|
||||
let symbol_name = tcx.symbol_name(instance).name.to_string();
|
||||
let sig = get_function_sig(tcx, module.isa().triple(), instance);
|
||||
let func_id = module.declare_function(symbol_name.name, Linkage::Local, &sig).unwrap();
|
||||
let func_id = module.declare_function(&symbol_name, Linkage::Local, &sig).unwrap();
|
||||
|
||||
// Make the FunctionBuilder
|
||||
let mut func_ctx = FunctionBuilderContext::new();
|
||||
|
|
@ -81,7 +80,7 @@ fn codegen_fn<'tcx>(
|
|||
let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance);
|
||||
|
||||
let func_debug_cx = if let Some(debug_context) = &mut cx.debug_context {
|
||||
Some(debug_context.define_function(tcx, symbol_name.name, mir.span))
|
||||
Some(debug_context.define_function(tcx, &symbol_name, mir.span))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -113,6 +112,7 @@ fn codegen_fn<'tcx>(
|
|||
tcx.sess.time("codegen clif ir", || codegen_fn_body(&mut fx, start_block));
|
||||
|
||||
// Recover all necessary data from fx, before accessing func will prevent future access to it.
|
||||
let symbol_name = fx.symbol_name;
|
||||
let clif_comments = fx.clif_comments;
|
||||
let func_debug_cx = fx.func_debug_cx;
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ fn codegen_fn<'tcx>(
|
|||
if cx.should_write_ir {
|
||||
crate::pretty_clif::write_clif_file(
|
||||
tcx.output_filenames(()),
|
||||
symbol_name.name,
|
||||
&symbol_name,
|
||||
"unopt",
|
||||
module.isa(),
|
||||
&func,
|
||||
|
|
@ -135,11 +135,11 @@ fn codegen_fn<'tcx>(
|
|||
CodegenedFunction { symbol_name, func_id, func, clif_comments, func_debug_cx }
|
||||
}
|
||||
|
||||
fn compile_fn<'tcx>(
|
||||
fn compile_fn(
|
||||
cx: &mut crate::CodegenCx,
|
||||
cached_context: &mut Context,
|
||||
module: &mut dyn Module,
|
||||
codegened_func: CodegenedFunction<'tcx>,
|
||||
codegened_func: CodegenedFunction,
|
||||
) {
|
||||
let clif_comments = codegened_func.clif_comments;
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ fn compile_fn<'tcx>(
|
|||
// Write optimized function to file for debugging
|
||||
crate::pretty_clif::write_clif_file(
|
||||
&cx.output_filenames,
|
||||
codegened_func.symbol_name.name,
|
||||
&codegened_func.symbol_name,
|
||||
"opt",
|
||||
module.isa(),
|
||||
&context.func,
|
||||
|
|
@ -205,7 +205,7 @@ fn compile_fn<'tcx>(
|
|||
if let Some(disasm) = &context.compiled_code().unwrap().disasm {
|
||||
crate::pretty_clif::write_ir_file(
|
||||
&cx.output_filenames,
|
||||
&format!("{}.vcode", codegened_func.symbol_name.name),
|
||||
&format!("{}.vcode", codegened_func.symbol_name),
|
||||
|file| file.write_all(disasm.as_bytes()),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use rustc_index::vec::IndexVec;
|
|||
use rustc_middle::ty::layout::{
|
||||
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
|
||||
};
|
||||
use rustc_middle::ty::SymbolName;
|
||||
use rustc_span::SourceFile;
|
||||
use rustc_target::abi::call::FnAbi;
|
||||
use rustc_target::abi::{Integer, Primitive};
|
||||
|
|
@ -246,7 +245,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
|||
pub(crate) func_debug_cx: Option<FunctionDebugContext>,
|
||||
|
||||
pub(crate) instance: Instance<'tcx>,
|
||||
pub(crate) symbol_name: SymbolName<'tcx>,
|
||||
pub(crate) symbol_name: String,
|
||||
pub(crate) mir: &'tcx Body<'tcx>,
|
||||
pub(crate) fn_abi: Option<&'tcx FnAbi<'tcx, Ty<'tcx>>>,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue