]> git.proxmox.com Git - rustc.git/blame - src/test/codegen/non-terminate/nonempty-infinite-loop.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / codegen / non-terminate / nonempty-infinite-loop.rs
CommitLineData
6a06907d
XL
1// min-llvm-version: 12.0
2// compile-flags: -C opt-level=3
3
4#![crate_type = "lib"]
5
6// Verify that we don't miscompile this even if rustc didn't apply the trivial loop detection to
7// insert the sideeffect intrinsic.
8
9fn infinite_loop() -> u8 {
10 let mut x = 0;
11 // CHECK-NOT: sideeffect
12 loop {
13 if x == 42 {
14 x = 0;
15 } else {
16 x = 42;
17 }
18 }
19}
20
21// CHECK-LABEL: @test
22#[no_mangle]
23fn test() -> u8 {
24 // CHECK-NOT: unreachable
25 // CHECK: br label %{{.+}}
26 // CHECK-NOT: unreachable
27 let x = infinite_loop();
28 x
29}