Skip to content

Commit d5a94c4

Browse files
committed
Revert "don't translate items when monomorphizing foreign-ABI functions"
This reverts commit 0c158b4.
1 parent 4bb4a43 commit d5a94c4

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

src/librustc/middle/trans/base.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2066,8 +2066,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
20662066
llfn,
20672067
&param_substs::empty(),
20682068
item.id,
2069-
None,
2070-
TranslateItems);
2069+
None);
20712070
} else {
20722071
trans_fn(ccx,
20732072
&**decl,

src/librustc/middle/trans/foreign.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
577577
llwrapfn: ValueRef,
578578
param_substs: &param_substs,
579579
id: ast::NodeId,
580-
hash: Option<&str>,
581-
handle_items: HandleItemsFlag) {
580+
hash: Option<&str>) {
582581
let _icx = push_ctxt("foreign::build_foreign_fn");
583582

584583
let fnty = ty::node_id_to_type(ccx.tcx(), id);
@@ -587,8 +586,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
587586

588587
unsafe { // unsafe because we call LLVM operations
589588
// Build up the Rust function (`foo0` above).
590-
let llrustfn = build_rust_fn(ccx, decl, body, param_substs, attrs, id,
591-
hash, handle_items);
589+
let llrustfn = build_rust_fn(ccx, decl, body, param_substs, attrs, id, hash);
592590

593591
// Build up the foreign wrapper (`foo` above).
594592
return build_wrap_fn(ccx, llrustfn, llwrapfn, &tys, mty);
@@ -600,8 +598,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
600598
param_substs: &param_substs,
601599
attrs: &[ast::Attribute],
602600
id: ast::NodeId,
603-
hash: Option<&str>,
604-
handle_items: HandleItemsFlag)
601+
hash: Option<&str>)
605602
-> ValueRef {
606603
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
607604
let tcx = ccx.tcx();
@@ -633,7 +630,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
633630

634631
let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
635632
base::set_llvm_fn_attrs(attrs, llfn);
636-
base::trans_fn(ccx, decl, body, llfn, param_substs, id, [], handle_items);
633+
base::trans_fn(ccx, decl, body, llfn, param_substs, id, [], TranslateItems);
637634
llfn
638635
}
639636

src/librustc/middle/trans/monomorphize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
164164
if abi != abi::Rust {
165165
foreign::trans_rust_fn_with_foreign_abi(
166166
ccx, &**decl, &**body, [], d, &psubsts, fn_id.node,
167-
Some(hash.as_slice()), IgnoreItems);
167+
Some(hash.as_slice()));
168168
} else {
169169
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, [],
170170
IgnoreItems);

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# Test to make sure that inner functions within a polymorphic outer function
44
# don't get re-translated when the outer function is monomorphized. The test
5-
# code monomorphizes the outer functions several times, but the magic constants
6-
# used in the inner functions should each appear only once in the generated IR.
5+
# code monomorphizes the outer function several times, but the magic constant
6+
# `8675309` used in the inner function should appear only once in the generated
7+
# IR.
78

89
all:
910
$(RUSTC) foo.rs --emit=ir
1011
[ "$$(grep -c 8675309 "$(TMPDIR)/foo.ll")" -eq "1" ]
11-
[ "$$(grep -c 11235813 "$(TMPDIR)/foo.ll")" -eq "1" ]

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

-9
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@ fn outer<T>() {
1515
}
1616
}
1717

18-
extern "C" fn outer_foreign<T>() {
19-
#[allow(dead_code)]
20-
fn inner() -> uint {
21-
11235813
22-
}
23-
}
24-
2518
fn main() {
2619
outer::<int>();
2720
outer::<uint>();
28-
outer_foreign::<int>();
29-
outer_foreign::<uint>();
3021
}

0 commit comments

Comments
 (0)