Skip to content
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

rustc: Give glue symbols meaningful names #6706

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
rustc: Give glue symbols meaningful names
Instead of `glue_drop1234` it's `Type::<hash>::glue_drop1234`

Haven't done any performance testing.
  • Loading branch information
brson committed May 24, 2013
commit 7f642f3d85c8c9886983cbabadedf4a2dbbd6fc6
11 changes: 11 additions & 0 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,17 @@ pub fn mangle_internal_name_by_type_only(ccx: @CrateContext,
path_name(ccx.sess.ident_of(hash))]);
}

pub fn mangle_internal_name_by_type_and_seq(ccx: @CrateContext,
t: ty::t,
name: &str) -> ~str {
let s = ppaux::ty_to_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
return mangle(ccx.sess,
~[path_name(ccx.sess.ident_of(s)),
path_name(ccx.sess.ident_of(hash)),
path_name((ccx.names)(name))]);
}

pub fn mangle_internal_name_by_path_and_seq(ccx: @CrateContext,
path: path,
flav: &str) -> ~str {
Expand Down
14 changes: 2 additions & 12 deletions src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
let llsize = llsize_of(ccx, llty);
let llalign = llalign_of(ccx, llty);
let addrspace = declare_tydesc_addrspace(ccx, t);
// FIXME #6574: this triggers duplicate LLVM symbols
let name = @(if false /*ccx.sess.opts.debuginfo*/ {
mangle_internal_name_by_type_only(ccx, t, "tydesc")
} else {
mangle_internal_name_by_seq(ccx, "tydesc")
});
let name = @mangle_internal_name_by_type_and_seq(ccx, t, "tydesc");
note_unique_llvm_symbol(ccx, name);
debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), *name);
let gvar = str::as_c_str(*name, |buf| {
Expand Down Expand Up @@ -703,12 +698,7 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
name: ~str) -> ValueRef {
let _icx = ccx.insn_ctxt("declare_generic_glue");
let name = name;
// FIXME #6574 this triggers duplicate LLVM symbols
let fn_nm = @(if false /*ccx.sess.opts.debuginfo*/ {
mangle_internal_name_by_type_only(ccx, t, (~"glue_" + name))
} else {
mangle_internal_name_by_seq(ccx, (~"glue_" + name))
});
let fn_nm = @mangle_internal_name_by_type_and_seq(ccx, t, (~"glue_" + name));
debug!("%s is for type %s", *fn_nm, ppaux::ty_to_str(ccx.tcx, t));
note_unique_llvm_symbol(ccx, fn_nm);
let llfn = decl_cdecl_fn(ccx.llmod, *fn_nm, llfnty);
Expand Down