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