Skip to content

Commit 1fb0855

Browse files
committed
Make declare_fn aware of vtable shims.
1 parent fe3f606 commit 1fb0855

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
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);
94+
let llfn = declare::declare_fn(cx, &sym, 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
412412
Abi::C
413413
)));
414414

415-
let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", ty);
415+
let llfn = declare::declare_fn(self, "rust_eh_unwind_resume", ty, false);
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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ pub fn declare_fn(
130130
cx: &CodegenCx<'ll, 'tcx>,
131131
name: &str,
132132
fn_type: Ty<'tcx>,
133+
is_vtable_shim: bool,
133134
) -> &'ll Value {
134-
debug!("declare_rust_fn(name={:?}, fn_type={:?})", name, fn_type);
135-
let sig = common::ty_fn_sig(cx, fn_type);
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);
136138
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
137139
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
138140

@@ -189,7 +191,7 @@ pub fn define_fn(
189191
if get_defined_value(cx, name).is_some() {
190192
cx.sess().fatal(&format!("symbol `{}` already defined", name))
191193
} else {
192-
declare_fn(cx, name, fn_type)
194+
declare_fn(cx, name, fn_type, false)
193195
}
194196
}
195197

src/librustc_codegen_llvm/mono_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
155155

156156
let mono_ty = instance.ty(cx.tcx);
157157
let attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
158-
let lldecl = declare::declare_fn(cx, symbol_name, mono_ty);
158+
let lldecl = declare::declare_fn(cx, symbol_name, mono_ty, instance.is_vtable_shim());
159159
unsafe { llvm::LLVMRustSetLinkage(lldecl, base::linkage_to_llvm(linkage)) };
160160
base::set_link_section(lldecl, &attrs);
161161
if linkage == Linkage::LinkOnceODR ||

0 commit comments

Comments
 (0)