mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Move vcall_visibility_metadata optimization hint out of a debuginfo generation method
This commit is contained in:
parent
5ced3dad57
commit
e9ea578147
@ -3,6 +3,7 @@ use crate::back::write::to_llvm_code_model;
|
|||||||
use crate::callee::get_fn;
|
use crate::callee::get_fn;
|
||||||
use crate::coverageinfo;
|
use crate::coverageinfo;
|
||||||
use crate::debuginfo;
|
use crate::debuginfo;
|
||||||
|
use crate::debuginfo::metadata::apply_vcall_visibility_metadata;
|
||||||
use crate::llvm;
|
use crate::llvm;
|
||||||
use crate::llvm_util;
|
use crate::llvm_util;
|
||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
@ -522,6 +523,15 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
&self.vtables
|
&self.vtables
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_vcall_visibility_metadata(
|
||||||
|
&self,
|
||||||
|
ty: Ty<'tcx>,
|
||||||
|
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||||
|
vtable: &'ll Value,
|
||||||
|
) {
|
||||||
|
apply_vcall_visibility_metadata(self, ty, poly_trait_ref, vtable);
|
||||||
|
}
|
||||||
|
|
||||||
fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
|
fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
|
||||||
get_fn(self, instance)
|
get_fn(self, instance)
|
||||||
}
|
}
|
||||||
|
@ -1449,12 +1449,18 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
|
|||||||
.di_node
|
.di_node
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vcall_visibility_metadata<'ll, 'tcx>(
|
pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
trait_ref: Option<PolyExistentialTraitRef<'tcx>>,
|
trait_ref: Option<PolyExistentialTraitRef<'tcx>>,
|
||||||
vtable: &'ll Value,
|
vtable: &'ll Value,
|
||||||
) {
|
) {
|
||||||
|
// FIXME(flip1995): The virtual function elimination optimization only works with full LTO in
|
||||||
|
// LLVM at the moment.
|
||||||
|
if !cx.sess().opts.unstable_opts.virtual_function_elimination || cx.sess().lto() != Lto::Fat {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
enum VCallVisibility {
|
enum VCallVisibility {
|
||||||
Public = 0,
|
Public = 0,
|
||||||
LinkageUnit = 1,
|
LinkageUnit = 1,
|
||||||
@ -1531,12 +1537,6 @@ pub fn create_vtable_di_node<'ll, 'tcx>(
|
|||||||
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||||
vtable: &'ll Value,
|
vtable: &'ll Value,
|
||||||
) {
|
) {
|
||||||
// FIXME(flip1995): The virtual function elimination optimization only works with full LTO in
|
|
||||||
// LLVM at the moment.
|
|
||||||
if cx.sess().opts.unstable_opts.virtual_function_elimination && cx.sess().lto() == Lto::Fat {
|
|
||||||
vcall_visibility_metadata(cx, ty, poly_trait_ref, vtable);
|
|
||||||
}
|
|
||||||
|
|
||||||
if cx.dbg_cx.is_none() {
|
if cx.dbg_cx.is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
|
|||||||
let align = cx.data_layout().pointer_align.abi;
|
let align = cx.data_layout().pointer_align.abi;
|
||||||
let vtable = cx.static_addr_of(vtable_const, align, Some("vtable"));
|
let vtable = cx.static_addr_of(vtable_const, align, Some("vtable"));
|
||||||
|
|
||||||
|
cx.apply_vcall_visibility_metadata(ty, trait_ref, vtable);
|
||||||
cx.create_vtable_debuginfo(ty, trait_ref, vtable);
|
cx.create_vtable_debuginfo(ty, trait_ref, vtable);
|
||||||
cx.vtables().borrow_mut().insert((ty, trait_ref), vtable);
|
cx.vtables().borrow_mut().insert((ty, trait_ref), vtable);
|
||||||
vtable
|
vtable
|
||||||
|
@ -9,6 +9,13 @@ pub trait MiscMethods<'tcx>: BackendTypes {
|
|||||||
fn vtables(
|
fn vtables(
|
||||||
&self,
|
&self,
|
||||||
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
|
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
|
||||||
|
fn apply_vcall_visibility_metadata(
|
||||||
|
&self,
|
||||||
|
_ty: Ty<'tcx>,
|
||||||
|
_poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||||
|
_vtable: Self::Value,
|
||||||
|
) {
|
||||||
|
}
|
||||||
fn check_overflow(&self) -> bool;
|
fn check_overflow(&self) -> bool;
|
||||||
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
|
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
|
||||||
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
|
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
|
||||||
|
Loading…
Reference in New Issue
Block a user