diff options
| author | bors <bors@rust-lang.org> | 2025-02-21 14:56:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-02-21 14:56:04 +0000 |
| commit | 71e06b9c59d6af50fdc55aed75620493d29baf98 (patch) | |
| tree | 1bcad1953bae13a0114731ea8d0962abea2f3abf /tests/codegen/box-default-debug-copies.rs | |
| parent | 9f48dedc9763334a587c66558974635807a113ed (diff) | |
| parent | 636f4f19d84237de41974ef17c77ac915b380790 (diff) | |
| download | rust-71e06b9c59d6af50fdc55aed75620493d29baf98.tar.gz rust-71e06b9c59d6af50fdc55aed75620493d29baf98.zip | |
Auto merge of #137371 - matthiaskrgr:rollup-3qkdqar, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #128080 (Specify scope in `out_of_scope_macro_calls` lint) - #135630 (add more `s390x` target features) - #136089 (Reduce `Box::default` stack copies in debug mode) - #137204 (Clarify MIR dialects and phases) - #137299 (Simplify `Postorder` customization.) - #137302 (Use a probe to avoid registering stray region obligations when re-checking drops in MIR typeck) - #137305 (Tweaks in and around `rustc_middle`) - #137313 (Some codegen_llvm cleanups) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen/box-default-debug-copies.rs')
| -rw-r--r-- | tests/codegen/box-default-debug-copies.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/codegen/box-default-debug-copies.rs b/tests/codegen/box-default-debug-copies.rs new file mode 100644 index 00000000000..06cc41b21c0 --- /dev/null +++ b/tests/codegen/box-default-debug-copies.rs @@ -0,0 +1,28 @@ +//@ compile-flags: -Copt-level=0 + +// Test to make sure that `<Box<T>>::default` does not create too many copies of `T` on the stack. +// in debug mode. This regressed in dd0620b86721ae8cae86736443acd3f72ba6fc32 to +// four `T` allocas. +// +// See https://github.com/rust-lang/rust/issues/136043 for more context. +// +// FIXME: This test only wants to ensure that there are at most two allocas of `T` created, instead +// of checking for exactly two. + +#![crate_type = "lib"] + +#[allow(dead_code)] +pub struct Thing([u8; 1000000]); + +impl Default for Thing { + fn default() -> Self { + Thing([0; 1000000]) + } +} + +// CHECK-COUNT-2: %{{.*}} = alloca {{.*}}1000000 +// CHECK-NOT: %{{.*}} = alloca {{.*}}1000000 +#[no_mangle] +pub fn box_default_single_copy() -> Box<Thing> { + Box::default() +} |
