rustc: Use the abbreviated type names to avoid LLVM bitcode size explosion

This commit is contained in:
Patrick Walton 2011-04-25 16:59:49 -07:00
parent da328b1ba9
commit c4e13cd1fa
3 changed files with 11 additions and 5 deletions

View File

@ -45,9 +45,8 @@ const uint tag_index_table = 0x15u;
// Type encoding
// Compact string representation for ty.t values. API ty_str & parse_from_str.
// (The second has to be authed pure.) Extra parameters are for converting
// to/from def_ids in the string rep. Whatever format you choose should not
// contain pipe characters.
// Extra parameters are for converting to/from def_ids in the string rep.
// Whatever format you choose should not contain pipe characters.
mod Encode {

View File

@ -786,7 +786,8 @@ fn type_of_inner(@crate_ctxt cx, ty.t t) -> TypeRef {
}
check (llty as int != 0);
llvm.LLVMAddTypeName(cx.llmod, _str.buf(ty.ty_to_str(cx.tcx, t)), llty);
llvm.LLVMAddTypeName(cx.llmod, _str.buf(ty.ty_to_abbrev_str(cx.tcx, t)),
llty);
cx.lltypes.insert(t, llty);
ret llty;
}
@ -1645,7 +1646,7 @@ fn declare_tydesc(@local_ctxt cx, ty.t t) {
auto glue_fn_ty = T_ptr(T_glue_fn(ccx.tn));
auto name = sanitize(ccx.names.next("tydesc_" +
ty.ty_to_str(cx.ccx.tcx, t)));
ty.ty_to_abbrev_str(cx.ccx.tcx, t)));
auto gvar = llvm.LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn),
_str.buf(name));
auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))),

View File

@ -627,6 +627,12 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
ret s;
}
fn ty_to_abbrev_str(ctxt cx, t typ) -> str {
auto f = def_to_str;
auto ecx = @rec(ds=f, tcx=cx);
ret metadata.Encode.ty_str(ecx, typ);
}
// Type folds
type ty_walk = fn(t);