Skip to content

Commit 2ad47c9

Browse files
committed
---
yaml --- r: 172392 b: refs/heads/master c: b8304e5 h: refs/heads/master v: v3
1 parent 959509d commit 2ad47c9

File tree

10 files changed

+16
-62
lines changed

10 files changed

+16
-62
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d2d35db570f0d5da1b0b829e38b495e763a0a60b
2+
refs/heads/master: b8304e540423b86bbe9789ed0088f29a61f46459
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
55
refs/heads/try: 705b92bdfe33d0d6febdf945340262514e1b3b5c

trunk/src/librustc_trans/trans/base.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,11 +1054,6 @@ pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
10541054
C_undef(type_of::type_of(cx.ccx(), t))
10551055
} else if ty::type_is_bool(t) {
10561056
Trunc(cx, LoadRangeAssert(cx, ptr, 0, 2, llvm::False), Type::i1(cx.ccx()))
1057-
} else if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
1058-
// We want to pass small aggregates as immediate values, but using an aggregate LLVM type
1059-
// for this leads to bad optimizations, so its arg type is an appropriately sized integer
1060-
// and we have to convert it
1061-
Load(cx, BitCast(cx, ptr, type_of::arg_type_of(cx.ccx(), t).ptr_to()))
10621057
} else if ty::type_is_char(t) {
10631058
// a char is a Unicode codepoint, and so takes values from 0
10641059
// to 0x10FFFF inclusive only.
@@ -1070,14 +1065,9 @@ pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
10701065

10711066
/// Helper for storing values in memory. Does the necessary conversion if the in-memory type
10721067
/// differs from the type used for SSA values.
1073-
pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t: Ty<'tcx>) {
1068+
pub fn store_ty(cx: Block, v: ValueRef, dst: ValueRef, t: Ty) {
10741069
if ty::type_is_bool(t) {
10751070
Store(cx, ZExt(cx, v, Type::i8(cx.ccx())), dst);
1076-
} else if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
1077-
// We want to pass small aggregates as immediate values, but using an aggregate LLVM type
1078-
// for this leads to bad optimizations, so its arg type is an appropriately sized integer
1079-
// and we have to convert it
1080-
Store(cx, v, BitCast(cx, dst, type_of::arg_type_of(cx.ccx(), t).ptr_to()));
10811071
} else {
10821072
Store(cx, v, dst);
10831073
};

trunk/src/librustc_trans/trans/common.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
222222
match ty.sty {
223223
ty::ty_struct(def_id, substs) => {
224224
let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
225-
fields.len() == 1 && type_is_immediate(ccx, fields[0].mt.ty)
225+
fields.len() == 1 &&
226+
fields[0].name ==
227+
token::special_idents::unnamed_field.name &&
228+
type_is_immediate(ccx, fields[0].mt.ty)
226229
}
227230
_ => false
228231
}
@@ -244,7 +247,7 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
244247
return false;
245248
}
246249
match ty.sty {
247-
ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) | ty::ty_vec(_, Some(_)) |
250+
ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) |
248251
ty::ty_unboxed_closure(..) => {
249252
let llty = sizing_type_of(ccx, ty);
250253
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())

trunk/src/librustc_trans/trans/foreign.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -736,13 +736,6 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
736736
if ty::type_is_bool(rust_ty) {
737737
let tmp = builder.load_range_assert(llforeign_arg, 0, 2, llvm::False);
738738
builder.trunc(tmp, Type::i1(ccx))
739-
} else if type_of::type_of(ccx, rust_ty).is_aggregate() {
740-
// We want to pass small aggregates as immediate values, but using an aggregate
741-
// LLVM type for this leads to bad optimizations, so its arg type is an
742-
// appropriately sized integer and we have to convert it
743-
let tmp = builder.bitcast(llforeign_arg,
744-
type_of::arg_type_of(ccx, rust_ty).ptr_to());
745-
builder.load(tmp)
746739
} else {
747740
builder.load(llforeign_arg)
748741
}
@@ -841,10 +834,10 @@ fn foreign_signature<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
841834
fn_sig: &ty::FnSig<'tcx>,
842835
arg_tys: &[Ty<'tcx>])
843836
-> LlvmSignature {
844-
let llarg_tys = arg_tys.iter().map(|&arg| foreign_arg_type_of(ccx, arg)).collect();
837+
let llarg_tys = arg_tys.iter().map(|&arg| arg_type_of(ccx, arg)).collect();
845838
let (llret_ty, ret_def) = match fn_sig.output {
846839
ty::FnConverging(ret_ty) =>
847-
(type_of::foreign_arg_type_of(ccx, ret_ty), !return_type_is_void(ccx, ret_ty)),
840+
(type_of::arg_type_of(ccx, ret_ty), !return_type_is_void(ccx, ret_ty)),
848841
ty::FnDiverging =>
849842
(Type::nil(ccx), false)
850843
};

trunk/src/librustc_trans/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub fn drop_ty_immediate<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
138138
-> Block<'blk, 'tcx> {
139139
let _icx = push_ctxt("drop_ty_immediate");
140140
let vp = alloca(bcx, type_of(bcx.ccx(), t), "");
141-
store_ty(bcx, v, vp, t);
141+
Store(bcx, v, vp);
142142
drop_ty(bcx, vp, t, source_location)
143143
}
144144

trunk/src/librustc_trans/trans/intrinsic.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
357357
&ccx.link_meta().crate_hash);
358358
// NB: This needs to be kept in lockstep with the TypeId struct in
359359
// the intrinsic module
360-
C_u64(ccx, hash)
360+
C_named_struct(llret_ty, &[C_u64(ccx, hash)])
361361
}
362362
(_, "init") => {
363363
let tp_ty = *substs.types.get(FnSpace, 0);
364-
let lltp_ty = type_of::arg_type_of(ccx, tp_ty);
364+
let lltp_ty = type_of::type_of(ccx, tp_ty);
365365
if return_type_is_void(ccx, tp_ty) {
366366
C_nil(ccx)
367367
} else {
@@ -686,11 +686,6 @@ fn with_overflow_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, name: &'static st
686686
let ret = C_undef(type_of::type_of(bcx.ccx(), t));
687687
let ret = InsertValue(bcx, ret, result, 0);
688688
let ret = InsertValue(bcx, ret, overflow, 1);
689-
if type_is_immediate(bcx.ccx(), t) {
690-
let tmp = alloc_ty(bcx, t, "tmp");
691-
Store(bcx, ret, tmp);
692-
load_ty(bcx, tmp, t)
693-
} else {
694-
ret
695-
}
689+
690+
ret
696691
}

trunk/src/librustc_trans/trans/type_.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ impl Type {
8282
ty!(llvm::LLVMInt64TypeInContext(ccx.llcx()))
8383
}
8484

85-
// Creates an integer type with the given number of bits, e.g. i24
86-
pub fn ix(ccx: &CrateContext, num_bits: u64) -> Type {
87-
ty!(llvm::LLVMIntTypeInContext(ccx.llcx(), num_bits as c_uint))
88-
}
89-
9085
pub fn f32(ccx: &CrateContext) -> Type {
9186
ty!(llvm::LLVMFloatTypeInContext(ccx.llcx()))
9287
}
@@ -265,13 +260,6 @@ impl Type {
265260
ty!(llvm::LLVMPointerType(self.to_ref(), 0))
266261
}
267262

268-
pub fn is_aggregate(&self) -> bool {
269-
match self.kind() {
270-
TypeKind::Struct | TypeKind::Array => true,
271-
_ => false
272-
}
273-
}
274-
275263
pub fn is_packed(&self) -> bool {
276264
unsafe {
277265
llvm::LLVMIsPackedStruct(self.to_ref()) == True

trunk/src/librustc_trans/trans/type_of.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,24 +243,9 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
243243
llsizingty
244244
}
245245

246-
pub fn foreign_arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
247-
if ty::type_is_bool(t) {
248-
Type::i1(cx)
249-
} else {
250-
type_of(cx, t)
251-
}
252-
}
253-
254246
pub fn arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
255247
if ty::type_is_bool(t) {
256248
Type::i1(cx)
257-
} else if type_is_immediate(cx, t) && type_of(cx, t).is_aggregate() {
258-
// We want to pass small aggregates as immediate values, but using an aggregate LLVM type
259-
// for this leads to bad optimizations, so its arg type is an appropriately sized integer
260-
match machine::llsize_of_alloc(cx, sizing_type_of(cx, t)) {
261-
0 => type_of(cx, t),
262-
n => Type::ix(cx, n * 8),
263-
}
264249
} else {
265250
type_of(cx, t)
266251
}

trunk/src/test/run-pass/unwind-unique.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ fn f() {
1919
}
2020

2121
pub fn main() {
22-
let _t = Thread::spawn(f);
22+
let _t = Thread::scoped(f);
2323
}

trunk/src/test/run-pass/weak-lang-item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern crate "weak-lang-items" as other;
1515
use std::thread::Thread;
1616

1717
fn main() {
18-
let _ = Thread::spawn(move|| {
18+
let _ = Thread::scoped(move|| {
1919
other::foo()
2020
});
2121
}

0 commit comments

Comments
 (0)