Skip to content

fix performance regression from invalid IR #8724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 2 additions & 67 deletions src/librustc/middle/trans/monomorphize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ use middle::trans::type_of;
use middle::trans::type_use;
use middle::trans::intrinsic;
use middle::ty;
use middle::ty::{FnSig};
use middle::typeck;
use util::ppaux::{Repr,ty_to_str};

use syntax::ast;
use syntax::ast_map;
use syntax::ast_map::path_name;
use syntax::ast_util::local_def;
use syntax::opt_vec;
use syntax::abi::AbiSet;

pub fn monomorphic_fn(ccx: @mut CrateContext,
fn_id: ast::def_id,
Expand All @@ -61,17 +58,10 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
let _icx = push_ctxt("monomorphic_fn");
let mut must_cast = false;

let do_normalize = |t: &ty::t| {
match normalize_for_monomorphization(ccx.tcx, *t) {
Some(t) => { must_cast = true; t }
None => *t
}
};

let psubsts = @param_substs {
tys: real_substs.tps.map(|x| do_normalize(x)),
tys: real_substs.tps.to_owned(),
vtables: vtables,
self_ty: real_substs.self_ty.map(|x| do_normalize(x)),
self_ty: real_substs.self_ty.clone(),
self_vtables: self_vtables
};

Expand Down Expand Up @@ -305,61 +295,6 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
(lldecl, must_cast)
}

pub fn normalize_for_monomorphization(tcx: ty::ctxt,
ty: ty::t) -> Option<ty::t> {
// FIXME[mono] could do this recursively. is that worthwhile? (#2529)
return match ty::get(ty).sty {
ty::ty_box(*) => {
Some(ty::mk_opaque_box(tcx))
}
ty::ty_bare_fn(_) => {
Some(ty::mk_bare_fn(
tcx,
ty::BareFnTy {
purity: ast::impure_fn,
abis: AbiSet::Rust(),
sig: FnSig {bound_lifetime_names: opt_vec::Empty,
inputs: ~[],
output: ty::mk_nil()}}))
}
ty::ty_closure(ref fty) => {
Some(normalized_closure_ty(tcx, fty.sigil))
}
ty::ty_trait(_, _, ref store, _, _) => {
let sigil = match *store {
ty::UniqTraitStore => ast::OwnedSigil,
ty::BoxTraitStore => ast::ManagedSigil,
ty::RegionTraitStore(_) => ast::BorrowedSigil,
};

// Traits have the same runtime representation as closures.
Some(normalized_closure_ty(tcx, sigil))
}
ty::ty_ptr(_) => {
Some(ty::mk_uint())
}
_ => {
None
}
};

fn normalized_closure_ty(tcx: ty::ctxt,
sigil: ast::Sigil) -> ty::t
{
ty::mk_closure(
tcx,
ty::ClosureTy {
purity: ast::impure_fn,
sigil: sigil,
onceness: ast::Many,
region: ty::re_static,
bounds: ty::EmptyBuiltinBounds(),
sig: ty::FnSig {bound_lifetime_names: opt_vec::Empty,
inputs: ~[],
output: ty::mk_nil()}})
}
}

pub fn make_mono_id(ccx: @mut CrateContext,
item: ast::def_id,
substs: &param_substs,
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ fn test_repr() {
exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\"");

exact_test(&(@10), "@10");
exact_test(&(@mut 10), "@10"); // FIXME: #4210: incorrect
exact_test(&(@mut 10), "@mut 10");
exact_test(&((@mut 10, 2)), "(@mut 10, 2)");
exact_test(&(~10), "~10");
exact_test(&(&10), "&10");
Expand Down