Skip to content

Commit 8fa3006

Browse files
committed
librustc: Update to reflect changes to how intrinsics are codegened.
1 parent 541c639 commit 8fa3006

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,12 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val
862862
ty::ty_bare_fn(ref fn_ty) => {
863863
match fn_ty.abi.for_target(ccx.sess().targ_cfg.os,
864864
ccx.sess().targ_cfg.arch) {
865-
Some(Rust) | Some(RustIntrinsic) => {
865+
Some(Rust) => {
866866
get_extern_rust_fn(ccx, t, name.as_slice(), did)
867867
}
868+
Some(RustIntrinsic) => {
869+
ccx.sess().bug("unexpected intrinsic in trans_external_path")
870+
}
868871
Some(..) | None => {
869872
foreign::register_foreign_item_fn(ccx, fn_ty.abi, t,
870873
name.as_slice(), None)
@@ -1781,9 +1784,9 @@ fn register_fn(ccx: &CrateContext,
17811784
-> ValueRef {
17821785
match ty::get(node_type).sty {
17831786
ty::ty_bare_fn(ref f) => {
1784-
assert!(f.abi == Rust || f.abi == RustIntrinsic);
1787+
assert!(f.abi == Rust);
17851788
}
1786-
_ => fail!("expected bare rust fn or an intrinsic")
1789+
_ => fail!("expected bare rust fn")
17871790
};
17881791

17891792
let llfn = decl_rust_fn(ccx, node_type, sym.as_slice());

src/librustc/middle/trans/callee.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use arena::TypedArena;
2020
use back::abi;
2121
use back::link;
22-
use driver::session;
2322
use lib::llvm::ValueRef;
2423
use lib::llvm::llvm;
2524
use metadata::csearch;
@@ -54,7 +53,6 @@ use util::ppaux::Repr;
5453
use std::gc::Gc;
5554
use syntax::ast;
5655
use synabi = syntax::abi;
57-
use syntax::ast_map;
5856

5957
pub struct MethodData {
6058
pub llfn: ValueRef,
@@ -477,27 +475,8 @@ pub fn trans_fn_ref_with_vtables(
477475
}
478476
};
479477

480-
// We must monomorphise if the fn has type parameters, is a rust
481-
// intrinsic, or is a default method. In particular, if we see an
482-
// intrinsic that is inlined from a different crate, we want to reemit the
483-
// intrinsic instead of trying to call it in the other crate.
484-
let must_monomorphise = if !substs.types.is_empty() || is_default {
485-
true
486-
} else if def_id.krate == ast::LOCAL_CRATE {
487-
let map_node = session::expect(
488-
ccx.sess(),
489-
tcx.map.find(def_id.node),
490-
|| "local item should be in ast map".to_string());
491-
492-
match map_node {
493-
ast_map::NodeForeignItem(_) => {
494-
tcx.map.get_foreign_abi(def_id.node) == synabi::RustIntrinsic
495-
}
496-
_ => false
497-
}
498-
} else {
499-
false
500-
};
478+
// We must monomorphise if the fn has type parameters or is a default method.
479+
let must_monomorphise = !substs.types.is_empty() || is_default;
501480

502481
// Create a monomorphic version of generic functions
503482
if must_monomorphise {
@@ -712,6 +691,10 @@ pub fn trans_call_inner<'a>(
712691
}
713692
};
714693

694+
// Intrinsics should not become actual functions.
695+
// We trans them in place in `trans_intrinsic_call`
696+
assert!(abi != synabi::RustIntrinsic);
697+
715698
// Generate a location to store the result. If the user does
716699
// not care about the result, just make a stack slot.
717700
let opt_llretslot = match dest {

src/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
7676
abi.for_target(os, arch).map(|abi| {
7777
match abi {
7878
RustIntrinsic => {
79-
// Intrinsics are emitted by monomorphic fn
79+
// Intrinsics are emitted at the call site
8080
ccx.sess().bug("asked to register intrinsic fn");
8181
}
8282

src/librustc/middle/trans/type_of.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ pub fn type_of_fn_from_ty(cx: &CrateContext, fty: ty::t) -> Type {
7575
type_of_rust_fn(cx, true, f.sig.inputs.as_slice(), f.sig.output)
7676
}
7777
ty::ty_bare_fn(ref f) => {
78-
if f.abi == abi::Rust || f.abi == abi::RustIntrinsic {
78+
if f.abi == abi::Rust {
7979
type_of_rust_fn(cx,
8080
false,
8181
f.sig.inputs.as_slice(),
8282
f.sig.output)
83+
} else if f.abi == abi::RustIntrinsic {
84+
cx.sess().bug("type_of_fn_from_ty given intrinsic")
8385
} else {
8486
foreign::lltype_for_foreign_fn(cx, fty)
8587
}

0 commit comments

Comments
 (0)