mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Merge typeid_metadata into type_checked_load
This allows removing the Metadata associated type from BackendTypes.
This commit is contained in:
@@ -486,7 +486,6 @@ fn deref<'b>(&'b self) -> &'a Self::Target {
|
||||
|
||||
impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> {
|
||||
type Value = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Value;
|
||||
type Metadata = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Metadata;
|
||||
type Function = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Function;
|
||||
type BasicBlock = <CodegenCx<'gcc, 'tcx> as BackendTypes>::BasicBlock;
|
||||
type Type = <CodegenCx<'gcc, 'tcx> as BackendTypes>::Type;
|
||||
|
||||
@@ -381,7 +381,6 @@ pub fn bitcast_if_needed(
|
||||
|
||||
impl<'gcc, 'tcx> BackendTypes for CodegenCx<'gcc, 'tcx> {
|
||||
type Value = RValue<'gcc>;
|
||||
type Metadata = RValue<'gcc>;
|
||||
type Function = Function<'gcc>;
|
||||
|
||||
type BasicBlock = Block<'gcc>;
|
||||
|
||||
@@ -712,7 +712,7 @@ fn type_checked_load(
|
||||
&mut self,
|
||||
_vtable: Self::Value,
|
||||
_vtable_byte_offset: u64,
|
||||
_typeid: Self::Value,
|
||||
_typeid: &[u8],
|
||||
) -> Self::Value {
|
||||
// Unsupported.
|
||||
self.context.new_rvalue_from_int(self.int_type, 0)
|
||||
|
||||
@@ -197,7 +197,6 @@ pub(crate) fn load(&mut self, ty: &'ll Type, ptr: &'ll Value, align: Align) -> &
|
||||
|
||||
impl<'ll, CX: Borrow<SCx<'ll>>> BackendTypes for GenericBuilder<'_, 'll, CX> {
|
||||
type Value = <GenericCx<'ll, CX> as BackendTypes>::Value;
|
||||
type Metadata = <GenericCx<'ll, CX> as BackendTypes>::Metadata;
|
||||
type Function = <GenericCx<'ll, CX> as BackendTypes>::Function;
|
||||
type BasicBlock = <GenericCx<'ll, CX> as BackendTypes>::BasicBlock;
|
||||
type Type = <GenericCx<'ll, CX> as BackendTypes>::Type;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
use crate::consts::const_alloc_to_llvm;
|
||||
pub(crate) use crate::context::CodegenCx;
|
||||
use crate::context::{GenericCx, SCx};
|
||||
use crate::llvm::{self, BasicBlock, ConstantInt, FALSE, Metadata, TRUE, ToLlvmBool, Type, Value};
|
||||
use crate::llvm::{self, BasicBlock, ConstantInt, FALSE, TRUE, ToLlvmBool, Type, Value};
|
||||
|
||||
/*
|
||||
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
|
||||
@@ -83,7 +83,6 @@ pub(crate) fn bundle(&self) -> &llvm::OperandBundle<'ll> {
|
||||
|
||||
impl<'ll, CX: Borrow<SCx<'ll>>> BackendTypes for GenericCx<'ll, CX> {
|
||||
type Value = &'ll Value;
|
||||
type Metadata = &'ll Metadata;
|
||||
// FIXME(eddyb) replace this with a `Function` "subclass" of `Value`.
|
||||
type Function = &'ll Value;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
use crate::errors::{
|
||||
AutoDiffWithoutEnable, AutoDiffWithoutLto, OffloadWithoutEnable, OffloadWithoutFatLTO,
|
||||
};
|
||||
use crate::llvm::{self, Metadata, Type, Value};
|
||||
use crate::llvm::{self, Type, Value};
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::va_arg::emit_va_arg;
|
||||
|
||||
@@ -799,8 +799,9 @@ fn type_checked_load(
|
||||
&mut self,
|
||||
llvtable: &'ll Value,
|
||||
vtable_byte_offset: u64,
|
||||
typeid: &'ll Metadata,
|
||||
typeid: &[u8],
|
||||
) -> Self::Value {
|
||||
let typeid = self.create_metadata(typeid);
|
||||
let typeid = self.get_metadata_value(typeid);
|
||||
let vtable_byte_offset = self.const_i32(vtable_byte_offset as i32);
|
||||
let type_checked_load = self.call_intrinsic(
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
use crate::abi::{FnAbiLlvmExt, LlvmType};
|
||||
use crate::common;
|
||||
use crate::context::{CodegenCx, GenericCx, SCx};
|
||||
use crate::llvm::{self, FALSE, Metadata, TRUE, ToGeneric, ToLlvmBool, Type, Value};
|
||||
use crate::llvm::{self, FALSE, TRUE, ToGeneric, ToLlvmBool, Type, Value};
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
|
||||
impl PartialEq for Type {
|
||||
@@ -319,10 +319,6 @@ fn set_type_metadata(&self, function: &'ll Value, typeid: &[u8]) {
|
||||
self.global_set_metadata_node(function, llvm::MD_type, &v);
|
||||
}
|
||||
|
||||
fn typeid_metadata(&self, typeid: &[u8]) -> Option<&'ll Metadata> {
|
||||
Some(self.create_metadata(typeid))
|
||||
}
|
||||
|
||||
fn add_kcfi_type_metadata(&self, function: &'ll Value, kcfi_typeid: u32) {
|
||||
let kcfi_type_metadata = [llvm::LLVMValueAsMetadata(self.const_u32(kcfi_typeid))];
|
||||
self.global_add_metadata_node(function, llvm::MD_kcfi_type, &kcfi_type_metadata);
|
||||
|
||||
@@ -139,9 +139,8 @@ pub(crate) fn load_vtable<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
&& bx.cx().sess().lto() == Lto::Fat
|
||||
{
|
||||
if let Some(trait_ref) = dyn_trait_in_self(bx.tcx(), ty) {
|
||||
let typeid =
|
||||
bx.typeid_metadata(typeid_for_trait_ref(bx.tcx(), trait_ref).as_bytes()).unwrap();
|
||||
let func = bx.type_checked_load(llvtable, vtable_byte_offset, typeid);
|
||||
let typeid = typeid_for_trait_ref(bx.tcx(), trait_ref);
|
||||
let func = bx.type_checked_load(llvtable, vtable_byte_offset, typeid.as_bytes());
|
||||
return func;
|
||||
} else if nonnull {
|
||||
bug!("load nonnull value from a vtable without a principal trait")
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
pub trait BackendTypes {
|
||||
type Value: CodegenObject + PartialEq;
|
||||
type Metadata: CodegenObject;
|
||||
type Function: CodegenObject;
|
||||
|
||||
type BasicBlock: Copy;
|
||||
|
||||
@@ -50,7 +50,6 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||
type CodegenCx: CodegenMethods<
|
||||
'tcx,
|
||||
Value = Self::Value,
|
||||
Metadata = Self::Metadata,
|
||||
Function = Self::Function,
|
||||
BasicBlock = Self::BasicBlock,
|
||||
Type = Self::Type,
|
||||
|
||||
@@ -41,7 +41,7 @@ fn type_checked_load(
|
||||
&mut self,
|
||||
llvtable: Self::Value,
|
||||
vtable_byte_offset: u64,
|
||||
typeid: Self::Metadata,
|
||||
typeid: &[u8],
|
||||
) -> Self::Value;
|
||||
/// Trait method used to inject `va_start` on the "spoofed" `VaList` in
|
||||
/// Rust defined C-variadic functions.
|
||||
|
||||
@@ -156,9 +156,6 @@ fn is_backend_ref(&self, layout: TyAndLayout<'tcx>) -> bool {
|
||||
pub trait TypeMembershipCodegenMethods<'tcx>: BackendTypes {
|
||||
fn add_type_metadata(&self, _function: Self::Function, _typeid: &[u8]) {}
|
||||
fn set_type_metadata(&self, _function: Self::Function, _typeid: &[u8]) {}
|
||||
fn typeid_metadata(&self, _typeid: &[u8]) -> Option<Self::Metadata> {
|
||||
None
|
||||
}
|
||||
fn add_kcfi_type_metadata(&self, _function: Self::Function, _typeid: u32) {}
|
||||
fn set_kcfi_type_metadata(&self, _function: Self::Function, _typeid: u32) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user