aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-02 16:23:14 -0800
committerPatrick Walton <[email protected]>2011-03-02 16:23:14 -0800
commit21e42ad88a388d2178770fe2ee046c4f30148da9 (patch)
treee15f8c2e9fee61e288776e22807d0b5ab889c514 /src
parentrustc: Don't have type_of_arg() rely on the particular lie told by type_of() (diff)
downloadrust-21e42ad88a388d2178770fe2ee046c4f30148da9.tar.xz
rust-21e42ad88a388d2178770fe2ee046c4f30148da9.zip
rustc: For derived tydescs, explicitly store 0 for size and align when the type in question has a dynamic size
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 45f59841..2258ee18 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1201,7 +1201,19 @@ fn make_tydesc(@crate_ctxt cx, @ty.t t, vec[ast.def_id] typaram_defs) {
auto dg = make_drop_glue;
auto drop_glue = make_generic_glue(cx, t, "drop", dg, typaram_defs);
- auto llty = type_of(cx, t);
+ auto llsize;
+ auto llalign;
+ if (!ty.type_has_dynamic_size(t)) {
+ auto llty = type_of(cx, t);
+ llsize = llsize_of(llty);
+ llalign = llalign_of(llty);
+ } else {
+ // These will be overwritten as the derived tydesc is generated, so
+ // we create placeholder values.
+ llsize = C_int(0);
+ llalign = C_int(0);
+ }
+
auto glue_fn_ty = T_ptr(T_glue_fn(cx.tn));
// FIXME: this adjustment has to do with the ridiculous encoding of
@@ -1218,8 +1230,8 @@ fn make_tydesc(@crate_ctxt cx, @ty.t t, vec[ast.def_id] typaram_defs) {
auto gvar = llvm.LLVMAddGlobal(cx.llmod, T_tydesc(cx.tn),
_str.buf(name));
auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(cx.tn)))),
- llsize_of(llty),
- llalign_of(llty),
+ llsize,
+ llalign,
off(gvar, take_glue), // take_glue_off
off(gvar, drop_glue), // drop_glue_off
C_null(glue_fn_ty), // free_glue_off