blob: ecf1fa1ddb3e081b9138ac955276d50f389ffbaf [file] [log] [blame]
许杰友 Jieyou Xu (Joe)6e48b962024-02-22 12:10:29 +00001//@ compile-flags: -C opt-level=3
许杰友 Jieyou Xu (Joe)6e48b962024-02-22 12:10:29 +00002//@ min-llvm-version: 17.0.2
Erik Desjardins31ee8b12022-03-10 17:10:36 -05003#![crate_type = "lib"]
4
5// Regression test for issue 97217 (the following should result in no allocations)
6
7// CHECK-LABEL: @issue97217
8#[no_mangle]
9pub fn issue97217() -> i32 {
10 // drop_in_place should be inlined and never appear
11 // CHECK-NOT: drop_in_place
12
13 // __rust_alloc should be optimized out
14 // CHECK-NOT: __rust_alloc
15
16 let v1 = vec![5, 6, 7];
17 let v1_iter = v1.iter();
18 let total: i32 = v1_iter.sum();
Nicholas Nethercote72800d32024-05-29 14:11:20 +100019 println!("{}", total);
Erik Desjardins31ee8b12022-03-10 17:10:36 -050020 total
21}