]> git.lizzy.rs Git - rust.git/blob - tests/codegen/drop.rs
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
[rust.git] / tests / 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-COUNT-6: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
27 // CHECK-NOT: {{(call|invoke) void @.*}}drop_in_place{{.*}}SomeUniqueName
28 // The next line checks for the } that ends the function definition
29 // CHECK-LABEL: {{^[}]}}
30     let _s = SomeUniqueName;
31     possibly_unwinding();
32     let _s = SomeUniqueName;
33     possibly_unwinding();
34     let _s = SomeUniqueName;
35     possibly_unwinding();
36 }