Skip to content

Commit ab7e7f3

Browse files
committed
---
yaml --- r: 228850 b: refs/heads/try c: a0f3f2a h: refs/heads/master v: v3
1 parent c6e944d commit ab7e7f3

File tree

8 files changed

+214
-32
lines changed

8 files changed

+214
-32
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: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 20aa27b7bca3504f6a7672cc88e17a9c286cec4b
4+
refs/heads/try: a0f3f2ac53690ee049d9c5387dafd46411320a4f
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl MatchInput {
437437
fn from_val(val: ValueRef) -> MatchInput {
438438
MatchInput {
439439
val: val,
440-
lval: Lvalue,
440+
lval: Lvalue::new("MatchInput::from_val"),
441441
}
442442
}
443443

@@ -941,30 +941,41 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
941941
cs: Option<cleanup::ScopeId>)
942942
-> Block<'blk, 'tcx> {
943943
for (&ident, &binding_info) in bindings_map {
944-
let llval = match binding_info.trmode {
944+
let (llval, aliases_other_state) = match binding_info.trmode {
945945
// By value mut binding for a copy type: load from the ptr
946946
// into the matched value and copy to our alloca
947947
TrByCopy(llbinding) |
948948
TrByMoveIntoCopy(llbinding) => {
949949
let llval = Load(bcx, binding_info.llmatch);
950-
let datum = Datum::new(llval, binding_info.ty, Lvalue);
950+
let lval = match binding_info.trmode {
951+
TrByCopy(..) =>
952+
Lvalue::new("_match::insert_lllocals"),
953+
TrByMoveIntoCopy(..) =>
954+
Lvalue::match_input("_match::insert_lllocals", bcx, binding_info.id),
955+
_ => unreachable!(),
956+
};
957+
let datum = Datum::new(llval, binding_info.ty, lval);
951958
call_lifetime_start(bcx, llbinding);
952959
bcx = datum.store_to(bcx, llbinding);
953960
if let Some(cs) = cs {
954961
bcx.fcx.schedule_lifetime_end(cs, llbinding);
955962
}
956963

957-
llbinding
964+
(llbinding, false)
958965
},
959966

960967
// By value move bindings: load from the ptr into the matched value
961-
TrByMoveRef => Load(bcx, binding_info.llmatch),
968+
TrByMoveRef => (Load(bcx, binding_info.llmatch), true),
962969

963970
// By ref binding: use the ptr into the matched value
964-
TrByRef => binding_info.llmatch
971+
TrByRef => (binding_info.llmatch, true),
965972
};
966973

967-
let datum = Datum::new(llval, binding_info.ty, Lvalue);
974+
let lval = Lvalue::local("_match::insert_lllocals",
975+
bcx,
976+
binding_info.id,
977+
aliases_other_state);
978+
let datum = Datum::new(llval, binding_info.ty, lval);
968979
if let Some(cs) = cs {
969980
bcx.fcx.schedule_lifetime_end(cs, binding_info.llmatch);
970981
bcx.fcx.schedule_drop_and_fill_mem(cs, llval, binding_info.ty);
@@ -1619,6 +1630,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16191630
let scope = cleanup::var_scope(tcx, p_id);
16201631
bcx = mk_binding_alloca(
16211632
bcx, p_id, path1.node.name, scope, (),
1633+
"_match::store_local::create_dummy_locals",
16221634
|(), bcx, llval, ty| { drop_done_fill_mem(bcx, llval, ty); bcx });
16231635
});
16241636
bcx
@@ -1641,6 +1653,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16411653
let var_scope = cleanup::var_scope(tcx, local.id);
16421654
return mk_binding_alloca(
16431655
bcx, pat.id, ident.name, var_scope, (),
1656+
"_match::store_local",
16441657
|(), bcx, v, _| expr::trans_into(bcx, &**init_expr,
16451658
expr::SaveIn(v)));
16461659
}
@@ -1668,6 +1681,7 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
16681681
name: ast::Name,
16691682
cleanup_scope: cleanup::ScopeId,
16701683
arg: A,
1684+
caller_name: &'static str,
16711685
populate: F)
16721686
-> Block<'blk, 'tcx> where
16731687
F: FnOnce(A, Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
@@ -1685,7 +1699,8 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
16851699

16861700
// Now that memory is initialized and has cleanup scheduled,
16871701
// create the datum and insert into the local variable map.
1688-
let datum = Datum::new(llval, var_ty, Lvalue);
1702+
let lval = Lvalue::binding(caller_name, bcx, p_id, name);
1703+
let datum = Datum::new(llval, var_ty, lval);
16891704
bcx.fcx.lllocals.borrow_mut().insert(p_id, datum);
16901705
bcx
16911706
}
@@ -1730,6 +1745,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17301745
// map.
17311746
bcx = mk_binding_alloca(
17321747
bcx, pat.id, path1.node.name, cleanup_scope, (),
1748+
"_match::bind_irrefutable_pat",
17331749
|(), bcx, llval, ty| {
17341750
match pat_binding_mode {
17351751
ast::BindByValue(_) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
10831083
));
10841084
bcx = fold_variants(bcx, r, val, |variant_cx, st, value| {
10851085
let ptr = struct_field_ptr(variant_cx, st, value, (st.fields.len() - 1), false);
1086-
datum::Datum::new(ptr, ptr_ty, datum::Lvalue)
1086+
datum::Datum::new(ptr, ptr_ty, datum::Lvalue::new("adt::trans_drop_flag_ptr"))
10871087
.store_to(variant_cx, scratch.val)
10881088
});
10891089
let expr_datum = scratch.to_expr_datum();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use trans::cleanup;
5656
use trans::closure;
5757
use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_int, C_integral};
5858
use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_undef};
59-
use trans::common::{CrateContext, FunctionContext};
59+
use trans::common::{CrateContext, DropFlagHintsMap, FunctionContext};
6060
use trans::common::{Result, NodeIdAndSpan};
6161
use trans::common::{node_id_type, return_type_is_void};
6262
use trans::common::{type_is_immediate, type_is_zero_size, val_ty};
@@ -1235,6 +1235,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
12351235
caller_expects_out_pointer: uses_outptr,
12361236
lllocals: RefCell::new(NodeMap()),
12371237
llupvars: RefCell::new(NodeMap()),
1238+
lldropflag_hints: RefCell::new(DropFlagHintsMap::new()),
12381239
id: id,
12391240
param_substs: param_substs,
12401241
span: sp,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ use trans::base;
124124
use trans::build;
125125
use trans::common;
126126
use trans::common::{Block, FunctionContext, NodeIdAndSpan};
127+
use trans::datum::{Datum, Lvalue};
127128
use trans::debuginfo::{DebugLoc, ToDebugLoc};
128129
use trans::glue;
129130
use middle::region;
@@ -212,6 +213,12 @@ pub enum ScopeId {
212213
CustomScope(CustomScopeIndex)
213214
}
214215

216+
#[derive(Copy, Clone, Debug)]
217+
pub struct DropHint<K>(pub ast::NodeId, pub K);
218+
219+
pub type DropHintDatum<'tcx> = DropHint<Datum<'tcx, Lvalue>>;
220+
pub type DropHintValue = DropHint<ValueRef>;
221+
215222
impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
216223
/// Invoked when we start to trans the code contained within a new cleanup scope.
217224
fn push_ast_cleanup_scope(&self, debug_loc: NodeIdAndSpan) {

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,27 @@ pub fn validate_substs(substs: &Substs) {
299299
type RvalueDatum<'tcx> = datum::Datum<'tcx, datum::Rvalue>;
300300
pub type LvalueDatum<'tcx> = datum::Datum<'tcx, datum::Lvalue>;
301301

302+
#[derive(Clone, Debug)]
303+
struct HintEntry<'tcx> {
304+
// The datum for the dropflag-hint itself; note that many
305+
// source-level Lvalues will be associated with the same
306+
// dropflag-hint datum.
307+
datum: cleanup::DropHintDatum<'tcx>,
308+
}
309+
310+
pub struct DropFlagHintsMap<'tcx> {
311+
// Maps NodeId for expressions that read/write unfragmented state
312+
// to that state's drop-flag "hint." (A stack-local hint
313+
// indicates either that (1.) it is certain that no-drop is
314+
// needed, or (2.) inline drop-flag must be consulted.)
315+
node_map: NodeMap<HintEntry<'tcx>>,
316+
}
317+
318+
impl<'tcx> DropFlagHintsMap<'tcx> {
319+
pub fn new() -> DropFlagHintsMap<'tcx> { DropFlagHintsMap { node_map: NodeMap() } }
320+
pub fn has_hint(&self, id: ast::NodeId) -> bool { self.node_map.contains_key(&id) }
321+
}
322+
302323
// Function context. Every LLVM function we create will have one of
303324
// these.
304325
pub struct FunctionContext<'a, 'tcx: 'a> {
@@ -349,6 +370,10 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
349370
// Same as above, but for closure upvars
350371
pub llupvars: RefCell<NodeMap<ValueRef>>,
351372

373+
// Carries info about drop-flags for local bindings (longer term,
374+
// paths) for the code being compiled.
375+
pub lldropflag_hints: RefCell<DropFlagHintsMap<'tcx>>,
376+
352377
// The NodeId of the function, or -1 if it doesn't correspond to
353378
// a user-defined function.
354379
pub id: ast::NodeId,

0 commit comments

Comments
 (0)