Skip to content

Commit 0006f32

Browse files
committed
---
yaml --- r: 281997 b: refs/heads/stable c: d6e72c4 h: refs/heads/master i: 281995: 93f4358
1 parent 5b8ccd2 commit 0006f32

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 3c795e08d6f4a532f12f3f8e1837db5e0647f8b0
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 89766a81ef6270595cb8e51f100ed44be4bb9929
32+
refs/heads/stable: d6e72c48dd7dacebe08b44e7ee6ce0f052797f55
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc_trans/trans/callee.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ use syntax::codemap::DUMMY_SP;
5858
use syntax::errors;
5959
use syntax::ptr::P;
6060

61-
pub enum CalleeData<'tcx> {
61+
pub enum CalleeData {
6262
/// Constructor for enum variant/tuple-like-struct.
6363
NamedTupleConstructor(Disr),
6464

6565
/// Function pointer.
6666
Fn(ValueRef),
6767

68-
Intrinsic(ast::NodeId, &'tcx subst::Substs<'tcx>),
68+
Intrinsic,
6969

7070
/// Trait object found in the vtable at that index.
7171
Virtual(usize)
7272
}
7373

7474
pub struct Callee<'tcx> {
75-
pub data: CalleeData<'tcx>,
75+
pub data: CalleeData,
7676
pub ty: Ty<'tcx>
7777
}
7878

@@ -245,7 +245,7 @@ impl<'tcx> Callee<'tcx> {
245245
}
246246
_ => unreachable!("expected fn item type, found {}", self.ty)
247247
},
248-
Intrinsic(..) => unreachable!("intrinsic {} getting reified", self.ty)
248+
Intrinsic => unreachable!("intrinsic {} getting reified", self.ty)
249249
}
250250
}
251251
}
@@ -545,7 +545,7 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
545545
};
546546

547547
match callee.data {
548-
Intrinsic(node, substs) => {
548+
Intrinsic => {
549549
assert!(abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic);
550550
assert!(dest.is_some());
551551

@@ -557,10 +557,9 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
557557
};
558558

559559
let arg_cleanup_scope = fcx.push_custom_cleanup_scope();
560-
return intrinsic::trans_intrinsic_call(bcx, node, callee.ty,
560+
return intrinsic::trans_intrinsic_call(bcx, callee.ty,
561561
arg_cleanup_scope, args,
562562
dest.unwrap(),
563-
substs,
564563
call_info);
565564
}
566565
NamedTupleConstructor(disr) => {

branches/stable/src/librustc_trans/trans/intrinsic.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ use syntax::codemap::Span;
5151

5252
use std::cmp::Ordering;
5353

54-
pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Option<ValueRef> {
55-
let name = match &*item.name.as_str() {
54+
fn get_simple_intrinsic(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
55+
let llvm_name = match name {
5656
"sqrtf32" => "llvm.sqrt.f32",
5757
"sqrtf64" => "llvm.sqrt.f64",
5858
"powif32" => "llvm.powi.f32",
@@ -94,7 +94,7 @@ pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Opti
9494
"assume" => "llvm.assume",
9595
_ => return None
9696
};
97-
Some(ccx.get_intrinsic(&name))
97+
Some(ccx.get_intrinsic(&llvm_name))
9898
}
9999

100100
pub fn span_transmute_size_error(a: &Session, b: Span, msg: &str) {
@@ -171,12 +171,10 @@ pub fn check_intrinsics(ccx: &CrateContext) {
171171
/// and in libcore/intrinsics.rs; if you need access to any llvm intrinsics,
172172
/// add them to librustc_trans/trans/context.rs
173173
pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
174-
node: ast::NodeId,
175174
callee_ty: Ty<'tcx>,
176175
cleanup_scope: cleanup::CustomScopeIndex,
177176
args: callee::CallArgs<'a, 'tcx>,
178177
dest: expr::Dest,
179-
substs: &'tcx subst::Substs<'tcx>,
180178
call_info: NodeIdAndSpan)
181179
-> Result<'blk, 'tcx> {
182180
let fcx = bcx.fcx;
@@ -185,12 +183,16 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
185183

186184
let _icx = push_ctxt("trans_intrinsic_call");
187185

188-
let sig = ccx.tcx().erase_late_bound_regions(callee_ty.fn_sig());
189-
let sig = infer::normalize_associated_type(ccx.tcx(), &sig);
186+
let (def_id, substs, sig) = match callee_ty.sty {
187+
ty::TyFnDef(def_id, substs, fty) => {
188+
let sig = tcx.erase_late_bound_regions(&fty.sig);
189+
(def_id, substs, infer::normalize_associated_type(tcx, &sig))
190+
}
191+
_ => unreachable!("expected fn item type, found {}", callee_ty)
192+
};
190193
let arg_tys = sig.inputs;
191194
let ret_ty = sig.output;
192-
let foreign_item = tcx.map.expect_foreign_item(node);
193-
let name = foreign_item.name.as_str();
195+
let name = tcx.item_name(def_id).as_str();
194196

195197
let call_debug_location = DebugLoc::At(call_info.id, call_info.span);
196198

@@ -437,8 +439,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
437439
}
438440
};
439441

440-
let simple = get_simple_intrinsic(ccx, &foreign_item);
441-
let llval = match (simple, &*name) {
442+
let simple = get_simple_intrinsic(ccx, &name);
443+
let llval = match (simple, &name[..]) {
442444
(Some(llfn), _) => {
443445
Call(bcx, llfn, &llargs, None, call_debug_location)
444446
}
@@ -815,8 +817,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
815817
(_, _) => {
816818
let intr = match Intrinsic::find(tcx, &name) {
817819
Some(intr) => intr,
818-
None => ccx.sess().span_bug(foreign_item.span,
819-
&format!("unknown intrinsic '{}'", name)),
820+
None => unreachable!("unknown intrinsic '{}'", name),
820821
};
821822
fn one<T>(x: Vec<T>) -> T {
822823
assert_eq!(x.len(), 1);

0 commit comments

Comments
 (0)