Skip to content

Commit d852f7c

Browse files
committed
Implement support for explicit tail calls in the MIR block builders and the LLVM codegen backend.
1 parent a4ac1e4 commit d852f7c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ codegen_gcc_unwinding_inline_asm =
44
codegen_gcc_copy_bitcode = failed to copy bitcode to object file: {$err}
55
66
codegen_gcc_lto_bitcode_from_rlib = failed to get bitcode from object file for LTO ({$gcc_err})
7+
8+
codegen_gcc_explicit_tail_calls_unsupported = explicit tail calls with the 'become' keyword are not implemented in the GCC backend

src/builder.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi};
3434

3535
use crate::common::{SignType, TypeReflection, type_is_pointer};
3636
use crate::context::CodegenCx;
37+
use crate::errors;
3738
use crate::intrinsic::llvm;
3839
use crate::type_of::LayoutGccExt;
3940

@@ -1742,6 +1743,20 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
17421743
call
17431744
}
17441745

1746+
fn tail_call(
1747+
&mut self,
1748+
_llty: Self::Type,
1749+
_fn_attrs: Option<&CodegenFnAttrs>,
1750+
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
1751+
_llfn: Self::Value,
1752+
_args: &[Self::Value],
1753+
_funclet: Option<&Self::Funclet>,
1754+
_instance: Option<Instance<'tcx>>,
1755+
) {
1756+
// FIXME: implement support for explicit tail calls like rustc_codegen_llvm.
1757+
self.tcx.dcx().emit_fatal(errors::ExplicitTailCallsUnsupported);
1758+
}
1759+
17451760
fn zext(&mut self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> {
17461761
// FIXME(antoyo): this does not zero-extend.
17471762
self.gcc_int_cast(value, dest_typ)

src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ pub(crate) struct CopyBitcode {
1919
pub(crate) struct LtoBitcodeFromRlib {
2020
pub gcc_err: String,
2121
}
22+
23+
#[derive(Diagnostic)]
24+
#[diag(codegen_gcc_explicit_tail_calls_unsupported)]
25+
pub(crate) struct ExplicitTailCallsUnsupported;

0 commit comments

Comments
 (0)