Skip to content

Commit

Permalink
Auto merge of #125910 - scottmcm:single-use-consts, r=saethlin
Browse files Browse the repository at this point in the history
Add `SingleUseConsts` mir-opt pass

The goal here is to make a pass that can be run in debug builds to simplify the common case of constants that are used just once -- that doesn't need SSA handling and avoids any potential downside of multi-use constants.  In particular, to simplify the `if T::IS_ZST` pattern that's common in the standard library.

By also handling the case of constants that are *never* actually used this fully replaces the `ConstDebugInfo` pass, since it has all the information needed to do that naturally from the traversal it needs to do anyway.

This is roughly a wash on instructions on its own (a couple regressions, a few improvements rust-lang/rust#125910 (comment)), with a bunch of size improvements.  So I'd like to land it as its own PR, then do follow-ups to take more advantage of it (in the inliner, cg_ssa, etc).

r? `@saethlin`
  • Loading branch information
bors committed Jun 11, 2024
2 parents 056d43d + a51684a commit 2340a4f
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 2340a4f

Please sign in to comment.