Skip to content

Commit b1a9e4f

Browse files
committed
---
yaml --- r: 232762 b: refs/heads/try c: 4ff44ff h: refs/heads/master v: v3
1 parent dd319dc commit b1a9e4f

File tree

15 files changed

+89
-80
lines changed

15 files changed

+89
-80
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: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: abfa081c10c9401c8a2f858497fbac583bae234d
4+
refs/heads/try: 4ff44ff8faabb7e0545dfefa96b0d601f0f17b94
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/libcore/marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub trait Sized {
4545
}
4646

4747
/// Types that can be "unsized" to a dynamically sized type.
48-
#[unstable(feature = "unsize", issue = "27732")]
48+
#[unstable(feature = "unsize", issue = "27779")]
4949
#[lang="unsize"]
5050
pub trait Unsize<T: ?Sized> {
5151
// Empty.

branches/try/src/liblibc/lib.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,6 +3920,8 @@ pub mod consts {
39203920
pub const _SC_XBS5_ILP32_OFFBIG : c_int = 126;
39213921
pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 128;
39223922

3923+
pub const _PC_NAME_MAX: c_int = 3;
3924+
pub const _PC_PATH_MAX: c_int = 4;
39233925
}
39243926
#[cfg(target_os = "nacl")]
39253927
pub mod sysconf {
@@ -3928,6 +3930,9 @@ pub mod consts {
39283930
pub static _SC_SENDMSG_MAX_SIZE : c_int = 0;
39293931
pub static _SC_NPROCESSORS_ONLN : c_int = 1;
39303932
pub static _SC_PAGESIZE : c_int = 2;
3933+
3934+
pub const _PC_NAME_MAX: c_int = 3;
3935+
pub const _PC_PATH_MAX: c_int = 4;
39313936
}
39323937

39333938
#[cfg(target_os = "android")]
@@ -3963,6 +3968,9 @@ pub mod consts {
39633968
pub const _SC_STREAM_MAX : c_int = 27;
39643969
pub const _SC_TZNAME_MAX : c_int = 28;
39653970
pub const _SC_PAGESIZE : c_int = 39;
3971+
3972+
pub const _PC_NAME_MAX: c_int = 4;
3973+
pub const _PC_PATH_MAX: c_int = 5;
39663974
}
39673975
}
39683976

@@ -4433,6 +4441,9 @@ pub mod consts {
44334441
pub const _SC_SEM_VALUE_MAX : c_int = 50;
44344442
pub const _SC_SIGQUEUE_MAX : c_int = 51;
44354443
pub const _SC_TIMER_MAX : c_int = 52;
4444+
4445+
pub const _PC_NAME_MAX: c_int = 4;
4446+
pub const _PC_PATH_MAX: c_int = 5;
44364447
}
44374448
}
44384449

@@ -4868,6 +4879,9 @@ pub mod consts {
48684879
pub const _SC_SYNCHRONIZED_IO : c_int = 75;
48694880
pub const _SC_TIMER_MAX : c_int = 93;
48704881
pub const _SC_TIMERS : c_int = 94;
4882+
4883+
pub const _PC_NAME_MAX: c_int = 4;
4884+
pub const _PC_PATH_MAX: c_int = 5;
48714885
}
48724886
}
48734887

@@ -5379,6 +5393,9 @@ pub mod consts {
53795393
pub const _SC_TRACE_SYS_MAX : c_int = 129;
53805394
pub const _SC_TRACE_USER_EVENT_MAX : c_int = 130;
53815395
pub const _SC_PASS_MAX : c_int = 131;
5396+
5397+
pub const _PC_NAME_MAX: c_int = 4;
5398+
pub const _PC_PATH_MAX: c_int = 5;
53825399
}
53835400
}
53845401
}
@@ -5835,8 +5852,6 @@ pub mod funcs {
58355852
use types::os::arch::posix88::{gid_t, off_t, pid_t};
58365853
use types::os::arch::posix88::{ssize_t, uid_t};
58375854

5838-
pub const _PC_NAME_MAX: c_int = 4;
5839-
58405855
#[cfg(not(target_os = "nacl"))]
58415856
extern {
58425857
pub fn access(path: *const c_char, amode: c_int) -> c_int;

branches/try/src/librustc_trans/trans/_match.rs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -875,17 +875,19 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
875875
debug_loc: DebugLoc)
876876
-> Result<'blk, 'tcx> {
877877
fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
878-
lhs_data: ValueRef,
879-
lhs_len: ValueRef,
880-
rhs_data: ValueRef,
881-
rhs_len: ValueRef,
878+
lhs: ValueRef,
879+
rhs: ValueRef,
882880
rhs_t: Ty<'tcx>,
883881
debug_loc: DebugLoc)
884882
-> Result<'blk, 'tcx> {
885883
let did = langcall(cx,
886884
None,
887885
&format!("comparison of `{}`", rhs_t),
888886
StrEqFnLangItem);
887+
let lhs_data = Load(cx, expr::get_dataptr(cx, lhs));
888+
let lhs_len = Load(cx, expr::get_meta(cx, lhs));
889+
let rhs_data = Load(cx, expr::get_dataptr(cx, rhs));
890+
let rhs_len = Load(cx, expr::get_meta(cx, rhs));
889891
callee::trans_lang_call(cx, did, &[lhs_data, lhs_len, rhs_data, rhs_len], None, debug_loc)
890892
}
891893

@@ -897,38 +899,32 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
897899

898900
match rhs_t.sty {
899901
ty::TyRef(_, mt) => match mt.ty.sty {
900-
ty::TyStr => {
901-
let lhs_data = Load(cx, expr::get_dataptr(cx, lhs));
902-
let lhs_len = Load(cx, expr::get_meta(cx, lhs));
903-
let rhs_data = Load(cx, expr::get_dataptr(cx, rhs));
904-
let rhs_len = Load(cx, expr::get_meta(cx, rhs));
905-
compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
906-
}
902+
ty::TyStr => compare_str(cx, lhs, rhs, rhs_t, debug_loc),
907903
ty::TyArray(ty, _) | ty::TySlice(ty) => match ty.sty {
908904
ty::TyUint(ast::TyU8) => {
909905
// NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
910906
// which calls memcmp().
911907
let pat_len = val_ty(rhs).element_type().array_length();
912908
let ty_str_slice = cx.tcx().mk_static_str();
913909

914-
let rhs_data = GEPi(cx, rhs, &[0, 0]);
915-
let rhs_len = C_uint(cx.ccx(), pat_len);
910+
let rhs_str = alloc_ty(cx, ty_str_slice, "rhs_str");
911+
Store(cx, expr::get_dataptr(cx, rhs), expr::get_dataptr(cx, rhs_str));
912+
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, rhs_str));
916913

917-
let lhs_data;
918-
let lhs_len;
914+
let lhs_str;
919915
if val_ty(lhs) == val_ty(rhs) {
920916
// Both the discriminant and the pattern are thin pointers
921-
lhs_data = GEPi(cx, lhs, &[0, 0]);
922-
lhs_len = C_uint(cx.ccx(), pat_len);
923-
} else {
917+
lhs_str = alloc_ty(cx, ty_str_slice, "lhs_str");
918+
Store(cx, expr::get_dataptr(cx, lhs), expr::get_dataptr(cx, lhs_str));
919+
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, lhs_str));
920+
}
921+
else {
924922
// The discriminant is a fat pointer
925923
let llty_str_slice = type_of::type_of(cx.ccx(), ty_str_slice).ptr_to();
926-
let lhs_str = PointerCast(cx, lhs, llty_str_slice);
927-
lhs_data = Load(cx, expr::get_dataptr(cx, lhs_str));
928-
lhs_len = Load(cx, expr::get_meta(cx, lhs_str));
924+
lhs_str = PointerCast(cx, lhs, llty_str_slice);
929925
}
930926

931-
compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
927+
compare_str(cx, lhs_str, rhs_str, rhs_t, debug_loc)
932928
},
933929
_ => cx.sess().bug("only byte strings supported in compare_values"),
934930
},
@@ -1196,7 +1192,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
11961192
let unsized_ty = def.struct_variant().fields.last().map(|field| {
11971193
monomorphize::field_ty(bcx.tcx(), substs, field)
11981194
}).unwrap();
1199-
let scratch = alloc_ty(bcx, unsized_ty, "__struct_field_fat_ptr");
1195+
let llty = type_of::type_of(bcx.ccx(), unsized_ty);
1196+
let scratch = alloca_no_lifetime(bcx, llty, "__struct_field_fat_ptr");
12001197
let data = adt::trans_field_ptr(bcx, &*repr, struct_val, 0, arg_count);
12011198
let len = Load(bcx, expr::get_meta(bcx, val.val));
12021199
Store(bcx, data, expr::get_dataptr(bcx, scratch));
@@ -1523,8 +1520,12 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
15231520
match bm {
15241521
ast::BindByValue(_) if !moves_by_default || reassigned =>
15251522
{
1526-
llmatch = alloca(bcx, llvariable_ty.ptr_to(), "__llmatch");
1527-
let llcopy = alloca(bcx, llvariable_ty, &bcx.name(name));
1523+
llmatch = alloca_no_lifetime(bcx,
1524+
llvariable_ty.ptr_to(),
1525+
"__llmatch");
1526+
let llcopy = alloca_no_lifetime(bcx,
1527+
llvariable_ty,
1528+
&bcx.name(name));
15281529
trmode = if moves_by_default {
15291530
TrByMoveIntoCopy(llcopy)
15301531
} else {
@@ -1535,11 +1536,15 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
15351536
// in this case, the final type of the variable will be T,
15361537
// but during matching we need to store a *T as explained
15371538
// above
1538-
llmatch = alloca(bcx, llvariable_ty.ptr_to(), &bcx.name(name));
1539+
llmatch = alloca_no_lifetime(bcx,
1540+
llvariable_ty.ptr_to(),
1541+
&bcx.name(name));
15391542
trmode = TrByMoveRef;
15401543
}
15411544
ast::BindByRef(_) => {
1542-
llmatch = alloca(bcx, llvariable_ty, &bcx.name(name));
1545+
llmatch = alloca_no_lifetime(bcx,
1546+
llvariable_ty,
1547+
&bcx.name(name));
15431548
trmode = TrByRef;
15441549
}
15451550
};
@@ -1740,7 +1745,6 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
17401745

17411746
// Subtle: be sure that we *populate* the memory *before*
17421747
// we schedule the cleanup.
1743-
call_lifetime_start(bcx, llval);
17441748
let bcx = populate(arg, bcx, datum);
17451749
bcx.fcx.schedule_lifetime_end(cleanup_scope, llval);
17461750
bcx.fcx.schedule_drop_mem(cleanup_scope, llval, var_ty, lvalue.dropflag_hint(bcx));

branches/try/src/librustc_trans/trans/base.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,17 @@ pub fn alloc_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, name: &str) ->
10201020
let ccx = bcx.ccx();
10211021
let ty = type_of::type_of(ccx, t);
10221022
assert!(!t.has_param_types());
1023-
alloca(bcx, ty, name)
1023+
let val = alloca(bcx, ty, name);
1024+
return val;
10241025
}
10251026

10261027
pub fn alloca(cx: Block, ty: Type, name: &str) -> ValueRef {
1028+
let p = alloca_no_lifetime(cx, ty, name);
1029+
call_lifetime_start(cx, p);
1030+
p
1031+
}
1032+
1033+
pub fn alloca_no_lifetime(cx: Block, ty: Type, name: &str) -> ValueRef {
10271034
let _icx = push_ctxt("alloca");
10281035
if cx.unreachable.get() {
10291036
unsafe {
@@ -1735,9 +1742,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
17351742
expr::SaveIn(d) => d,
17361743
expr::Ignore => {
17371744
if !type_is_zero_size(ccx, result_ty) {
1738-
let llresult = alloc_ty(bcx, result_ty, "constructor_result");
1739-
call_lifetime_start(bcx, llresult);
1740-
llresult
1745+
alloc_ty(bcx, result_ty, "constructor_result")
17411746
} else {
17421747
C_undef(type_of::type_of(ccx, result_ty).ptr_to())
17431748
}

branches/try/src/librustc_trans/trans/callee.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
725725
let llty = type_of::type_of(ccx, ret_ty);
726726
Some(common::C_undef(llty.ptr_to()))
727727
} else {
728-
let llresult = alloc_ty(bcx, ret_ty, "__llret");
729-
call_lifetime_start(bcx, llresult);
730-
Some(llresult)
728+
Some(alloc_ty(bcx, ret_ty, "__llret"))
731729
}
732730
} else {
733731
None

branches/try/src/librustc_trans/trans/cleanup.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,8 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
730730
let prev_bcx = self.new_block(true, "resume", None);
731731
let personality = self.personality.get().expect(
732732
"create_landing_pad() should have set this");
733-
let lp = build::Load(prev_bcx, personality);
734-
base::call_lifetime_end(prev_bcx, personality);
735-
build::Resume(prev_bcx, lp);
733+
build::Resume(prev_bcx,
734+
build::Load(prev_bcx, personality));
736735
prev_llbb = prev_bcx.llbb;
737736
break;
738737
}
@@ -884,7 +883,6 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
884883
}
885884
None => {
886885
let addr = base::alloca(pad_bcx, common::val_ty(llretval), "");
887-
base::call_lifetime_start(pad_bcx, addr);
888886
self.personality.set(Some(addr));
889887
build::Store(pad_bcx, llretval, addr);
890888
}

branches/try/src/librustc_trans/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
504504
output: ty::FnOutput<'tcx>,
505505
name: &str) -> ValueRef {
506506
if self.needs_ret_allocas {
507-
base::alloca(bcx, match output {
507+
base::alloca_no_lifetime(bcx, match output {
508508
ty::FnConverging(output_type) => type_of::type_of(bcx.ccx(), output_type),
509509
ty::FnDiverging => Type::void(bcx.ccx())
510510
}, name)

branches/try/src/librustc_trans/trans/datum.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ use trans::cleanup;
101101
use trans::cleanup::{CleanupMethods, DropHintDatum, DropHintMethods};
102102
use trans::expr;
103103
use trans::tvec;
104+
use trans::type_of;
104105
use middle::ty::Ty;
105106

106107
use std::fmt;
@@ -301,10 +302,12 @@ pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
301302
-> DatumBlock<'blk, 'tcx, Lvalue> where
302303
F: FnOnce(A, Block<'blk, 'tcx>, ValueRef) -> Block<'blk, 'tcx>,
303304
{
304-
let scratch = alloc_ty(bcx, ty, name);
305+
let llty = type_of::type_of(bcx.ccx(), ty);
306+
let scratch = alloca(bcx, llty, name);
305307

306308
// Subtle. Populate the scratch memory *before* scheduling cleanup.
307309
let bcx = populate(arg, bcx, scratch);
310+
bcx.fcx.schedule_lifetime_end(scope, scratch);
308311
bcx.fcx.schedule_drop_mem(scope, scratch, ty, None);
309312

310313
DatumBlock::new(bcx, Datum::new(scratch, ty, Lvalue::new("datum::lvalue_scratch_datum")))
@@ -319,8 +322,8 @@ pub fn rvalue_scratch_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
319322
ty: Ty<'tcx>,
320323
name: &str)
321324
-> Datum<'tcx, Rvalue> {
322-
let scratch = alloc_ty(bcx, ty, name);
323-
call_lifetime_start(bcx, scratch);
325+
let llty = type_of::type_of(bcx.ccx(), ty);
326+
let scratch = alloca(bcx, llty, name);
324327
Datum::new(scratch, ty, Rvalue::new(ByRef))
325328
}
326329

@@ -497,12 +500,7 @@ impl<'tcx> Datum<'tcx, Rvalue> {
497500
ByValue => {
498501
lvalue_scratch_datum(
499502
bcx, self.ty, name, scope, self,
500-
|this, bcx, llval| {
501-
call_lifetime_start(bcx, llval);
502-
let bcx = this.store_to(bcx, llval);
503-
bcx.fcx.schedule_lifetime_end(scope, llval);
504-
bcx
505-
})
503+
|this, bcx, llval| this.store_to(bcx, llval))
506504
}
507505
}
508506
}

branches/try/src/librustc_trans/trans/expr.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
246246
// Maybe just get the value directly, instead of loading it?
247247
immediate_rvalue(load_ty(bcx, global, const_ty), const_ty)
248248
} else {
249-
let scratch = alloc_ty(bcx, const_ty, "const");
250-
call_lifetime_start(bcx, scratch);
249+
let llty = type_of::type_of(bcx.ccx(), const_ty);
250+
// HACK(eddyb) get around issues with lifetime intrinsics.
251+
let scratch = alloca_no_lifetime(bcx, llty, "const");
251252
let lldest = if !const_ty.is_structural() {
252253
// Cast pointer to slot, because constants have different types.
253254
PointerCast(bcx, scratch, val_ty(global))
@@ -402,9 +403,10 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
402403
datum.to_rvalue_datum(bcx, "__coerce_source"));
403404

404405
let target = bcx.monomorphize(&target);
406+
let llty = type_of::type_of(bcx.ccx(), target);
405407

406-
let scratch = alloc_ty(bcx, target, "__coerce_target");
407-
call_lifetime_start(bcx, scratch);
408+
// HACK(eddyb) get around issues with lifetime intrinsics.
409+
let scratch = alloca_no_lifetime(bcx, llty, "__coerce_target");
408410
let target_datum = Datum::new(scratch, target,
409411
Rvalue::new(ByRef));
410412
bcx = coerce_unsized(bcx, expr.span, source_datum, target_datum);
@@ -1438,11 +1440,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
14381440
// temporary stack slot
14391441
let addr = match dest {
14401442
SaveIn(pos) => pos,
1441-
Ignore => {
1442-
let llresult = alloc_ty(bcx, ty, "temp");
1443-
call_lifetime_start(bcx, llresult);
1444-
llresult
1445-
}
1443+
Ignore => alloc_ty(bcx, ty, "temp"),
14461444
};
14471445

14481446
// This scope holds intermediates that must be cleaned should

branches/try/src/librustc_trans/trans/foreign.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
296296
// Ensure that we always have the Rust value indirectly,
297297
// because it makes bitcasting easier.
298298
if !rust_indirect {
299-
let scratch = base::alloc_ty(bcx, passed_arg_tys[i], "__arg");
299+
let scratch =
300+
base::alloca(bcx,
301+
type_of::type_of(ccx, passed_arg_tys[i]),
302+
"__arg");
300303
if type_is_fat_ptr(ccx.tcx(), passed_arg_tys[i]) {
301304
Store(bcx, llargs_rust[i + offset], expr::get_dataptr(bcx, scratch));
302305
Store(bcx, llargs_rust[i + offset + 1], expr::get_meta(bcx, scratch));
@@ -429,7 +432,6 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
429432
// - Truncating foreign type to correct integral type and then
430433
// bitcasting to the struct type yields invalid cast errors.
431434
let llscratch = base::alloca(bcx, llforeign_ret_ty, "__cast");
432-
base::call_lifetime_start(bcx, llscratch);
433435
Store(bcx, llforeign_retval, llscratch);
434436
let llscratch_i8 = BitCast(bcx, llscratch, Type::i8(ccx).ptr_to());
435437
let llretptr_i8 = BitCast(bcx, llretptr, Type::i8(ccx).ptr_to());
@@ -440,7 +442,6 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
440442
debug!("llrust_size={}", llrust_size);
441443
base::call_memcpy(bcx, llretptr_i8, llscratch_i8,
442444
C_uint(ccx, llrust_size), llalign as u32);
443-
base::call_lifetime_end(bcx, llscratch);
444445
}
445446
}
446447

0 commit comments

Comments
 (0)