Skip to content

Commit 1be3feb

Browse files
committed
---
yaml --- r: 142527 b: refs/heads/try2 c: 41efcdf h: refs/heads/master i: 142525: 13e1816 142523: 1c75745 142519: aa50b97 142511: c7ccc1c 142495: 97c8d64 142463: 6ef3bda v: v3
1 parent 6f4517a commit 1be3feb

File tree

15 files changed

+61
-47
lines changed

15 files changed

+61
-47
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 90843b6f58a042cd1548555064a80034a608c02b
8+
refs/heads/try2: 41efcdf2996f842394277298a2f8045c432ba169
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/_match.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub fn trans_opt(bcx: block, o: &Opt) -> opt_result {
268268
}
269269
lit(UnitLikeStructLit(pat_id)) => {
270270
let struct_ty = ty::node_id_to_type(bcx.tcx(), pat_id);
271-
let datumblock = datum::scratch_datum(bcx, struct_ty, true);
271+
let datumblock = datum::scratch_datum(bcx, struct_ty, "", true);
272272
return single_result(datumblock.to_result(bcx));
273273
}
274274
lit(ConstLit(lit_id)) => {
@@ -927,7 +927,7 @@ pub fn extract_vec_elems(bcx: block,
927927
ty::mt {ty: vt.unit_ty, mutbl: ast::m_imm},
928928
ty::vstore_slice(ty::re_static)
929929
);
930-
let scratch = scratch_datum(bcx, slice_ty, false);
930+
let scratch = scratch_datum(bcx, slice_ty, "", false);
931931
Store(bcx, slice_begin,
932932
GEPi(bcx, scratch.val, [0u, abi::slice_elt_base])
933933
);
@@ -1095,9 +1095,9 @@ pub fn compare_values(cx: block,
10951095

10961096
match ty::get(rhs_t).sty {
10971097
ty::ty_estr(ty::vstore_uniq) => {
1098-
let scratch_lhs = alloca(cx, val_ty(lhs));
1098+
let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
10991099
Store(cx, lhs, scratch_lhs);
1100-
let scratch_rhs = alloca(cx, val_ty(rhs));
1100+
let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
11011101
Store(cx, rhs, scratch_rhs);
11021102
let did = cx.tcx().lang_items.uniq_str_eq_fn();
11031103
let result = callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None);
@@ -1636,12 +1636,12 @@ fn create_bindings_map(bcx: block, pat: @ast::pat) -> BindingsMap {
16361636
// in this case, the final type of the variable will be T,
16371637
// but during matching we need to store a *T as explained
16381638
// above
1639-
let is_move = ccx.maps.moves_map.contains(&p_id);
1640-
llmatch = alloca(bcx, llvariable_ty.ptr_to());
1641-
trmode = TrByValue(is_move, alloca(bcx, llvariable_ty));
1639+
llmatch = alloca(bcx, llvariable_ty.ptr_to(), "__llmatch");
1640+
trmode = TrByValue(alloca(bcx, llvariable_ty,
1641+
bcx.ident(ident)));
16421642
}
16431643
ast::bind_by_ref(_) => {
1644-
llmatch = alloca(bcx, llvariable_ty);
1644+
llmatch = alloca(bcx, llvariable_ty, bcx.ident(ident));
16451645
trmode = TrByRef;
16461646
}
16471647
};

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ pub fn get_landing_pad(bcx: block) -> BasicBlockRef {
10121012
match bcx.fcx.personality {
10131013
Some(addr) => Store(pad_bcx, llretval, addr),
10141014
None => {
1015-
let addr = alloca(pad_bcx, val_ty(llretval));
1015+
let addr = alloca(pad_bcx, val_ty(llretval), "");
10161016
bcx.fcx.personality = Some(addr);
10171017
Store(pad_bcx, llretval, addr);
10181018
}
@@ -1056,15 +1056,15 @@ pub fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef {
10561056
if ty::type_is_bot(t) {
10571057
return C_null(Type::i8p());
10581058
}
1059-
let llptr = alloc_ty(bcx, t);
1059+
let llptr = alloc_ty(bcx, t, "");
10601060
Store(bcx, v, llptr);
10611061
return llptr;
10621062
}
10631063

10641064
// Since this function does *not* root, it is the caller's responsibility to
10651065
// ensure that the referent is pointed to by a root.
10661066
pub fn do_spill_noroot(cx: block, v: ValueRef) -> ValueRef {
1067-
let llptr = alloca(cx, val_ty(v));
1067+
let llptr = alloca(cx, val_ty(v), "");
10681068
Store(cx, v, llptr);
10691069
return llptr;
10701070
}
@@ -1561,28 +1561,28 @@ pub fn memzero(cx: block, llptr: ValueRef, ty: Type) {
15611561
Call(cx, llintrinsicfn, [llptr, llzeroval, size, align, volatile]);
15621562
}
15631563

1564-
pub fn alloc_ty(bcx: block, t: ty::t) -> ValueRef {
1564+
pub fn alloc_ty(bcx: block, t: ty::t, name: &str) -> ValueRef {
15651565
let _icx = push_ctxt("alloc_ty");
15661566
let ccx = bcx.ccx();
15671567
let ty = type_of::type_of(ccx, t);
15681568
assert!(!ty::type_has_params(t), "Type has params: %s", ty_to_str(ccx.tcx, t));
1569-
let val = alloca(bcx, ty);
1569+
let val = alloca(bcx, ty, name);
15701570
return val;
15711571
}
15721572

1573-
pub fn alloca(cx: block, ty: Type) -> ValueRef {
1574-
alloca_maybe_zeroed(cx, ty, false)
1573+
pub fn alloca(cx: block, ty: Type, name: &str) -> ValueRef {
1574+
alloca_maybe_zeroed(cx, ty, name, false)
15751575
}
15761576

1577-
pub fn alloca_maybe_zeroed(cx: block, ty: Type, zero: bool) -> ValueRef {
1577+
pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> ValueRef {
15781578
let _icx = push_ctxt("alloca");
15791579
if cx.unreachable {
15801580
unsafe {
15811581
return llvm::LLVMGetUndef(ty.to_ref());
15821582
}
15831583
}
15841584
let initcx = base::raw_block(cx.fcx, false, cx.fcx.llstaticallocas);
1585-
let p = Alloca(initcx, ty);
1585+
let p = Alloca(initcx, ty, name);
15861586
if zero { memzero(initcx, p, ty); }
15871587
p
15881588
}
@@ -1623,7 +1623,8 @@ pub fn make_return_pointer(fcx: fn_ctxt, output_type: ty::t) -> ValueRef {
16231623
llvm::LLVMGetParam(fcx.llfn, 0)
16241624
} else {
16251625
let lloutputtype = type_of::type_of(fcx.ccx, output_type);
1626-
alloca(raw_block(fcx, false, fcx.llstaticallocas), lloutputtype)
1626+
alloca(raw_block(fcx, false, fcx.llstaticallocas), lloutputtype,
1627+
"__make_return_pointer")
16271628
}
16281629
}
16291630
}

branches/try2/src/librustc/middle/trans/build.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,17 @@ pub fn ArrayMalloc(cx: block, Ty: Type, Val: ValueRef) -> ValueRef {
505505
}
506506
}
507507

508-
pub fn Alloca(cx: block, Ty: Type) -> ValueRef {
508+
pub fn Alloca(cx: block, Ty: Type, name: &str) -> ValueRef {
509509
unsafe {
510510
if cx.unreachable { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
511511
count_insn(cx, "alloca");
512-
return llvm::LLVMBuildAlloca(B(cx), Ty.to_ref(), noname());
512+
if name.is_empty() {
513+
llvm::LLVMBuildAlloca(B(cx), Ty.to_ref(), noname())
514+
} else {
515+
str::as_c_str(
516+
name,
517+
|c| llvm::LLVMBuildAlloca(B(cx), Ty.to_ref(), c))
518+
}
513519
}
514520
}
515521

branches/try2/src/librustc/middle/trans/cabi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ impl FnType {
130130
j = 1u;
131131
get_param(llwrapfn, 0u)
132132
} else if self.ret_ty.cast {
133-
let retptr = alloca(bcx, self.ret_ty.ty);
133+
let retptr = alloca(bcx, self.ret_ty.ty, "");
134134
BitCast(bcx, retptr, ret_ty.ptr_to())
135135
} else {
136-
alloca(bcx, ret_ty)
136+
alloca(bcx, ret_ty, "")
137137
};
138138

139139
let mut i = 0u;

branches/try2/src/librustc/middle/trans/callee.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ pub fn trans_call_inner(in_cx: block,
600600
let mut bcx = callee.bcx;
601601
let ccx = cx.ccx();
602602
let ret_flag = if ret_in_loop {
603-
let flag = alloca(bcx, Type::bool());
603+
let flag = alloca(bcx, Type::bool(), "__ret_flag");
604604
Store(bcx, C_bool(false), flag);
605605
Some(flag)
606606
} else {
@@ -675,7 +675,7 @@ pub fn trans_call_inner(in_cx: block,
675675
unsafe {
676676
if ty::type_needs_drop(bcx.tcx(), ret_ty) {
677677
if ty::type_is_immediate(bcx.tcx(), ret_ty) {
678-
let llscratchptr = alloc_ty(bcx, ret_ty);
678+
let llscratchptr = alloc_ty(bcx, ret_ty, "__ret");
679679
Store(bcx, llresult, llscratchptr);
680680
bcx = glue::drop_ty(bcx, llscratchptr, ret_ty);
681681
} else {
@@ -733,7 +733,7 @@ pub fn trans_ret_slot(bcx: block, fn_ty: ty::t, dest: Option<expr::Dest>)
733733
llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref())
734734
}
735735
} else {
736-
alloc_ty(bcx, retty)
736+
alloc_ty(bcx, retty, "__trans_ret_slot")
737737
}
738738
}
739739
}
@@ -823,7 +823,7 @@ pub fn trans_arg_expr(bcx: block,
823823
_
824824
}) => {
825825
let scratch_ty = expr_ty(bcx, arg_expr);
826-
let scratch = alloc_ty(bcx, scratch_ty);
826+
let scratch = alloc_ty(bcx, scratch_ty, "__ret_flag");
827827
let arg_ty = expr_ty(bcx, arg_expr);
828828
let sigil = ty::ty_closure_sigil(arg_ty);
829829
let bcx = closure::trans_expr_fn(
@@ -895,7 +895,8 @@ pub fn trans_arg_expr(bcx: block,
895895
arg_datum.appropriate_mode(bcx.tcx()).is_by_ref() {
896896
debug!("by copy arg with type %s, storing to scratch",
897897
bcx.ty_to_str(arg_datum.ty));
898-
let scratch = scratch_datum(bcx, arg_datum.ty, false);
898+
let scratch = scratch_datum(bcx, arg_datum.ty,
899+
"__arg", false);
899900

900901
arg_datum.store_to_datum(bcx,
901902
arg_expr.id,

branches/try2/src/librustc/middle/trans/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
193193
}
194194
ast::BorrowedSigil => {
195195
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
196-
let llbox = alloc_ty(bcx, cbox_ty);
196+
let llbox = alloc_ty(bcx, cbox_ty, "__closure");
197197
nuke_ref_count(bcx, llbox);
198198
rslt(bcx, llbox)
199199
}

branches/try2/src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ impl block_ {
608608
pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx }
609609
pub fn sess(&self) -> Session { self.fcx.ccx.sess }
610610

611+
pub fn ident(&self, ident: ident) -> @str {
612+
token::ident_to_str(&ident)
613+
}
614+
611615
pub fn node_id_to_str(&self, id: ast::node_id) -> ~str {
612616
ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
613617
}

branches/try2/src/librustc/middle/trans/datum.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ pub fn immediate_rvalue_bcx(bcx: block,
173173
return DatumBlock {bcx: bcx, datum: immediate_rvalue(val, ty)};
174174
}
175175

176-
pub fn scratch_datum(bcx: block, ty: ty::t, zero: bool) -> Datum {
176+
pub fn scratch_datum(bcx: block, ty: ty::t, name: &str, zero: bool) -> Datum {
177177
/*!
178-
*
179178
* Allocates temporary space on the stack using alloca() and
180179
* returns a by-ref Datum pointing to it. If `zero` is true, the
181180
* space will be zeroed when it is allocated; this is normally not
182181
* necessary, but in the case of automatic rooting in match
183182
* statements it is possible to have temporaries that may not get
184183
* initialized if a certain arm is not taken, so we must zero
185-
* them. You must arrange any cleanups etc yourself! */
184+
* them. You must arrange any cleanups etc yourself!
185+
*/
186186

187187
let llty = type_of::type_of(bcx.ccx(), ty);
188-
let scratch = alloca_maybe_zeroed(bcx, llty, zero);
188+
let scratch = alloca_maybe_zeroed(bcx, llty, name, zero);
189189
Datum { val: scratch, ty: ty, mode: ByRef(RevokeClean) }
190190
}
191191

@@ -476,7 +476,7 @@ impl Datum {
476476
if ty::type_is_nil(self.ty) || ty::type_is_bot(self.ty) {
477477
C_null(type_of::type_of(bcx.ccx(), self.ty).ptr_to())
478478
} else {
479-
let slot = alloc_ty(bcx, self.ty);
479+
let slot = alloc_ty(bcx, self.ty, "");
480480
Store(bcx, self.val, slot);
481481
slot
482482
}

branches/try2/src/librustc/middle/trans/expr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
274274
ty::mt { ty: unit_ty, mutbl: ast::m_imm },
275275
ty::vstore_slice(ty::re_static));
276276

277-
let scratch = scratch_datum(bcx, slice_ty, false);
277+
let scratch = scratch_datum(bcx, slice_ty, "__adjust", false);
278278
Store(bcx, base, GEPi(bcx, scratch.val, [0u, abi::slice_elt_base]));
279279
Store(bcx, len, GEPi(bcx, scratch.val, [0u, abi::slice_elt_len]));
280280
DatumBlock {bcx: bcx, datum: scratch}
@@ -290,7 +290,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
290290
let tcx = bcx.tcx();
291291
let closure_ty = expr_ty_adjusted(bcx, expr);
292292
debug!("add_env(closure_ty=%s)", closure_ty.repr(tcx));
293-
let scratch = scratch_datum(bcx, closure_ty, false);
293+
let scratch = scratch_datum(bcx, closure_ty, "__adjust", false);
294294
let llfn = GEPi(bcx, scratch.val, [0u, abi::fn_field_code]);
295295
assert_eq!(datum.appropriate_mode(tcx), ByValue);
296296
Store(bcx, datum.to_appropriate_llval(bcx), llfn);
@@ -423,7 +423,7 @@ fn trans_to_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
423423
bcx = trans_rvalue_dps_unadjusted(bcx, expr, Ignore);
424424
return nil(bcx, ty);
425425
} else {
426-
let scratch = scratch_datum(bcx, ty, false);
426+
let scratch = scratch_datum(bcx, ty, "", false);
427427
bcx = trans_rvalue_dps_unadjusted(
428428
bcx, expr, SaveIn(scratch.val));
429429

@@ -1687,7 +1687,7 @@ fn trans_assign_op(bcx: block,
16871687
// A user-defined operator method
16881688
if bcx.ccx().maps.method_map.find(&expr.id).is_some() {
16891689
// FIXME(#2528) evaluates the receiver twice!!
1690-
let scratch = scratch_datum(bcx, dst_datum.ty, false);
1690+
let scratch = scratch_datum(bcx, dst_datum.ty, "__assign_op", false);
16911691
let bcx = trans_overloaded_op(bcx,
16921692
expr,
16931693
callee_id,

branches/try2/src/librustc/middle/trans/foreign.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,15 @@ fn build_wrap_fn_(ccx: @mut CrateContext,
195195
if needs_c_return && !ty::type_is_immediate(ccx.tcx, tys.fn_sig.output) {
196196
let lloutputtype = type_of::type_of(fcx.ccx, tys.fn_sig.output);
197197
fcx.llretptr = Some(alloca(raw_block(fcx, false, fcx.llstaticallocas),
198-
lloutputtype));
198+
lloutputtype,
199+
""));
199200
}
200201

201202
let bcx = top_scope_block(fcx, None);
202203
let lltop = bcx.llbb;
203204

204205
// Allocate the struct and write the arguments into it.
205-
let llargbundle = alloca(bcx, tys.bundle_ty);
206+
let llargbundle = alloca(bcx, tys.bundle_ty, "__llargbundle");
206207
arg_builder(bcx, tys, llwrapfn, llargbundle);
207208

208209
// Create call itself.
@@ -732,7 +733,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
732733

733734
let llsrcval = get_param(decl, first_real_arg);
734735
let llsrcptr = if ty::type_is_immediate(ccx.tcx, in_type) {
735-
let llsrcptr = alloca(bcx, llintype);
736+
let llsrcptr = alloca(bcx, llintype, "__llsrcptr");
736737
Store(bcx, llsrcval, llsrcptr);
737738
llsrcptr
738739
} else {

branches/try2/src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn free_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
132132
ty::ty_evec(_, ty::vstore_box) |
133133
ty::ty_estr(ty::vstore_box) |
134134
ty::ty_opaque_closure_ptr(_) => {
135-
let vp = alloca(bcx, type_of(bcx.ccx(), t));
135+
let vp = alloca(bcx, type_of(bcx.ccx(), t), "");
136136
Store(bcx, v, vp);
137137
free_ty(bcx, vp, t)
138138
}

branches/try2/src/librustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Reflector {
5757
let bcx = self.bcx;
5858
let str_vstore = ty::vstore_slice(ty::re_static);
5959
let str_ty = ty::mk_estr(bcx.tcx(), str_vstore);
60-
let scratch = scratch_datum(bcx, str_ty, false);
60+
let scratch = scratch_datum(bcx, str_ty, "", false);
6161
let len = C_uint(bcx.ccx(), s.len() + 1);
6262
let c_str = PointerCast(bcx, C_cstr(bcx.ccx(), s), Type::i8p());
6363
Store(bcx, c_str, GEPi(bcx, scratch.val, [ 0, 0 ]));

branches/try2/src/librustc/middle/trans/tvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: block, heap: heap, vstore_expr: @ast::e
332332
let llptrval = PointerCast(bcx, llptrval, Type::i8p());
333333
let llsizeval = C_uint(bcx.ccx(), s.len());
334334
let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq);
335-
let lldestval = scratch_datum(bcx, typ, false);
335+
let lldestval = scratch_datum(bcx, typ, "", false);
336336
let bcx = callee::trans_lang_call(
337337
bcx,
338338
bcx.tcx().lang_items.strdup_uniq_fn(),
@@ -454,7 +454,7 @@ pub fn write_content(bcx: block,
454454

455455
let loop_counter = {
456456
// i = 0
457-
let i = alloca(loop_bcx, bcx.ccx().int_type);
457+
let i = alloca(loop_bcx, bcx.ccx().int_type, "__i");
458458
Store(loop_bcx, C_uint(bcx.ccx(), 0), i);
459459

460460
Br(loop_bcx, cond_bcx.llbb);

branches/try2/src/librustc/middle/trans/write_guard.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn root(datum: &Datum,
120120
// First, root the datum. Note that we must zero this value,
121121
// because sometimes we root on one path but not another.
122122
// See e.g. #4904.
123-
let scratch = scratch_datum(bcx, datum.ty, true);
123+
let scratch = scratch_datum(bcx, datum.ty, "__write_guard", true);
124124
datum.copy_to_datum(bcx, INIT, scratch);
125125
let cleanup_bcx = find_bcx_for_scope(bcx, root_info.scope);
126126
add_clean_temp_mem_in_scope(cleanup_bcx, root_info.scope, scratch.val, scratch.ty);
@@ -135,7 +135,8 @@ fn root(datum: &Datum,
135135
// scratch.val will be NULL should the cleanup get
136136
// called without the freezing actually occurring, and
137137
// return_to_mut checks for this condition.
138-
let scratch_bits = scratch_datum(bcx, ty::mk_uint(), false);
138+
let scratch_bits = scratch_datum(bcx, ty::mk_uint(),
139+
"__write_guard_bits", false);
139140

140141
let freeze_did = match freeze_kind {
141142
DynaImm => bcx.tcx().lang_items.borrow_as_imm_fn(),

0 commit comments

Comments
 (0)