Skip to content

Commit f1bfb2b

Browse files
committed
---
yaml --- r: 64309 b: refs/heads/snap-stage3 c: 66e2857 h: refs/heads/master i: 64307: 96178a0 v: v3
1 parent 47f9695 commit f1bfb2b

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 51cb98443cfd053f3d2bdb26465fdb0c9d3a0f74
4+
refs/heads/snap-stage3: 66e2857253ff9bc8ce299398ad5bb346d64e3fc3
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/glue.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
230230
field: uint,
231231
ti: @mut tydesc_info) {
232232
let _icx = push_ctxt("lazily_emit_tydesc_glue");
233-
let llfnty = Type::glue_fn();
233+
let llfnty = Type::glue_fn(type_of::type_of(ccx, ti.ty).ptr_to());
234234

235235
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
236236
return;
@@ -323,7 +323,20 @@ pub fn call_tydesc_glue_full(bcx: block,
323323
}
324324
};
325325

326-
let llrawptr = PointerCast(bcx, v, Type::i8p());
326+
// When static type info is available, avoid casting parameter unless the
327+
// glue is using a simplified type, because the function already has the
328+
// right type. Otherwise cast to generic pointer.
329+
let llrawptr = if static_ti.is_none() || static_glue_fn.is_none() {
330+
PointerCast(bcx, v, Type::i8p())
331+
} else {
332+
let ty = static_ti.get().ty;
333+
let simpl = simplified_glue_type(ccx.tcx, field, ty);
334+
if simpl != ty {
335+
PointerCast(bcx, v, type_of(ccx, simpl).ptr_to())
336+
} else {
337+
v
338+
}
339+
};
327340

328341
let llfn = {
329342
match static_glue_fn {
@@ -709,13 +722,14 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext,
709722
// requirement since in many contexts glue is invoked indirectly and
710723
// the caller has no idea if it's dealing with something that can be
711724
// passed by value.
725+
//
726+
// llfn is expected be declared to take a parameter of the appropriate
727+
// type, so we don't need to explicitly cast the function parameter.
712728

713729
let bcx = top_scope_block(fcx, None);
714730
let lltop = bcx.llbb;
715731
let rawptr0_arg = fcx.arg_pos(0u);
716732
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
717-
let llty = type_of(ccx, t);
718-
let llrawptr0 = PointerCast(bcx, llrawptr0, llty.ptr_to());
719733
let bcx = helper(bcx, llrawptr0, t);
720734

721735
finish_fn(fcx, lltop, bcx);

branches/snap-stage3/src/librustc/middle/trans/type_.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,20 @@ impl Type {
187187
None => ()
188188
}
189189

190-
let ty = Type::glue_fn();
190+
let ty = Type::glue_fn(Type::i8p());
191191
cx.tn.associate_type("glue_fn", &ty);
192192

193193
return ty;
194194
}
195195

196-
pub fn glue_fn() -> Type {
197-
Type::func([ Type::nil().ptr_to(), Type::i8p() ],
196+
pub fn glue_fn(t: Type) -> Type {
197+
Type::func([ Type::nil().ptr_to(), t ],
198198
&Type::void())
199199
}
200200

201201
pub fn tydesc(arch: Architecture) -> Type {
202202
let mut tydesc = Type::named_struct("tydesc");
203-
let glue_fn_ty = Type::glue_fn().ptr_to();
203+
let glue_fn_ty = Type::glue_fn(Type::i8p()).ptr_to();
204204

205205
let int_ty = Type::int(arch);
206206

0 commit comments

Comments
 (0)