Skip to content

Commit bcb01bc

Browse files
committed
Remove MiscMethods::instances
1 parent dad8ddb commit bcb01bc

File tree

8 files changed

+21
-22
lines changed

8 files changed

+21
-22
lines changed

src/librustc_codegen_llvm/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn get_fn(
3333
assert!(!instance.substs.has_param_types());
3434

3535
let sig = instance.fn_sig(cx.tcx());
36-
if let Some(&llfn) = cx.instances().borrow().get(&instance) {
36+
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
3737
return llfn;
3838
}
3939

src/librustc_codegen_llvm/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
305305
}
306306
}
307307
Some(GlobalAlloc::Function(fn_instance)) => {
308-
self.get_fn(fn_instance)
308+
self.get_fn_addr(fn_instance)
309309
}
310310
Some(GlobalAlloc::Static(def_id)) => {
311311
assert!(self.tcx.is_static(def_id));

src/librustc_codegen_llvm/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
326326
&self.vtables
327327
}
328328

329-
fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, &'ll Value>> {
330-
&self.instances
329+
fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
330+
get_fn(self, instance)
331331
}
332332

333-
fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
333+
fn get_fn_addr(&self, instance: Instance<'tcx>) -> &'ll Value {
334334
get_fn(self, instance)
335335
}
336336

@@ -361,7 +361,7 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
361361
let tcx = self.tcx;
362362
let llfn = match tcx.lang_items().eh_personality() {
363363
Some(def_id) if !wants_msvc_seh(self.sess()) => {
364-
self.get_fn(
364+
self.get_fn_addr(
365365
ty::Instance::resolve(
366366
tcx,
367367
ty::ParamEnv::reveal_all(),
@@ -396,7 +396,7 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
396396
let tcx = self.tcx;
397397
assert!(self.sess().target.target.options.custom_unwind_resume);
398398
if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
399-
let llfn = self.get_fn(
399+
let llfn = self.get_fn_addr(
400400
ty::Instance::resolve(
401401
tcx,
402402
ty::ParamEnv::reveal_all(),

src/librustc_codegen_ssa/base.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,7 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
376376
let sig = instance.fn_sig(cx.tcx());
377377
let sig = cx.tcx().normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
378378

379-
let lldecl = cx.instances().borrow().get(&instance).cloned().unwrap_or_else(||
380-
bug!("Instance `{:?}` not already declared", instance));
379+
let lldecl = cx.get_fn(instance);
381380

382381
let mir = cx.tcx().instance_mir(instance.def);
383382
mir::codegen_mir::<Bx>(cx, lldecl, &mir, instance, sig);
@@ -399,7 +398,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'
399398
return;
400399
}
401400

402-
let main_llfn = cx.get_fn(instance);
401+
let main_llfn = cx.get_fn_addr(instance);
403402

404403
let et = cx.tcx().entry_fn(LOCAL_CRATE).map(|e| e.1);
405404
match et {
@@ -454,7 +453,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'
454453

455454
let (start_fn, args) = if use_start_lang_item {
456455
let start_def_id = cx.tcx().require_lang_item(StartFnLangItem, None);
457-
let start_fn = cx.get_fn(
456+
let start_fn = cx.get_fn_addr(
458457
ty::Instance::resolve(
459458
cx.tcx(),
460459
ty::ParamEnv::reveal_all(),

src/librustc_codegen_ssa/meth.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
9191

9292
let methods = methods.cloned().map(|opt_mth| {
9393
opt_mth.map_or(nullptr, |(def_id, substs)| {
94-
cx.get_fn(
94+
cx.get_fn_addr(
9595
ty::Instance::resolve_for_vtable(
9696
cx.tcx(),
9797
ty::ParamEnv::reveal_all(),
@@ -108,7 +108,7 @@ pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
108108
// `get_vtable` in rust_mir/interpret/traits.rs
109109
// /////////////////////////////////////////////////////////////////////////////////////////////
110110
let components: Vec<_> = [
111-
cx.get_fn(Instance::resolve_drop_in_place(cx.tcx(), ty)),
111+
cx.get_fn_addr(Instance::resolve_drop_in_place(cx.tcx(), ty)),
112112
cx.const_usize(layout.size.bytes()),
113113
cx.const_usize(layout.align.abi.bytes())
114114
].iter().cloned().chain(methods).collect();

src/librustc_codegen_ssa/mir/block.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
358358
(meth::DESTRUCTOR.get_fn(&mut bx, vtable, &fn_ty), fn_ty)
359359
}
360360
_ => {
361-
(bx.get_fn(drop_fn),
361+
(bx.get_fn_addr(drop_fn),
362362
FnType::of_instance(&bx, drop_fn))
363363
}
364364
};
@@ -460,7 +460,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
460460
let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
461461
let instance = ty::Instance::mono(bx.tcx(), def_id);
462462
let fn_ty = FnType::of_instance(&bx, instance);
463-
let llfn = bx.get_fn(instance);
463+
let llfn = bx.get_fn_addr(instance);
464464

465465
// Codegen the actual panic invoke/call.
466466
helper.do_call(self, &mut bx, fn_ty, llfn, &args, None, cleanup);
@@ -576,7 +576,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
576576
common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem);
577577
let instance = ty::Instance::mono(bx.tcx(), def_id);
578578
let fn_ty = FnType::of_instance(&bx, instance);
579-
let llfn = bx.get_fn(instance);
579+
let llfn = bx.get_fn_addr(instance);
580580

581581
if let Some((_, target)) = destination.as_ref() {
582582
helper.maybe_sideeffect(self.mir, &mut bx, &[*target]);
@@ -793,7 +793,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
793793

794794
let fn_ptr = match (llfn, instance) {
795795
(Some(llfn), _) => llfn,
796-
(None, Some(instance)) => bx.get_fn(instance),
796+
(None, Some(instance)) => bx.get_fn_addr(instance),
797797
_ => span_bug!(span, "no llfn for call"),
798798
};
799799

src/librustc_codegen_ssa/mir/rvalue.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
189189
bug!("reifying a fn ptr that requires const arguments");
190190
}
191191
OperandValue::Immediate(
192-
bx.get_fn(
192+
bx.get_fn_addr(
193193
ty::Instance::resolve_for_fn_ptr(
194194
bx.tcx(),
195195
ty::ParamEnv::reveal_all(),
@@ -212,7 +212,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
212212
def_id,
213213
substs,
214214
ty::ClosureKind::FnOnce);
215-
OperandValue::Immediate(bx.cx().get_fn(instance))
215+
OperandValue::Immediate(bx.cx().get_fn_addr(instance))
216216
}
217217
_ => {
218218
bug!("{} cannot be cast to a fn ptr", operand.layout.ty)
@@ -495,7 +495,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
495495
}
496496
};
497497
let instance = ty::Instance::mono(bx.tcx(), def_id);
498-
let r = bx.cx().get_fn(instance);
498+
let r = bx.cx().get_fn_addr(instance);
499499
let call = bx.call(r, &[llsize, llalign], None);
500500
let val = bx.pointercast(call, llty_ptr);
501501

src/librustc_codegen_ssa/traits/misc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub trait MiscMethods<'tcx>: BackendTypes {
1111
&self,
1212
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), Self::Value>>;
1313
fn check_overflow(&self) -> bool;
14-
fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, Self::Function>>;
15-
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Value;
14+
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
15+
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
1616
fn eh_personality(&self) -> Self::Value;
1717
fn eh_unwind_resume(&self) -> Self::Value;
1818
fn sess(&self) -> &Session;

0 commit comments

Comments
 (0)