Repository: rust
Issue: Very slow 80 minutes release build, due mir_pass_scalar_replacement_of_aggregates (sroa) optimization enabled
Labels: I-compiletime,T-compiler,C-bug,A-mir-opt

When compiling recently project with release flag - `cargo build --release` I found that compilation takes more than 80 minutes. Debug build completes in ~8 minutes which is acceptable for me.

Cargo timing results:
debug - [debug_cargo-timing-20240220T105545Z.html.zip](https://github.com/slint-ui/slint/files/14344529/debug_cargo-timing-20240220T105545Z.html.zip)
    release - [release_cargo-timing-20240220T110513Z.html.zip](https://github.com/slint-ui/slint/files/14344530/release_cargo-timing-20240220T110513Z.html.zip)

Later I run `RUSTFLAGS="-Zself-profile"  cargo +nightly rustc --release` and I got this results 
```
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                                                    | Self time | % of total time | Time     | Item count |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| mir_pass_scalar_replacement_of_aggregates                               | 4933.25s  | 96.338          | 4933.25s | 4860       |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| LLVM_module_optimize                                                    | 35.17s    | 0.687           | 35.17s   | 17         |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| LLVM_passes                                                             | 34.53s    | 0.674           | 34.58s   | 1          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| LLVM_lto_optimize                                                       | 34.15s    | 0.667           | 34.15s   | 16         |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| finish_ongoing_codegen                                                  | 30.40s    | 0.594           | 30.40s   | 1          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| LLVM_module_codegen_emit_obj                                            | 28.04s    | 0.548           | 28.04s   | 17         |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| typeck                                                                  | 3.45s     | 0.067           | 3.60s    | 5318       |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| codegen_crate                                                           | 2.25s     | 0.044           | 4942.10s | 1          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
| LLVM_thin_lto_import                                                    | 2.05s     | 0.040           | 2.05s    | 16         |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+
```
this is output from `RUSTFLAGS="-Zself-profile"  cargo +nightly rustc`
```
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| Item                                                                    | Self time | % of total time | Time     | Item count | Incremental result hashing time |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| LLVM_module_codegen_emit_obj                                            | 28.48s    | 32.021          | 28.48s   | 257        | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| run_linker                                                              | 19.26s    | 21.659          | 19.26s   | 1          | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| LLVM_passes                                                             | 9.83s     | 11.050          | 9.83s    | 1          | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| typeck                                                                  | 6.91s     | 7.765           | 7.28s    | 5318       | 2.89s                           |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| codegen_module                                                          | 6.39s     | 7.183           | 10.44s   | 256        | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| mir_borrowck                                                            | 1.76s     | 1.979           | 3.30s    | 5318       | 1.93ms                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| LLVM_module_codegen                                                     | 1.37s     | 1.544           | 29.85s   | 257        | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| incr_comp_encode_dep_graph                                              | 1.36s     | 1.525           | 1.36s    | 1156568    | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| metadata_decode_entry_associated_item                                   | 1.00s     | 1.130           | 1.00s    | 5643       | 0.00ns                          |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| eval_to_allocation_raw                                                  | 925.25ms  | 1.040           | 1.24s    | 16774      | 10.06ms                         |
+-------------------------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+

```

During compilation, Slint generates single rust file with 90000 lines -   [main_window.rs.zip](https://github.com/rust-lang/rust/files/14349094/main_window.rs.zip)


repo  - https://github.com/qarmin/czkawka/tree/7.0.0/krokiet
```
git clone https://github.com/qarmin/czkawka.git
cd czkawka/krokiet
time cargo build
time cargo build --release
```

### Meta

`rustc --version --verbose`:
```
rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6
```

```
System:
  Host: rafal-komputer Kernel: 6.5.0-15-generic arch: x86_64 bits: 64
    Desktop: GNOME v: 45.2 Distro: Ubuntu 23.10 (Mantic Minotaur)
CPU:
  Info: quad core model: Intel Core i7-4770 bits: 64 type: MT MCP cache:
    L2: 1024 KiB
  Speed (MHz): avg: 3691 min/max: 800/3900 cores: 1: 3691 2: 3691 3: 3691
    4: 3691 5: 3691 6: 3691 7: 3691 8: 3691
```