From ddebb6269f53d16465f1b49484527a8cd638abbd Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 13 Nov 2025 16:05:09 +0100 Subject: [PATCH] add assembly test for infinite recursion with `become` --- .../tail-call-infinite-recursion.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/assembly-llvm/tail-call-infinite-recursion.rs diff --git a/tests/assembly-llvm/tail-call-infinite-recursion.rs b/tests/assembly-llvm/tail-call-infinite-recursion.rs new file mode 100644 index 0000000000000..f788f0d590b6b --- /dev/null +++ b/tests/assembly-llvm/tail-call-infinite-recursion.rs @@ -0,0 +1,21 @@ +//@ add-minicore +//@ assembly-output: emit-asm +//@ compile-flags: --target x86_64-unknown-linux-gnu -Copt-level=0 -Cllvm-args=-x86-asm-syntax=intel +//@ needs-llvm-components: x86 +#![expect(incomplete_features)] +#![feature(no_core, explicit_tail_calls)] +#![crate_type = "lib"] +#![no_core] + +extern crate minicore; +use minicore::*; + +// Test that an infinite loop via guaranteed tail calls does not blow the stack. + +// CHECK-LABEL: inf +// CHECK: mov rax, qword ptr [rip + inf@GOTPCREL] +// CHECK: jmp rax +#[unsafe(no_mangle)] +fn inf() -> ! { + become inf() +}