Skip to content

Commit 06b6b1c

Browse files
committed
Make declare_fn accept PolyFnSig instead of Ty.
1 parent 2075316 commit 06b6b1c

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

src/librustc_codegen_llvm/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn get_fn(
9191
llfn
9292
}
9393
} else {
94-
let llfn = declare::declare_fn(cx, &sym, fn_ty, instance.is_vtable_shim());
94+
let llfn = declare::declare_fn(cx, &sym, common::ty_fn_sig_vtable(cx, fn_ty, instance.is_vtable_shim()));
9595
assert_eq!(common::val_ty(llfn), llptrty);
9696
debug!("get_fn: not casting pointer!");
9797

src/librustc_codegen_llvm/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,15 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
404404
return llfn;
405405
}
406406

407-
let ty = tcx.mk_fn_ptr(ty::Binder::bind(tcx.mk_fn_sig(
407+
let sig = ty::Binder::bind(tcx.mk_fn_sig(
408408
iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
409409
tcx.types.never,
410410
false,
411411
hir::Unsafety::Unsafe,
412412
Abi::C
413-
)));
413+
));
414414

415-
let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", ty, false);
415+
let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", sig);
416416
attributes::unwind(llfn, true);
417417
attributes::apply_target_cpu_attr(self, llfn);
418418
unwresume.set(Some(llfn));

src/librustc_codegen_llvm/declare.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222
2323
use llvm;
2424
use llvm::AttributePlace::Function;
25-
use rustc::ty::{self, Ty};
25+
use rustc::ty::{self, PolyFnSig};
2626
use rustc::ty::layout::LayoutOf;
2727
use rustc::session::config::Sanitizer;
2828
use rustc_data_structures::small_c_str::SmallCStr;
2929
use rustc_target::spec::PanicStrategy;
3030
use abi::{Abi, FnType, FnTypeExt};
3131
use attributes;
3232
use context::CodegenCx;
33-
use common;
3433
use type_::Type;
3534
use value::Value;
3635

@@ -129,12 +128,9 @@ pub fn declare_cfn(cx: &CodegenCx<'ll, '_>, name: &str, fn_type: &'ll Type) -> &
129128
pub fn declare_fn(
130129
cx: &CodegenCx<'ll, 'tcx>,
131130
name: &str,
132-
fn_type: Ty<'tcx>,
133-
is_vtable_shim: bool,
131+
sig: PolyFnSig<'tcx>,
134132
) -> &'ll Value {
135-
debug!("declare_rust_fn(name={:?}, fn_type={:?}, is_vtable_shim={:?})",
136-
name, fn_type, is_vtable_shim);
137-
let sig = common::ty_fn_sig_vtable(cx, fn_type, is_vtable_shim);
133+
debug!("declare_rust_fn(name={:?}, sig={:?})", name, sig);
138134
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
139135
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
140136

@@ -186,12 +182,12 @@ pub fn define_private_global(cx: &CodegenCx<'ll, '_>, ty: &'ll Type) -> &'ll Val
186182
pub fn define_fn(
187183
cx: &CodegenCx<'ll, 'tcx>,
188184
name: &str,
189-
fn_type: Ty<'tcx>,
185+
fn_sig: PolyFnSig<'tcx>,
190186
) -> &'ll Value {
191187
if get_defined_value(cx, name).is_some() {
192188
cx.sess().fatal(&format!("symbol `{}` already defined", name))
193189
} else {
194-
declare_fn(cx, name, fn_type, false)
190+
declare_fn(cx, name, fn_sig)
195191
}
196192
}
197193

@@ -203,9 +199,9 @@ pub fn define_fn(
203199
pub fn define_internal_fn(
204200
cx: &CodegenCx<'ll, 'tcx>,
205201
name: &str,
206-
fn_type: Ty<'tcx>,
202+
fn_sig: PolyFnSig<'tcx>,
207203
) -> &'ll Value {
208-
let llfn = define_fn(cx, name, fn_type);
204+
let llfn = define_fn(cx, name, fn_sig);
209205
unsafe { llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::InternalLinkage) };
210206
llfn
211207
}

src/librustc_codegen_llvm/intrinsic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,14 +933,14 @@ fn gen_fn<'ll, 'tcx>(
933933
output: Ty<'tcx>,
934934
codegen: &mut dyn FnMut(Builder<'_, 'll, 'tcx>),
935935
) -> &'ll Value {
936-
let rust_fn_ty = cx.tcx.mk_fn_ptr(ty::Binder::bind(cx.tcx.mk_fn_sig(
936+
let rust_fn_sig = ty::Binder::bind(cx.tcx.mk_fn_sig(
937937
inputs.into_iter(),
938938
output,
939939
false,
940940
hir::Unsafety::Unsafe,
941941
Abi::Rust
942-
)));
943-
let llfn = declare::define_internal_fn(cx, name, rust_fn_ty);
942+
));
943+
let llfn = declare::define_internal_fn(cx, name, rust_fn_sig);
944944
attributes::from_fn_attrs(cx, llfn, None);
945945
let bx = Builder::new_block(cx, llfn, "entry-block");
946946
codegen(bx);

src/librustc_codegen_llvm/mono_item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use asm;
1818
use attributes;
1919
use base;
20+
use common;
2021
use consts;
2122
use context::CodegenCx;
2223
use declare;
@@ -154,8 +155,9 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
154155
!instance.substs.has_param_types());
155156

156157
let mono_ty = instance.ty(cx.tcx);
158+
let mono_sig = common::ty_fn_sig_vtable(cx, mono_ty, instance.is_vtable_shim());
157159
let attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
158-
let lldecl = declare::declare_fn(cx, symbol_name, mono_ty, instance.is_vtable_shim());
160+
let lldecl = declare::declare_fn(cx, symbol_name, mono_sig);
159161
unsafe { llvm::LLVMRustSetLinkage(lldecl, base::linkage_to_llvm(linkage)) };
160162
base::set_link_section(lldecl, &attrs);
161163
if linkage == Linkage::LinkOnceODR ||

0 commit comments

Comments
 (0)