]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/drop.rs
Rollup merge of #32337 - dotdash:llvm-aa-perf, r=alexcrichton
[rust.git] / src / test / codegen / drop.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -C no-prepopulate-passes
12
13 #![crate_type = "lib"]
14 #![feature(rustc_attrs)]
15
16 struct SomeUniqueName;
17
18 impl Drop for SomeUniqueName {
19     fn drop(&mut self) {
20     }
21 }
22
23 pub fn possibly_unwinding() {
24 }
25
26 // CHECK-LABEL: @droppy
27 #[no_mangle]
28 #[rustc_no_mir] // FIXME #27840 MIR has different codegen.
29 pub fn droppy() {
30 // Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
31 // that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
32 // regular function exit. We used to have problems with quadratic growths of drop calls in such
33 // functions.
34 // CHECK: call{{.*}}SomeUniqueName{{.*}}drop
35 // CHECK: call{{.*}}SomeUniqueName{{.*}}drop
36 // CHECK: call{{.*}}SomeUniqueName{{.*}}drop
37 // CHECK: call{{.*}}SomeUniqueName{{.*}}drop
38 // CHECK: call{{.*}}SomeUniqueName{{.*}}drop
39 // CHECK: call{{.*}}SomeUniqueName{{.*}}drop
40 // CHECK-NOT: call{{.*}}SomeUniqueName{{.*}}drop
41 // The next line checks for the } that ends the function definition
42 // CHECK-LABEL: {{^[}]}}
43     let _s = SomeUniqueName;
44     possibly_unwinding();
45     let _s = SomeUniqueName;
46     possibly_unwinding();
47     let _s = SomeUniqueName;
48     possibly_unwinding();
49 }