rustc_trans: don't do on-demand drop glue instantiation.

This commit is contained in:
Eduard Burtescu 2016-09-19 04:26:38 +03:00
parent a2726f4a54
commit 4ac30013c3
4 changed files with 5 additions and 18 deletions

View File

@ -216,30 +216,14 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
g: DropGlueKind<'tcx>) -> ValueRef {
let g = g.map_ty(|t| get_drop_glue_type(ccx.tcx(), t));
match ccx.drop_glues().borrow().get(&g) {
Some(&(glue, _)) => return glue,
Some(&(glue, _)) => glue,
None => {
debug!("Could not find drop glue for {:?} -- {} -- {}. \
Falling back to on-demand instantiation.",
bug!("Could not find drop glue for {:?} -- {} -- {}.",
g,
TransItem::DropGlue(g).to_raw_string(),
ccx.codegen_unit().name());
}
}
// FIXME: #34151
// Normally, getting here would indicate a bug in trans::collector,
// since it seems to have missed a translation item. When we are
// translating with non-MIR-based trans, however, the results of the
// collector are not entirely reliable since it bases its analysis
// on MIR. Thus, we'll instantiate the missing function on demand in
// this codegen unit, so that things keep working.
TransItem::DropGlue(g).predefine(ccx, llvm::InternalLinkage);
TransItem::DropGlue(g).define(ccx);
// Now that we made sure that the glue function is in ccx.drop_glues,
// give it another try
get_drop_glue_core(ccx, g)
}
pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,

View File

@ -31,6 +31,7 @@ impl<T> Trait for Struct<T> {
fn main() {
let s1 = Struct { _a: 0u32 };
//~ TRANS_ITEM drop-glue i8
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::foo[0]<u32>
//~ TRANS_ITEM fn instantiation_through_vtable::{{impl}}[0]::bar[0]<u32>
let _ = &s1 as &Trait;

View File

@ -57,6 +57,7 @@ fn main()
{
// simple case
let bool_sized = &true;
//~ TRANS_ITEM drop-glue i8
//~ TRANS_ITEM fn unsizing::{{impl}}[0]::foo[0]
let _bool_unsized = bool_sized as &Trait;

View File

@ -69,6 +69,7 @@ mod mod1 {
//~ TRANS_ITEM fn vtable_through_const::main[0] @@ vtable_through_const[External]
fn main() {
//~ TRANS_ITEM drop-glue i8 @@ vtable_through_const[Internal]
// Since Trait1::do_something() is instantiated via its default implementation,
// it is considered a generic and is instantiated here only because it is