about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStuart Pernsteiner <spernsteiner@mozilla.com>2014-08-11 16:54:16 -0700
committerStuart Pernsteiner <spernsteiner@mozilla.com>2014-08-12 16:13:11 -0700
commitd5a94c4a88ab1d9696ec17964bc989bd6fa4e260 (patch)
treebbfa0a77bc055becc0458199d50e299a8b44c6e7
parent4bb4a43917bf702fb2c6a614786aa1abe6c1014c (diff)
downloadrust-d5a94c4a88ab1d9696ec17964bc989bd6fa4e260.tar.gz
rust-d5a94c4a88ab1d9696ec17964bc989bd6fa4e260.zip
Revert "don't translate items when monomorphizing foreign-ABI functions"
This reverts commit 0c158b4fbfcec7d6f18859661047dff2109fdfe4.
-rw-r--r--src/librustc/middle/trans/base.rs3
-rw-r--r--src/librustc/middle/trans/foreign.rs11
-rw-r--r--src/librustc/middle/trans/monomorphize.rs2
-rw-r--r--src/test/run-make/issue-7349/Makefile6
-rw-r--r--src/test/run-make/issue-7349/foo.rs9
5 files changed, 9 insertions, 22 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 0860f84dbef..abf2fc28f22 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -2066,8 +2066,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
                                                         llfn,
                                                         &param_substs::empty(),
                                                         item.id,
-                                                        None,
-                                                        TranslateItems);
+                                                        None);
             } else {
                 trans_fn(ccx,
                          &**decl,
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index 4ca2060ca86..93e35720548 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -577,8 +577,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
                                       llwrapfn: ValueRef,
                                       param_substs: &param_substs,
                                       id: ast::NodeId,
-                                      hash: Option<&str>,
-                                      handle_items: HandleItemsFlag) {
+                                      hash: Option<&str>) {
     let _icx = push_ctxt("foreign::build_foreign_fn");
 
     let fnty = ty::node_id_to_type(ccx.tcx(), id);
@@ -587,8 +586,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
 
     unsafe { // unsafe because we call LLVM operations
         // Build up the Rust function (`foo0` above).
-        let llrustfn = build_rust_fn(ccx, decl, body, param_substs, attrs, id,
-                                     hash, handle_items);
+        let llrustfn = build_rust_fn(ccx, decl, body, param_substs, attrs, id, hash);
 
         // Build up the foreign wrapper (`foo` above).
         return build_wrap_fn(ccx, llrustfn, llwrapfn, &tys, mty);
@@ -600,8 +598,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
                      param_substs: &param_substs,
                      attrs: &[ast::Attribute],
                      id: ast::NodeId,
-                     hash: Option<&str>,
-                     handle_items: HandleItemsFlag)
+                     hash: Option<&str>)
                      -> ValueRef {
         let _icx = push_ctxt("foreign::foreign::build_rust_fn");
         let tcx = ccx.tcx();
@@ -633,7 +630,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
 
         let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
         base::set_llvm_fn_attrs(attrs, llfn);
-        base::trans_fn(ccx, decl, body, llfn, param_substs, id, [], handle_items);
+        base::trans_fn(ccx, decl, body, llfn, param_substs, id, [], TranslateItems);
         llfn
     }
 
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 070bd89d289..97f0f1beeac 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -164,7 +164,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
                   if abi != abi::Rust {
                       foreign::trans_rust_fn_with_foreign_abi(
                           ccx, &**decl, &**body, [], d, &psubsts, fn_id.node,
-                          Some(hash.as_slice()), IgnoreItems);
+                          Some(hash.as_slice()));
                   } else {
                       trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, [],
                                IgnoreItems);
diff --git a/src/test/run-make/issue-7349/Makefile b/src/test/run-make/issue-7349/Makefile
index 7f715a475be..18ba80a712d 100644
--- a/src/test/run-make/issue-7349/Makefile
+++ b/src/test/run-make/issue-7349/Makefile
@@ -2,10 +2,10 @@
 
 # Test to make sure that inner functions within a polymorphic outer function
 # don't get re-translated when the outer function is monomorphized.  The test
-# code monomorphizes the outer functions several times, but the magic constants
-# used in the inner functions should each appear only once in the generated IR.
+# code monomorphizes the outer function several times, but the magic constant
+# `8675309` used in the inner function should appear only once in the generated
+# IR.
 
 all:
 	$(RUSTC) foo.rs --emit=ir
 	[ "$$(grep -c 8675309 "$(TMPDIR)/foo.ll")" -eq "1" ]
-	[ "$$(grep -c 11235813 "$(TMPDIR)/foo.ll")" -eq "1" ]
diff --git a/src/test/run-make/issue-7349/foo.rs b/src/test/run-make/issue-7349/foo.rs
index 870d1749278..775b7314841 100644
--- a/src/test/run-make/issue-7349/foo.rs
+++ b/src/test/run-make/issue-7349/foo.rs
@@ -15,16 +15,7 @@ fn outer<T>() {
     }
 }
 
-extern "C" fn outer_foreign<T>() {
-    #[allow(dead_code)]
-    fn inner() -> uint {
-        11235813
-    }
-}
-
 fn main() {
     outer::<int>();
     outer::<uint>();
-    outer_foreign::<int>();
-    outer_foreign::<uint>();
 }