Skip to content

Commit 29bc1a5

Browse files
committed
Sync from rust 35b658f
2 parents 253436c + 776ab98 commit 29bc1a5

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

src/abi/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
371371

372372
// Handle special calls like intrinsics and empty drop glue.
373373
let instance = if let ty::FnDef(def_id, fn_args) = *func.layout().ty.kind() {
374-
let instance =
375-
ty::Instance::expect_resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, fn_args)
376-
.polymorphize(fx.tcx);
374+
let instance = ty::Instance::expect_resolve(
375+
fx.tcx,
376+
ty::ParamEnv::reveal_all(),
377+
def_id,
378+
fn_args,
379+
source_info.span,
380+
)
381+
.polymorphize(fx.tcx);
377382

378383
if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) {
379384
if target.is_some() {

src/base.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
491491
)
492492
});
493493
}
494+
// FIXME(explicit_tail_calls): add support for tail calls to the cranelift backend, once cranelift supports tail calls
495+
TerminatorKind::TailCall { fn_span, .. } => span_bug!(
496+
*fn_span,
497+
"tail calls are not yet supported in `rustc_codegen_cranelift` backend"
498+
),
494499
TerminatorKind::InlineAsm {
495500
template,
496501
operands,

src/constant.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(crate) fn codegen_const_value<'tcx>(
155155
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
156156
}
157157
}
158-
GlobalAlloc::Function(instance) => {
158+
GlobalAlloc::Function { instance, .. } => {
159159
let func_id = crate::abi::import_function(fx.tcx, fx.module, instance);
160160
let local_func_id =
161161
fx.module.declare_func_in_func(func_id, &mut fx.bcx.func);
@@ -351,7 +351,9 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
351351
TodoItem::Alloc(alloc_id) => {
352352
let alloc = match tcx.global_alloc(alloc_id) {
353353
GlobalAlloc::Memory(alloc) => alloc,
354-
GlobalAlloc::Function(_) | GlobalAlloc::Static(_) | GlobalAlloc::VTable(..) => {
354+
GlobalAlloc::Function { .. }
355+
| GlobalAlloc::Static(_)
356+
| GlobalAlloc::VTable(..) => {
355357
unreachable!()
356358
}
357359
};
@@ -443,7 +445,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
443445

444446
let reloc_target_alloc = tcx.global_alloc(alloc_id);
445447
let data_id = match reloc_target_alloc {
446-
GlobalAlloc::Function(instance) => {
448+
GlobalAlloc::Function { instance, .. } => {
447449
assert_eq!(addend, 0);
448450
let func_id =
449451
crate::abi::import_function(tcx, module, instance.polymorphize(tcx));
@@ -593,6 +595,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
593595
{
594596
return None;
595597
}
598+
TerminatorKind::TailCall { .. } => return None,
596599
TerminatorKind::Call { .. } => {}
597600
}
598601
}

src/main_shim.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_middle::ty::AssocKind;
44
use rustc_middle::ty::GenericArg;
55
use rustc_session::config::{sigpipe, EntryFnType};
66
use rustc_span::symbol::Ident;
7+
use rustc_span::DUMMY_SP;
78

89
use crate::prelude::*;
910

@@ -119,6 +120,7 @@ pub(crate) fn maybe_create_entry_wrapper(
119120
ParamEnv::reveal_all(),
120121
report.def_id,
121122
tcx.mk_args(&[GenericArg::from(main_ret_ty)]),
123+
DUMMY_SP,
122124
)
123125
.polymorphize(tcx);
124126

@@ -144,6 +146,7 @@ pub(crate) fn maybe_create_entry_wrapper(
144146
ParamEnv::reveal_all(),
145147
start_def_id,
146148
tcx.mk_args(&[main_ret_ty.into()]),
149+
DUMMY_SP,
147150
)
148151
.polymorphize(tcx);
149152
let start_func_id = import_function(tcx, m, start_instance);

0 commit comments

Comments
 (0)