Skip to content

Commit

Permalink
Make declare_fn aware of vtable shims.
Browse files Browse the repository at this point in the history
  • Loading branch information
qnighy committed Oct 24, 2018
1 parent fe3f606 commit 1fb0855
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Expand Up @@ -91,7 +91,7 @@ pub fn get_fn(
llfn
}
} else {
let llfn = declare::declare_fn(cx, &sym, fn_ty);
let llfn = declare::declare_fn(cx, &sym, fn_ty, instance.is_vtable_shim());
assert_eq!(common::val_ty(llfn), llptrty);
debug!("get_fn: not casting pointer!");

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/context.rs
Expand Up @@ -412,7 +412,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
Abi::C
)));

let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", ty);
let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", ty, false);
attributes::unwind(llfn, true);
attributes::apply_target_cpu_attr(self, llfn);
unwresume.set(Some(llfn));
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_codegen_llvm/declare.rs
Expand Up @@ -130,9 +130,11 @@ pub fn declare_fn(
cx: &CodegenCx<'ll, 'tcx>,
name: &str,
fn_type: Ty<'tcx>,
is_vtable_shim: bool,
) -> &'ll Value {
debug!("declare_rust_fn(name={:?}, fn_type={:?})", name, fn_type);
let sig = common::ty_fn_sig(cx, fn_type);
debug!("declare_rust_fn(name={:?}, fn_type={:?}, is_vtable_shim={:?})",
name, fn_type, is_vtable_shim);
let sig = common::ty_fn_sig_vtable(cx, fn_type, is_vtable_shim);
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);

Expand Down Expand Up @@ -189,7 +191,7 @@ pub fn define_fn(
if get_defined_value(cx, name).is_some() {
cx.sess().fatal(&format!("symbol `{}` already defined", name))
} else {
declare_fn(cx, name, fn_type)
declare_fn(cx, name, fn_type, false)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mono_item.rs
Expand Up @@ -155,7 +155,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,

let mono_ty = instance.ty(cx.tcx);
let attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
let lldecl = declare::declare_fn(cx, symbol_name, mono_ty);
let lldecl = declare::declare_fn(cx, symbol_name, mono_ty, instance.is_vtable_shim());
unsafe { llvm::LLVMRustSetLinkage(lldecl, base::linkage_to_llvm(linkage)) };
base::set_link_section(lldecl, &attrs);
if linkage == Linkage::LinkOnceODR ||
Expand Down

0 comments on commit 1fb0855

Please sign in to comment.