]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/drop.rs
Rollup merge of #61364 - lzutao:stabilize-reverse_bits, r=Centril
[rust.git] / src / test / codegen / drop.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type = "lib"]
4
5 struct SomeUniqueName;
6
7 impl Drop for SomeUniqueName {
8     fn drop(&mut self) {
9     }
10 }
11
12 pub fn possibly_unwinding() {
13 }
14
15 // CHECK-LABEL: @droppy
16 #[no_mangle]
17 pub fn droppy() {
18 // Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
19 // that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
20 // regular function exit. We used to have problems with quadratic growths of drop calls in such
21 // functions.
22 // FIXME(eddyb) the `void @` forces a match on the instruction, instead of the
23 // comment, that's `; call core::ptr::real_drop_in_place::<drop::SomeUniqueName>`
24 // for the `v0` mangling, should switch to matching on that once `legacy` is gone.
25 // CHECK-NOT: invoke void @{{.*}}drop_in_place{{.*}}SomeUniqueName
26 // CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName
27 // CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName
28 // CHECK-NOT: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName
29 // CHECK: invoke void @{{.*}}drop_in_place{{.*}}SomeUniqueName
30 // CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName
31 // CHECK: invoke void @{{.*}}drop_in_place{{.*}}SomeUniqueName
32 // CHECK: call void @{{.*}}drop_in_place{{.*}}SomeUniqueName
33 // CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
34 // The next line checks for the } that ends the function definition
35 // CHECK-LABEL: {{^[}]}}
36     let _s = SomeUniqueName;
37     possibly_unwinding();
38     let _s = SomeUniqueName;
39     possibly_unwinding();
40     let _s = SomeUniqueName;
41     possibly_unwinding();
42 }