diff options
| author | Joel Wejdenstål <joel.wejdenstal@gmail.com> | 2025-07-25 21:21:42 +0200 |
|---|---|---|
| committer | Joel Wejdenstål <joel.wejdenstal@gmail.com> | 2025-07-26 01:02:29 +0200 |
| commit | d852f7cb123cde2f0ed12ef09ef3bf58de391a4f (patch) | |
| tree | afc8f7aac1c47be465ca040fa1a53280cd0aa5c1 | |
| parent | a4ac1e4a090df9461522e08cd566855b7030f19a (diff) | |
| download | rust-d852f7cb123cde2f0ed12ef09ef3bf58de391a4f.tar.gz rust-d852f7cb123cde2f0ed12ef09ef3bf58de391a4f.zip | |
Implement support for explicit tail calls in the MIR block builders and the LLVM codegen backend.
| -rw-r--r-- | messages.ftl | 2 | ||||
| -rw-r--r-- | src/builder.rs | 15 | ||||
| -rw-r--r-- | src/errors.rs | 4 |
3 files changed, 21 insertions, 0 deletions
diff --git a/messages.ftl b/messages.ftl index a70ac08f01a..b9b77b7d18c 100644 --- a/messages.ftl +++ b/messages.ftl @@ -4,3 +4,5 @@ codegen_gcc_unwinding_inline_asm = codegen_gcc_copy_bitcode = failed to copy bitcode to object file: {$err} codegen_gcc_lto_bitcode_from_rlib = failed to get bitcode from object file for LTO ({$gcc_err}) + +codegen_gcc_explicit_tail_calls_unsupported = explicit tail calls with the 'become' keyword are not implemented in the GCC backend diff --git a/src/builder.rs b/src/builder.rs index a4ec4bf8dea..4aee211e2ef 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -34,6 +34,7 @@ use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi}; use crate::common::{SignType, TypeReflection, type_is_pointer}; use crate::context::CodegenCx; +use crate::errors; use crate::intrinsic::llvm; use crate::type_of::LayoutGccExt; @@ -1742,6 +1743,20 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { call } + fn tail_call( + &mut self, + _llty: Self::Type, + _fn_attrs: Option<&CodegenFnAttrs>, + _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + _llfn: Self::Value, + _args: &[Self::Value], + _funclet: Option<&Self::Funclet>, + _instance: Option<Instance<'tcx>>, + ) { + // FIXME: implement support for explicit tail calls like rustc_codegen_llvm. + self.tcx.dcx().emit_fatal(errors::ExplicitTailCallsUnsupported); + } + fn zext(&mut self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> { // FIXME(antoyo): this does not zero-extend. self.gcc_int_cast(value, dest_typ) diff --git a/src/errors.rs b/src/errors.rs index 0aa16bd88b4..b252c39c0c0 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -19,3 +19,7 @@ pub(crate) struct CopyBitcode { pub(crate) struct LtoBitcodeFromRlib { pub gcc_err: String, } + +#[derive(Diagnostic)] +#[diag(codegen_gcc_explicit_tail_calls_unsupported)] +pub(crate) struct ExplicitTailCallsUnsupported; |
