diff options
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/callee.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/common.rs | 13 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/consts.rs | 10 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/context.rs | 5 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/metadata.rs | 3 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/namespace.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/intrinsic.rs | 2 |
8 files changed, 17 insertions, 22 deletions
diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs index 6ad75cff3dd..7b341651adf 100644 --- a/src/librustc_codegen_llvm/callee.rs +++ b/src/librustc_codegen_llvm/callee.rs @@ -35,7 +35,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value return llfn; } - let sym = tcx.symbol_name(instance).name.as_str(); + let sym = tcx.symbol_name(instance).name; debug!("get_fn({:?}: {:?}) => {}", instance, instance.monomorphic_ty(cx.tcx()), sym); let fn_abi = FnAbi::of_instance(cx, instance, &[]); diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 64140747871..0101e4512fa 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -15,7 +15,7 @@ use rustc_codegen_ssa::traits::*; use rustc_middle::bug; use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar}; use rustc_middle::ty::layout::TyAndLayout; -use rustc_span::symbol::Symbol; +use rustc_middle::ty::SymbolName; use rustc_target::abi::{self, HasDataLayout, LayoutOf, Pointer, Size}; use libc::{c_char, c_uint}; @@ -105,17 +105,16 @@ impl CodegenCx<'ll, 'tcx> { bytes_in_context(self.llcx, bytes) } - fn const_cstr(&self, s: Symbol, null_terminated: bool) -> &'ll Value { + fn const_cstr(&self, s: SymbolName<'tcx>, null_terminated: bool) -> &'ll Value { unsafe { if let Some(&llval) = self.const_cstr_cache.borrow().get(&s) { return llval; } - let s_str = s.as_str(); let sc = llvm::LLVMConstStringInContext( self.llcx, - s_str.as_ptr() as *const c_char, - s_str.len() as c_uint, + s.name.as_ptr() as *const c_char, + s.name.len() as c_uint, !null_terminated as Bool, ); let sym = self.generate_local_symbol_name("str"); @@ -202,8 +201,8 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { unsafe { llvm::LLVMConstReal(t, val) } } - fn const_str(&self, s: Symbol) -> (&'ll Value, &'ll Value) { - let len = s.as_str().len(); + fn const_str(&self, s: SymbolName<'tcx>) -> (&'ll Value, &'ll Value) { + let len = s.name.len(); let cs = consts::ptrcast( self.const_cstr(s, false), self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)), diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 9d9b53fc4a8..90887b760fb 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -18,7 +18,7 @@ use rustc_middle::mir::interpret::{ use rustc_middle::mir::mono::MonoItem; use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::{bug, span_bug}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::sym; use rustc_span::Span; use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size}; @@ -107,11 +107,10 @@ fn check_and_apply_linkage( cx: &CodegenCx<'ll, 'tcx>, attrs: &CodegenFnAttrs, ty: Ty<'tcx>, - sym: Symbol, + sym: &str, span: Span, ) -> &'ll Value { let llty = cx.layout_of(ty).llvm_type(cx); - let sym = sym.as_str(); if let Some(linkage) = attrs.linkage { debug!("get_static: sym={} linkage={:?}", sym, linkage); @@ -215,14 +214,13 @@ impl CodegenCx<'ll, 'tcx> { // FIXME: refactor this to work without accessing the HIR let (g, attrs) = match self.tcx.hir().get(id) { Node::Item(&hir::Item { attrs, span, kind: hir::ItemKind::Static(..), .. }) => { - let sym_str = sym.as_str(); - if let Some(g) = self.get_declared_value(&sym_str) { + if let Some(g) = self.get_declared_value(sym) { if self.val_ty(g) != self.type_ptr_to(llty) { span_bug!(span, "Conflicting types for static"); } } - let g = self.declare_global(&sym_str, llty); + let g = self.declare_global(sym, llty); if !self.tcx.is_reachable_non_generic(def_id) { unsafe { diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 21ba97d15a4..0a415d12166 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -16,11 +16,10 @@ use rustc_data_structures::small_c_str::SmallCStr; use rustc_middle::bug; use rustc_middle::mir::mono::CodegenUnit; use rustc_middle::ty::layout::{HasParamEnv, LayoutError, TyAndLayout}; -use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; +use rustc_middle::ty::{self, Instance, SymbolName, Ty, TyCtxt}; use rustc_session::config::{CFGuard, CrateType, DebugInfo}; use rustc_session::Session; use rustc_span::source_map::{Span, DUMMY_SP}; -use rustc_span::symbol::Symbol; use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx}; use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel}; @@ -47,7 +46,7 @@ pub struct CodegenCx<'ll, 'tcx> { pub vtables: RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>, /// Cache of constant strings, - pub const_cstr_cache: RefCell<FxHashMap<Symbol, &'ll Value>>, + pub const_cstr_cache: RefCell<FxHashMap<SymbolName<'tcx>, &'ll Value>>, /// Reverse-direction for const ptrs cast from globals. /// diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index f2e042cf86a..ef9d42968ae 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -2468,8 +2468,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global let variable_type = Instance::mono(cx.tcx, def_id).monomorphic_ty(cx.tcx); let type_metadata = type_metadata(cx, variable_type, span); let var_name = tcx.item_name(def_id).as_str(); - let linkage_name: &str = - &mangled_name_of_instance(cx, Instance::mono(tcx, def_id)).name.as_str(); + let linkage_name = mangled_name_of_instance(cx, Instance::mono(tcx, def_id)).name; // When empty, linkage_name field is omitted, // which is what we want for no_mangle statics let linkage_name = if var_name == linkage_name { "" } else { linkage_name }; diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index b5434298805..44993d7602f 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -267,7 +267,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let substs = instance.substs.truncate_to(self.tcx(), generics); let template_parameters = get_template_parameters(self, &generics, substs, &mut name); - let linkage_name: &str = &mangled_name_of_instance(self, instance).name.as_str(); + let linkage_name = &mangled_name_of_instance(self, instance).name; // Omit the linkage_name if it is the same as subprogram name. let linkage_name = if &name == linkage_name { "" } else { linkage_name }; diff --git a/src/librustc_codegen_llvm/debuginfo/namespace.rs b/src/librustc_codegen_llvm/debuginfo/namespace.rs index 475dea239a7..d1a55335c44 100644 --- a/src/librustc_codegen_llvm/debuginfo/namespace.rs +++ b/src/librustc_codegen_llvm/debuginfo/namespace.rs @@ -12,7 +12,7 @@ use rustc_hir::definitions::DefPathData; pub fn mangled_name_of_instance<'a, 'tcx>( cx: &CodegenCx<'a, 'tcx>, instance: Instance<'tcx>, -) -> ty::SymbolName { +) -> ty::SymbolName<'tcx> { let tcx = cx.tcx; tcx.symbol_name(instance) } diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 153f0232f3a..c0d96366616 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -196,7 +196,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { // and/or monomorphization invalidates these assumptions. let coverageinfo = tcx.coverageinfo(caller_instance.def_id()); let mangled_fn = tcx.symbol_name(caller_instance); - let (mangled_fn_name, _len_val) = self.const_str(mangled_fn.name); + let (mangled_fn_name, _len_val) = self.const_str(mangled_fn); let hash = self.const_u64(coverageinfo.hash); let num_counters = self.const_u32(coverageinfo.num_counters); use coverage::count_code_region_args::*; |
