Skip to content

Commit 428d5ac

Browse files
committed
Revert "avoid redundant translation of items during monomorphization"
This reverts commit f97f65f. Conflicts: src/librustc/middle/trans/base.rs src/librustc/middle/trans/foreign.rs src/librustc/middle/trans/monomorphize.rs
1 parent d5a94c4 commit 428d5ac

File tree

13 files changed

+21
-80
lines changed

13 files changed

+21
-80
lines changed

src/librustc/middle/trans/base.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
13431343
output_type: ty::t,
13441344
param_substs: &'a param_substs,
13451345
sp: Option<Span>,
1346-
block_arena: &'a TypedArena<Block<'a>>,
1347-
handle_items: HandleItemsFlag)
1346+
block_arena: &'a TypedArena<Block<'a>>)
13481347
-> FunctionContext<'a> {
13491348
param_substs.validate();
13501349

@@ -1379,8 +1378,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
13791378
block_arena: block_arena,
13801379
ccx: ccx,
13811380
debug_context: debug_context,
1382-
scopes: RefCell::new(Vec::new()),
1383-
handle_items: handle_items,
1381+
scopes: RefCell::new(Vec::new())
13841382
};
13851383

13861384
if has_env {
@@ -1708,8 +1706,7 @@ pub fn trans_closure(ccx: &CrateContext,
17081706
abi: Abi,
17091707
has_env: bool,
17101708
is_unboxed_closure: IsUnboxedClosureFlag,
1711-
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>,
1712-
handle_items: HandleItemsFlag) {
1709+
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>) {
17131710
ccx.stats.n_closures.set(ccx.stats.n_closures.get() + 1);
17141711

17151712
let _icx = push_ctxt("trans_closure");
@@ -1726,8 +1723,7 @@ pub fn trans_closure(ccx: &CrateContext,
17261723
output_type,
17271724
param_substs,
17281725
Some(body.span),
1729-
&arena,
1730-
handle_items);
1726+
&arena);
17311727
let mut bcx = init_function(&fcx, false, output_type);
17321728

17331729
// cleanup scope for the incoming arguments
@@ -1836,8 +1832,7 @@ pub fn trans_fn(ccx: &CrateContext,
18361832
llfndecl: ValueRef,
18371833
param_substs: &param_substs,
18381834
id: ast::NodeId,
1839-
attrs: &[ast::Attribute],
1840-
handle_items: HandleItemsFlag) {
1835+
attrs: &[ast::Attribute]) {
18411836
let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_string(id).to_string());
18421837
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
18431838
let _icx = push_ctxt("trans_fn");
@@ -1857,8 +1852,7 @@ pub fn trans_fn(ccx: &CrateContext,
18571852
abi,
18581853
false,
18591854
NotUnboxedClosure,
1860-
|bcx| bcx,
1861-
handle_items);
1855+
|bcx| bcx);
18621856
}
18631857

18641858
pub fn trans_enum_variant(ccx: &CrateContext,
@@ -1964,7 +1958,7 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
19641958

19651959
let arena = TypedArena::new();
19661960
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
1967-
param_substs, None, &arena, TranslateItems);
1961+
param_substs, None, &arena);
19681962
let bcx = init_function(&fcx, false, result_ty);
19691963

19701964
assert!(!fcx.needs_ret_allocas);
@@ -2074,8 +2068,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
20742068
llfn,
20752069
&param_substs::empty(),
20762070
item.id,
2077-
item.attrs.as_slice(),
2078-
TranslateItems);
2071+
item.attrs.as_slice());
20792072
}
20802073
} else {
20812074
// Be sure to travel more than just one layer deep to catch nested

src/librustc/middle/trans/callee.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ pub fn trans_unboxing_shim(bcx: &Block,
339339
return_type,
340340
&empty_param_substs,
341341
None,
342-
&block_arena,
343-
TranslateItems);
342+
&block_arena);
344343
let mut bcx = init_function(&fcx, false, return_type);
345344

346345
// Create the substituted versions of the self type.

src/librustc/middle/trans/closure.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ pub fn trans_expr_fn<'a>(
394394
ty::ty_fn_abi(fty),
395395
true,
396396
NotUnboxedClosure,
397-
|bcx| load_environment(bcx, cdata_ty, &freevars, store),
398-
bcx.fcx.handle_items);
397+
|bcx| load_environment(bcx, cdata_ty, &freevars, store));
399398
fill_fn_pair(bcx, dest_addr, llfn, llbox);
400399
bcx
401400
}
@@ -487,8 +486,7 @@ pub fn trans_unboxed_closure<'a>(
487486
ty::ty_fn_abi(function_type),
488487
true,
489488
IsUnboxedClosure,
490-
|bcx| load_unboxed_closure_environment(bcx, freevars_ptr),
491-
bcx.fcx.handle_items);
489+
|bcx| load_unboxed_closure_environment(bcx, freevars_ptr));
492490

493491
// Don't hoist this to the top of the function. It's perfectly legitimate
494492
// to have a zero-size unboxed closure (in which case dest will be
@@ -575,7 +573,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
575573
let arena = TypedArena::new();
576574
let empty_param_substs = param_substs::empty();
577575
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, true, f.sig.output,
578-
&empty_param_substs, None, &arena, TranslateItems);
576+
&empty_param_substs, None, &arena);
579577
let bcx = init_function(&fcx, true, f.sig.output);
580578

581579
let args = create_datums_for_fn_args(&fcx,

src/librustc/middle/trans/common.rs

-9
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@ impl<T:Subst+Clone> SubstP for T {
224224
pub type RvalueDatum = datum::Datum<datum::Rvalue>;
225225
pub type LvalueDatum = datum::Datum<datum::Lvalue>;
226226

227-
#[deriving(Clone, Eq, PartialEq)]
228-
pub enum HandleItemsFlag {
229-
IgnoreItems,
230-
TranslateItems,
231-
}
232-
233227
// Function context. Every LLVM function we create will have one of
234228
// these.
235229
pub struct FunctionContext<'a> {
@@ -303,9 +297,6 @@ pub struct FunctionContext<'a> {
303297

304298
// Cleanup scopes.
305299
pub scopes: RefCell<Vec<cleanup::CleanupScope<'a>> >,
306-
307-
// How to handle items encountered during translation of this function.
308-
pub handle_items: HandleItemsFlag,
309300
}
310301

311302
impl<'a> FunctionContext<'a> {

src/librustc/middle/trans/controlflow.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,7 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
6969
debuginfo::create_local_var_metadata(bcx, &**local);
7070
}
7171
}
72-
ast::DeclItem(ref i) => {
73-
match fcx.handle_items {
74-
TranslateItems => trans_item(cx.fcx.ccx, &**i),
75-
IgnoreItems => {}
76-
}
77-
}
72+
ast::DeclItem(ref i) => trans_item(cx.fcx.ccx, &**i)
7873
}
7974
}
8075
ast::StmtMac(..) => cx.tcx().sess.bug("unexpanded macro")

src/librustc/middle/trans/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
630630

631631
let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
632632
base::set_llvm_fn_attrs(attrs, llfn);
633-
base::trans_fn(ccx, decl, body, llfn, param_substs, id, [], TranslateItems);
633+
base::trans_fn(ccx, decl, body, llfn, param_substs, id, []);
634634
llfn
635635
}
636636

src/librustc/middle/trans/glue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn make_generic_glue(ccx: &CrateContext,
468468
let arena = TypedArena::new();
469469
let empty_param_substs = param_substs::empty();
470470
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false, ty::mk_nil(),
471-
&empty_param_substs, None, &arena, TranslateItems);
471+
&empty_param_substs, None, &arena);
472472

473473
let bcx = init_function(&fcx, false, ty::mk_nil());
474474

src/librustc/middle/trans/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn maybe_instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
133133
if unparameterized {
134134
let llfn = get_item_val(ccx, mth.id);
135135
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), llfn,
136-
&param_substs::empty(), mth.id, [], TranslateItems);
136+
&param_substs::empty(), mth.id, []);
137137
}
138138
local_def(mth.id)
139139
}

src/librustc/middle/trans/meth.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ pub fn trans_impl(ccx: &CrateContext,
7575
llfn,
7676
&param_substs::empty(),
7777
method.id,
78-
[],
79-
TranslateItems);
78+
[]);
8079
} else {
8180
let mut v = TransItemVisitor{ ccx: ccx };
8281
visit::walk_method_helper(&mut v, &**method, ());

src/librustc/middle/trans/monomorphize.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
166166
ccx, &**decl, &**body, [], d, &psubsts, fn_id.node,
167167
Some(hash.as_slice()));
168168
} else {
169-
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, [],
170-
IgnoreItems);
169+
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, []);
171170
}
172171

173172
d
@@ -201,8 +200,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
201200
ast_map::NodeMethod(mth) => {
202201
let d = mk_lldecl(abi::Rust);
203202
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
204-
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, [],
205-
IgnoreItems);
203+
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, []);
206204
d
207205
}
208206
ast_map::NodeTraitMethod(method) => {
@@ -211,7 +209,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
211209
let d = mk_lldecl(abi::Rust);
212210
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
213211
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d,
214-
&psubsts, mth.id, [], IgnoreItems);
212+
&psubsts, mth.id, []);
215213
d
216214
}
217215
_ => {

src/librustc/middle/trans/reflect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
312312
let empty_param_substs = param_substs::empty();
313313
let fcx = new_fn_ctxt(ccx, llfdecl, ast::DUMMY_NODE_ID, false,
314314
ty::mk_u64(), &empty_param_substs,
315-
None, &arena, TranslateItems);
315+
None, &arena);
316316
let bcx = init_function(&fcx, false, ty::mk_u64());
317317

318318
// we know the return type of llfdecl is an int here, so

src/test/run-make/issue-7349/Makefile

-11
This file was deleted.

src/test/run-make/issue-7349/foo.rs

-21
This file was deleted.

0 commit comments

Comments
 (0)