From c4e13cd1fa451327a756efc0c23bbbdbb9e7e1ae Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 25 Apr 2011 16:59:49 -0700 Subject: rustc: Use the abbreviated type names to avoid LLVM bitcode size explosion --- src/comp/middle/metadata.rs | 5 ++--- src/comp/middle/trans.rs | 5 +++-- src/comp/middle/ty.rs | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs index fee92395..bd1d5253 100644 --- a/src/comp/middle/metadata.rs +++ b/src/comp/middle/metadata.rs @@ -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 { diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 8d8c9926..b7896ba4 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -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)))), diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 194dcf44..ca461bc4 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -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); -- cgit v1.2.3