diff options
| author | bors <bors@rust-lang.org> | 2020-01-24 14:00:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-24 14:00:56 +0000 |
| commit | 73f76b74efcaf21bd5424d87c66cd6ed7fe5c7de (patch) | |
| tree | 984179012855837848c7d3b741234ec45b4ac2bf /src/test/codegen-units | |
| parent | dee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5 (diff) | |
| parent | 197cc1e43afba388a0266a08d2b946a187b766bb (diff) | |
| download | rust-73f76b74efcaf21bd5424d87c66cd6ed7fe5c7de.tar.gz rust-73f76b74efcaf21bd5424d87c66cd6ed7fe5c7de.zip | |
Auto merge of #68414 - michaelwoerister:share-drop-glue, r=alexcrichton
Also share drop-glue when compiling with -Zshare-generics (i.e. at opt-level=0) This PR adds drop-glue to the set of monomorphizations that can be shared across crates via `-Zshare-generics`. This version of the PR might have detrimental effects on performance as it makes lots of stuff dependent on a single query results (`upstream_monomorphizations_for(def_id_of_drop_in_place)`). That should be fixable but let's do a perf run first. Potentially fixes issue https://github.com/rust-lang/rust/issues/64140. (cc @alexcrichton) The changes here are related to @matthewjasper's https://github.com/rust-lang/rust/pull/67332 but should be mostly orthogonal. r? @ghost
Diffstat (limited to 'src/test/codegen-units')
| -rw-r--r-- | src/test/codegen-units/partitioning/auxiliary/shared_generics_aux.rs | 16 | ||||
| -rw-r--r-- | src/test/codegen-units/partitioning/shared-generics.rs | 12 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/test/codegen-units/partitioning/auxiliary/shared_generics_aux.rs b/src/test/codegen-units/partitioning/auxiliary/shared_generics_aux.rs index 9050e8f1671..ffbd0dc5484 100644 --- a/src/test/codegen-units/partitioning/auxiliary/shared_generics_aux.rs +++ b/src/test/codegen-units/partitioning/auxiliary/shared_generics_aux.rs @@ -1,4 +1,6 @@ -// compile-flags:-Zshare-generics=yes +// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels +// prevent drop-glue from participating in share-generics. +// compile-flags:-Zshare-generics=yes -Copt-level=0 // no-prefer-dynamic #![crate_type="rlib"] @@ -8,5 +10,17 @@ pub fn generic_fn<T>(x: T, y: T) -> (T, T) { } pub fn use_generic_fn_f32() -> (f32, f32) { + // This line causes drop glue for Foo to be instantiated. We want to make + // sure that this crate exports an instance to be re-used by share-generics. + let _ = Foo(0); + generic_fn(0.0f32, 1.0f32) } + +pub struct Foo(pub u32); + +impl Drop for Foo { + fn drop(&mut self) { + println!("foo"); + } +} diff --git a/src/test/codegen-units/partitioning/shared-generics.rs b/src/test/codegen-units/partitioning/shared-generics.rs index 58e485be003..47ff94437ff 100644 --- a/src/test/codegen-units/partitioning/shared-generics.rs +++ b/src/test/codegen-units/partitioning/shared-generics.rs @@ -1,6 +1,8 @@ // ignore-tidy-linelength // no-prefer-dynamic -// compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Zincremental=tmp/partitioning-tests/shared-generics-exe +// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels +// prevent drop-glue from participating in share-generics. +// compile-flags:-Zprint-mono-items=eager -Zshare-generics=yes -Zincremental=tmp/partitioning-tests/shared-generics-exe -Copt-level=0 #![crate_type="rlib"] @@ -16,6 +18,10 @@ pub fn foo() { // This should not generate a monomorphization because it's already // available in `shared_generics_aux`. let _ = shared_generics_aux::generic_fn(0.0f32, 3.0f32); -} -// MONO_ITEM drop-glue i8 + // The following line will drop an instance of `Foo`, generating a call to + // Foo's drop-glue function. However, share-generics should take care of + // reusing the drop-glue from the upstream crate, so we do not expect a + // mono item for the drop-glue + let _ = shared_generics_aux::Foo(1); +} |
