bors 2836482241 Auto merge of #129283 - saethlin:unreachable-allocas, r=scottmcm
Don't alloca for unused locals

We already have a concept of mono-unreachable basic blocks; this is primarily useful for ensuring that we do not compile code under an `if false`. But since we never gave locals the same analysis, a large local only used under an `if false` will still have stack space allocated for it.

There are 3 places we traverse MIR during monomorphization: Inside the collector, `non_ssa_locals`, and the walk to generate code. Unfortunately, https://github.com/rust-lang/rust/pull/129283#issuecomment-2297925578 indicates that we cannot afford the expense of tracking reachable locals during the collector's traversal, so we do need at least two mono-reachable traversals. And of course caching is of no help here because the benchmarks that regress are incr-unchanged; they don't do any codegen.

This fixes the second problem in https://github.com/rust-lang/rust/issues/129282, and brings us anther step toward `const if` at home.
2024-09-21 13:48:14 +00:00
..
2024-05-31 15:56:43 +10:00
2024-08-29 18:12:31 +08:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-09-09 19:39:43 -07:00
2024-09-09 19:39:43 -07:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-09-09 19:39:43 -07:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-04-11 21:42:35 -04:00
2024-04-22 18:48:47 +02:00
2024-04-11 21:42:35 -04:00
2024-02-24 19:49:16 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-08-29 18:12:31 +08:00
2024-04-23 18:31:57 +02:00
2024-05-31 15:56:43 +10:00
2024-04-24 13:12:33 +01:00
2024-09-09 19:39:43 -07:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-06-16 17:19:25 +08:00
2024-05-31 15:56:43 +10:00
2024-05-03 14:32:08 +02:00
2024-05-31 15:56:43 +10:00
2024-07-14 13:48:29 +03:00
2024-05-31 15:56:43 +10:00
2024-04-22 18:48:47 +02:00
2024-07-14 13:48:29 +03:00
2024-09-09 13:29:47 +00:00
2024-05-31 15:56:43 +10:00
2024-07-14 13:48:29 +03:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-08-07 00:41:48 -04:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-09-09 19:39:43 -07:00
2024-03-29 15:37:43 -07:00
2024-02-23 18:04:01 -05:00
2024-06-19 21:26:48 +01:00
2024-05-31 15:56:43 +10:00
2024-09-09 19:39:43 -07:00

The files here use the LLVM FileCheck framework, documented at https://llvm.org/docs/CommandGuide/FileCheck.html.

One extension worth noting is the use of revisions as custom prefixes for FileCheck. If your codegen test has different behavior based on the chosen target or different compiler flags that you want to exercise, you can use a revisions annotation, like so:

// revisions: aaa bbb
// [bbb] compile-flags: --flags-for-bbb

After specifying those variations, you can write different expected, or explicitly unexpected output by using <prefix>-SAME: and <prefix>-NOT:, like so:

// CHECK: expected code
// aaa-SAME: emitted-only-for-aaa
// aaa-NOT:                        emitted-only-for-bbb
// bbb-NOT:  emitted-only-for-aaa
// bbb-SAME:                       emitted-only-for-bbb