summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_symbol_mangling/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /compiler/rustc_symbol_mangling/src
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_symbol_mangling/src')
-rw-r--r--compiler/rustc_symbol_mangling/src/legacy.rs2
-rw-r--r--compiler/rustc_symbol_mangling/src/lib.rs9
-rw-r--r--compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs29
-rw-r--r--compiler/rustc_symbol_mangling/src/v0.rs9
4 files changed, 25 insertions, 24 deletions
diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs
index 3a3356808..2fc102bda 100644
--- a/compiler/rustc_symbol_mangling/src/legacy.rs
+++ b/compiler/rustc_symbol_mangling/src/legacy.rs
@@ -230,7 +230,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
self.write_str("[")?;
self = self.print_type(ty)?;
self.write_str("; ")?;
- if let Some(size) = size.try_to_bits(self.tcx().data_layout.pointer_size) {
+ if let Some(size) = size.try_to_target_usize(self.tcx()) {
write!(self, "{size}")?
} else if let ty::ConstKind::Param(param) = size.kind() {
self = param.print(self)?
diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs
index 74538e9f5..535a3ea2d 100644
--- a/compiler/rustc_symbol_mangling/src/lib.rs
+++ b/compiler/rustc_symbol_mangling/src/lib.rs
@@ -108,7 +108,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
use rustc_middle::query::Providers;
-use rustc_middle::ty::GenericArgsRef;
use rustc_middle::ty::{self, Instance, TyCtxt};
use rustc_session::config::SymbolManglingVersion;
@@ -144,7 +143,7 @@ fn symbol_name_provider<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty
// This closure determines the instantiating crate for instances that
// need an instantiating-crate-suffix for their symbol name, in order
// to differentiate between local copies.
- if is_generic(instance.args) {
+ if is_generic(instance, tcx) {
// For generics we might find re-usable upstream instances. If there
// is one, we rely on the symbol being instantiated locally.
instance.upstream_monomorphization(tcx).unwrap_or(LOCAL_CRATE)
@@ -246,7 +245,7 @@ fn compute_symbol_name<'tcx>(
// the ID of the instantiating crate. This avoids symbol conflicts
// in case the same instances is emitted in two crates of the same
// project.
- let avoid_cross_crate_conflicts = is_generic(args) || is_globally_shared_function;
+ let avoid_cross_crate_conflicts = is_generic(instance, tcx) || is_globally_shared_function;
let instantiating_crate = avoid_cross_crate_conflicts.then(compute_instantiating_crate);
@@ -278,6 +277,6 @@ fn compute_symbol_name<'tcx>(
symbol
}
-fn is_generic(args: GenericArgsRef<'_>) -> bool {
- args.non_erasable_generics().next().is_some()
+fn is_generic<'tcx>(instance: Instance<'tcx>, tcx: TyCtxt<'tcx>) -> bool {
+ instance.args.non_erasable_generics(tcx, instance.def_id()).next().is_some()
}
diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
index d345368d5..6ad3e7155 100644
--- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
+++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
@@ -118,7 +118,7 @@ fn encode_const<'tcx>(
// bool value false is encoded as 0 and true as 1.
match c.ty().kind() {
ty::Int(ity) => {
- let bits = c.eval_bits(tcx, ty::ParamEnv::reveal_all(), c.ty());
+ let bits = c.eval_bits(tcx, ty::ParamEnv::reveal_all());
let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
if val < 0 {
s.push('n');
@@ -126,7 +126,7 @@ fn encode_const<'tcx>(
let _ = write!(s, "{val}");
}
ty::Uint(_) => {
- let val = c.eval_bits(tcx, ty::ParamEnv::reveal_all(), c.ty());
+ let val = c.eval_bits(tcx, ty::ParamEnv::reveal_all());
let _ = write!(s, "{val}");
}
ty::Bool => {
@@ -447,7 +447,7 @@ fn encode_ty<'tcx>(
typeid.push('b');
}
- ty::Int(..) | ty::Uint(..) | ty::Float(..) => {
+ ty::Int(..) | ty::Uint(..) => {
// u<length><type-name> as vendor extended type
let mut s = String::from(match ty.kind() {
ty::Int(IntTy::I8) => "u2i8",
@@ -462,14 +462,23 @@ fn encode_ty<'tcx>(
ty::Uint(UintTy::U64) => "u3u64",
ty::Uint(UintTy::U128) => "u4u128",
ty::Uint(UintTy::Usize) => "u5usize",
- ty::Float(FloatTy::F32) => "u3f32",
- ty::Float(FloatTy::F64) => "u3f64",
- _ => "",
+ _ => bug!("encode_ty: unexpected `{:?}`", ty.kind()),
});
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
typeid.push_str(&s);
}
+ // Rust's f32 and f64 single (32-bit) and double (64-bit) precision floating-point types
+ // have IEEE-754 binary32 and binary64 floating-point layouts, respectively.
+ //
+ // (See https://rust-lang.github.io/unsafe-code-guidelines/layout/scalars.html#fixed-width-floating-point-types.)
+ ty::Float(float_ty) => {
+ typeid.push(match float_ty {
+ FloatTy::F32 => 'f',
+ FloatTy::F64 => 'd',
+ });
+ }
+
ty::Char => {
// u4char as vendor extended type
let mut s = String::from("u4char");
@@ -711,7 +720,6 @@ fn encode_ty<'tcx>(
| ty::Bound(..)
| ty::Error(..)
| ty::GeneratorWitness(..)
- | ty::GeneratorWitnessMIR(..)
| ty::Infer(..)
| ty::Placeholder(..) => {
bug!("encode_ty: unexpected `{:?}`", ty.kind());
@@ -964,12 +972,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
);
}
- ty::Bound(..)
- | ty::Error(..)
- | ty::GeneratorWitnessMIR(..)
- | ty::Infer(..)
- | ty::Param(..)
- | ty::Placeholder(..) => {
+ ty::Bound(..) | ty::Error(..) | ty::Infer(..) | ty::Param(..) | ty::Placeholder(..) => {
bug!("transform_ty: unexpected `{:?}`", ty.kind());
}
}
diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs
index da19a3ba4..82b1a772e 100644
--- a/compiler/rustc_symbol_mangling/src/v0.rs
+++ b/compiler/rustc_symbol_mangling/src/v0.rs
@@ -329,7 +329,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
// Late-bound lifetimes use indices starting at 1,
// see `BinderLevel` for more details.
- ty::ReLateBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon(_) }) => {
+ ty::ReLateBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) => {
let binder = &self.binders[self.binders.len() - 1 - debruijn.index()];
let depth = binder.lifetime_depths.start + var.as_u32();
@@ -484,8 +484,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
ty::Alias(ty::Inherent, _) => bug!("symbol_names: unexpected inherent projection"),
ty::Alias(ty::Weak, _) => bug!("symbol_names: unexpected weak projection"),
- ty::GeneratorWitness(_) => bug!("symbol_names: unexpected `GeneratorWitness`"),
- ty::GeneratorWitnessMIR(..) => bug!("symbol_names: unexpected `GeneratorWitnessMIR`"),
+ ty::GeneratorWitness(..) => bug!("symbol_names: unexpected `GeneratorWitness`"),
}
// Only cache types that do not refer to an enclosing
@@ -562,7 +561,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
fn print_const(mut self, ct: ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
// We only mangle a typed value if the const can be evaluated.
- let ct = ct.eval(self.tcx, ty::ParamEnv::reveal_all());
+ let ct = ct.normalize(self.tcx, ty::ParamEnv::reveal_all());
match ct.kind() {
ty::ConstKind::Value(_) => {}
@@ -594,7 +593,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Char => {
self = ty.print(self)?;
- let mut bits = ct.eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ty);
+ let mut bits = ct.eval_bits(self.tcx, ty::ParamEnv::reveal_all());
// Negative integer values are mangled using `n` as a "sign prefix".
if let ty::Int(ity) = ty.kind() {