mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-07 13:25:45 +00:00
Undo the const_str
changes from the previous commit.
This commit is contained in:
parent
7c4d431c06
commit
a1b8540390
@ -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_middle::ty::SymbolName;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Pointer, Size};
|
||||
|
||||
use libc::{c_char, c_uint};
|
||||
@ -105,16 +105,17 @@ impl CodegenCx<'ll, 'tcx> {
|
||||
bytes_in_context(self.llcx, bytes)
|
||||
}
|
||||
|
||||
fn const_cstr(&self, s: SymbolName<'tcx>, null_terminated: bool) -> &'ll Value {
|
||||
fn const_cstr(&self, s: Symbol, 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.name.as_ptr() as *const c_char,
|
||||
s.name.len() as c_uint,
|
||||
s_str.as_ptr() as *const c_char,
|
||||
s_str.len() as c_uint,
|
||||
!null_terminated as Bool,
|
||||
);
|
||||
let sym = self.generate_local_symbol_name("str");
|
||||
@ -201,8 +202,8 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
unsafe { llvm::LLVMConstReal(t, val) }
|
||||
}
|
||||
|
||||
fn const_str(&self, s: SymbolName<'tcx>) -> (&'ll Value, &'ll Value) {
|
||||
let len = s.name.len();
|
||||
fn const_str(&self, s: Symbol) -> (&'ll Value, &'ll Value) {
|
||||
let len = s.as_str().len();
|
||||
let cs = consts::ptrcast(
|
||||
self.const_cstr(s, false),
|
||||
self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)),
|
||||
|
@ -16,10 +16,11 @@ 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, SymbolName, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Instance, 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};
|
||||
|
||||
@ -46,7 +47,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<SymbolName<'tcx>, &'ll Value>>,
|
||||
pub const_cstr_cache: RefCell<FxHashMap<Symbol, &'ll Value>>,
|
||||
|
||||
/// Reverse-direction for const ptrs cast from globals.
|
||||
///
|
||||
|
@ -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);
|
||||
let (mangled_fn_name, _len_val) = self.const_str(Symbol::intern(mangled_fn.name));
|
||||
let hash = self.const_u64(coverageinfo.hash);
|
||||
let num_counters = self.const_u32(coverageinfo.num_counters);
|
||||
use coverage::count_code_region_args::*;
|
||||
|
@ -16,7 +16,7 @@ use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{AllocId, ConstValue, Pointer, Scalar};
|
||||
use rustc_middle::mir::AssertKind;
|
||||
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
|
||||
use rustc_middle::ty::{self, Instance, SymbolName, Ty, TypeFoldable};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::{sym, Symbol};
|
||||
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
|
||||
@ -423,7 +423,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
(lang_items::PanicBoundsCheckFnLangItem, vec![index, len, location])
|
||||
}
|
||||
_ => {
|
||||
let msg = bx.const_str(SymbolName::new(bx.tcx(), msg.description()));
|
||||
let msg_str = Symbol::intern(msg.description());
|
||||
let msg = bx.const_str(msg_str);
|
||||
// It's `pub fn panic(expr: &str)`, with the wide reference being passed
|
||||
// as two arguments, and `#[track_caller]` adds an implicit third argument.
|
||||
(lang_items::PanicFnLangItem, vec![msg.0, msg.1, location])
|
||||
@ -486,7 +487,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
} else {
|
||||
format!("attempted to leave type `{}` uninitialized, which is invalid", ty)
|
||||
};
|
||||
let msg = bx.const_str(SymbolName::new(bx.tcx(), &msg_str));
|
||||
let msg = bx.const_str(Symbol::intern(&msg_str));
|
||||
let location = self.get_caller_location(bx, span).immediate();
|
||||
|
||||
// Obtain the panic entry point.
|
||||
|
@ -2,7 +2,7 @@ use super::BackendTypes;
|
||||
use crate::mir::place::PlaceRef;
|
||||
use rustc_middle::mir::interpret::{Allocation, Scalar};
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::SymbolName;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_target::abi::{self, Size};
|
||||
|
||||
pub trait ConstMethods<'tcx>: BackendTypes {
|
||||
@ -20,7 +20,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
|
||||
fn const_u8(&self, i: u8) -> Self::Value;
|
||||
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
|
||||
|
||||
fn const_str(&self, s: SymbolName<'tcx>) -> (Self::Value, Self::Value);
|
||||
fn const_str(&self, s: Symbol) -> (Self::Value, Self::Value);
|
||||
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
|
||||
|
||||
fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
|
||||
|
Loading…
Reference in New Issue
Block a user