Skip to content

Commit

Permalink
Fix cross-crate inlining of intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Sep 3, 2012
1 parent cd15eac commit ac31fdd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 29 additions & 1 deletion src/rustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2504,11 +2504,39 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,

// Check whether this fn has an inlined copy and, if so, redirect fn_id to
// the local id of the inlined copy.
let original_crate = fn_id.crate;
let fn_id = if fn_id.crate != ast::local_crate {
maybe_instantiate_inline(ccx, fn_id)
} else { fn_id };

if fn_id.crate == ast::local_crate && tys.len() > 0u {
let must_monomorphise = {
let local_with_type_params =
fn_id.crate == ast::local_crate && tys.len() > 0u;

// Rust intrinsic functions should always be monomorphised
let inlined_rust_intrinsic = {
if fn_id.crate == ast::local_crate
&& original_crate != ast::local_crate {

let map_node = session::expect(
ccx.sess,
ccx.tcx.items.find(fn_id.node),
|| fmt!("inlined item should be in ast map"));

match map_node {
ast_map::node_foreign_item(
_, ast::foreign_abi_rust_intrinsic, _) => true,
_ => false
}
} else {
false
}
};

local_with_type_params || inlined_rust_intrinsic
};

if must_monomorphise {
let mut {val, must_cast} =
monomorphic_fn(ccx, fn_id, tys, vtables, Some(id));
if must_cast {
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/intrinsic-atomics-cc.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// xfail-fast - check-fast doesn't understand aux-build
// aux-build:cci_intrinsic.rs

// xfail-test

use cci_intrinsic;
import cci_intrinsic::atomic_xchg;

Expand Down

0 comments on commit ac31fdd

Please sign in to comment.