Skip to content

Commit b5ef517

Browse files
authored
Rollup merge of #121818 - rcvalle:rust-cfi-remove-unused-typeid-for-fnsig, r=workingjubilee
CFI: Remove unused `typeid_for_fnsig` Removes unused `typeid_for_fnsig` for simplifying the compiler CFI API.
2 parents 1a4c93e + 7e64163 commit b5ef517

File tree

2 files changed

+2
-59
lines changed

2 files changed

+2
-59
lines changed

compiler/rustc_symbol_mangling/src/typeid.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
/// For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
55
/// see design document in the tracking issue #89653.
66
use bitflags::bitflags;
7-
use rustc_middle::ty::{FnSig, Instance, Ty, TyCtxt};
7+
use rustc_middle::ty::{Instance, Ty, TyCtxt};
88
use rustc_target::abi::call::FnAbi;
99
use std::hash::Hasher;
1010
use twox_hash::XxHash64;
1111

1212
bitflags! {
13-
/// Options for typeid_for_fnabi and typeid_for_fnsig.
13+
/// Options for typeid_for_fnabi.
1414
#[derive(Clone, Copy, Debug)]
1515
pub struct TypeIdOptions: u32 {
1616
const GENERALIZE_POINTERS = 1;
@@ -30,15 +30,6 @@ pub fn typeid_for_fnabi<'tcx>(
3030
typeid_itanium_cxx_abi::typeid_for_fnabi(tcx, fn_abi, options)
3131
}
3232

33-
/// Returns a type metadata identifier for the specified FnSig.
34-
pub fn typeid_for_fnsig<'tcx>(
35-
tcx: TyCtxt<'tcx>,
36-
fn_sig: &FnSig<'tcx>,
37-
options: TypeIdOptions,
38-
) -> String {
39-
typeid_itanium_cxx_abi::typeid_for_fnsig(tcx, fn_sig, options)
40-
}
41-
4233
/// Returns a type metadata identifier for the specified Instance.
4334
pub fn typeid_for_instance<'tcx>(
4435
tcx: TyCtxt<'tcx>,
@@ -61,19 +52,6 @@ pub fn kcfi_typeid_for_fnabi<'tcx>(
6152
hash.finish() as u32
6253
}
6354

64-
/// Returns a KCFI type metadata identifier for the specified FnSig.
65-
pub fn kcfi_typeid_for_fnsig<'tcx>(
66-
tcx: TyCtxt<'tcx>,
67-
fn_sig: &FnSig<'tcx>,
68-
options: TypeIdOptions,
69-
) -> u32 {
70-
// A KCFI type metadata identifier is a 32-bit constant produced by taking the lower half of the
71-
// xxHash64 of the type metadata identifier. (See llvm/llvm-project@cff5bef.)
72-
let mut hash: XxHash64 = Default::default();
73-
hash.write(typeid_itanium_cxx_abi::typeid_for_fnsig(tcx, fn_sig, options).as_bytes());
74-
hash.finish() as u32
75-
}
76-
7755
/// Returns a KCFI type metadata identifier for the specified Instance.
7856
pub fn kcfi_typeid_for_instance<'tcx>(
7957
tcx: TyCtxt<'tcx>,

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

-35
Original file line numberDiff line numberDiff line change
@@ -1074,41 +1074,6 @@ pub fn typeid_for_fnabi<'tcx>(
10741074
typeid
10751075
}
10761076

1077-
/// Returns a type metadata identifier for the specified FnSig using the Itanium C++ ABI with vendor
1078-
/// extended type qualifiers and types for Rust types that are not used at the FFI boundary.
1079-
pub fn typeid_for_fnsig<'tcx>(
1080-
tcx: TyCtxt<'tcx>,
1081-
fn_sig: &FnSig<'tcx>,
1082-
options: TypeIdOptions,
1083-
) -> String {
1084-
// A name is mangled by prefixing "_Z" to an encoding of its name, and in the case of functions
1085-
// its type.
1086-
let mut typeid = String::from("_Z");
1087-
1088-
// Clang uses the Itanium C++ ABI's virtual tables and RTTI typeinfo structure name as type
1089-
// metadata identifiers for function pointers. The typeinfo name encoding is a two-character
1090-
// code (i.e., 'TS') prefixed to the type encoding for the function.
1091-
typeid.push_str("TS");
1092-
1093-
// A dictionary of substitution candidates used for compression (see
1094-
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression).
1095-
let mut dict: FxHashMap<DictKey<'tcx>, usize> = FxHashMap::default();
1096-
1097-
// Encode the function signature
1098-
typeid.push_str(&encode_fnsig(tcx, fn_sig, &mut dict, options));
1099-
1100-
// Add encoding suffixes
1101-
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
1102-
typeid.push_str(".normalized");
1103-
}
1104-
1105-
if options.contains(EncodeTyOptions::GENERALIZE_POINTERS) {
1106-
typeid.push_str(".generalized");
1107-
}
1108-
1109-
typeid
1110-
}
1111-
11121077
/// Returns a type metadata identifier for the specified Instance using the Itanium C++ ABI with
11131078
/// vendor extended type qualifiers and types for Rust types that are not used at the FFI boundary.
11141079
pub fn typeid_for_instance<'tcx>(

0 commit comments

Comments
 (0)