Skip to content

Commit 7f642f3

Browse files
committed
rustc: Give glue symbols meaningful names
Instead of `glue_drop1234` it's `Type::<hash>::glue_drop1234` Haven't done any performance testing.
1 parent 4bbbae6 commit 7f642f3

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/librustc/back/link.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,17 @@ pub fn mangle_internal_name_by_type_only(ccx: @CrateContext,
721721
path_name(ccx.sess.ident_of(hash))]);
722722
}
723723

724+
pub fn mangle_internal_name_by_type_and_seq(ccx: @CrateContext,
725+
t: ty::t,
726+
name: &str) -> ~str {
727+
let s = ppaux::ty_to_str(ccx.tcx, t);
728+
let hash = get_symbol_hash(ccx, t);
729+
return mangle(ccx.sess,
730+
~[path_name(ccx.sess.ident_of(s)),
731+
path_name(ccx.sess.ident_of(hash)),
732+
path_name((ccx.names)(name))]);
733+
}
734+
724735
pub fn mangle_internal_name_by_path_and_seq(ccx: @CrateContext,
725736
path: path,
726737
flav: &str) -> ~str {

src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
669669
let llsize = llsize_of(ccx, llty);
670670
let llalign = llalign_of(ccx, llty);
671671
let addrspace = declare_tydesc_addrspace(ccx, t);
672-
// FIXME #6574: this triggers duplicate LLVM symbols
673-
let name = @(if false /*ccx.sess.opts.debuginfo*/ {
674-
mangle_internal_name_by_type_only(ccx, t, "tydesc")
675-
} else {
676-
mangle_internal_name_by_seq(ccx, "tydesc")
677-
});
672+
let name = @mangle_internal_name_by_type_and_seq(ccx, t, "tydesc");
678673
note_unique_llvm_symbol(ccx, name);
679674
debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), *name);
680675
let gvar = str::as_c_str(*name, |buf| {
@@ -703,12 +698,7 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
703698
name: ~str) -> ValueRef {
704699
let _icx = ccx.insn_ctxt("declare_generic_glue");
705700
let name = name;
706-
// FIXME #6574 this triggers duplicate LLVM symbols
707-
let fn_nm = @(if false /*ccx.sess.opts.debuginfo*/ {
708-
mangle_internal_name_by_type_only(ccx, t, (~"glue_" + name))
709-
} else {
710-
mangle_internal_name_by_seq(ccx, (~"glue_" + name))
711-
});
701+
let fn_nm = @mangle_internal_name_by_type_and_seq(ccx, t, (~"glue_" + name));
712702
debug!("%s is for type %s", *fn_nm, ppaux::ty_to_str(ccx.tcx, t));
713703
note_unique_llvm_symbol(ccx, fn_nm);
714704
let llfn = decl_cdecl_fn(ccx.llmod, *fn_nm, llfnty);

0 commit comments

Comments
 (0)