Skip to content

Commit 6bbc4cb

Browse files
authored
Rollup merge of #148907 - folkertdev:tail-call-infinite-recursion, r=WaffleLapkin
add assembly test for infinite recursion with `become` tracking issue: #112788 fixes #125698 Check that infinite recursion via `become` does not grow the stack (even on opt-level 0). The incomplete implementation of `become` did not guarantee that earlier. Although it's unlikely this ever regresses we may as well test it and close the issue. r? ```@WaffleLapkin```
2 parents 355e4cf + ddebb62 commit 6bbc4cb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ add-minicore
2+
//@ assembly-output: emit-asm
3+
//@ compile-flags: --target x86_64-unknown-linux-gnu -Copt-level=0 -Cllvm-args=-x86-asm-syntax=intel
4+
//@ needs-llvm-components: x86
5+
#![expect(incomplete_features)]
6+
#![feature(no_core, explicit_tail_calls)]
7+
#![crate_type = "lib"]
8+
#![no_core]
9+
10+
extern crate minicore;
11+
use minicore::*;
12+
13+
// Test that an infinite loop via guaranteed tail calls does not blow the stack.
14+
15+
// CHECK-LABEL: inf
16+
// CHECK: mov rax, qword ptr [rip + inf@GOTPCREL]
17+
// CHECK: jmp rax
18+
#[unsafe(no_mangle)]
19+
fn inf() -> ! {
20+
become inf()
21+
}

0 commit comments

Comments
 (0)