Skip to content

Commit

Permalink
Auto merge of #110569 - saethlin:mir-pass-cooperation, r=cjgillot
Browse files Browse the repository at this point in the history
Deduplicate unreachable blocks, for real this time

In rust-lang/rust#106428 (in particular rust-lang/rust@41eda69) we noticed that inlining `unreachable_unchecked` can produce duplicate unreachable blocks. So we improved two MIR optimizations: `SimplifyCfg` was given a simplify to deduplicate unreachable blocks, then `InstCombine` was given a combiner to deduplicate switch targets that point at the same block. The problem is that change doesn't actually work.

Our current pass order is
```
SimplifyCfg (does nothing relevant to this situation)
Inline (produces multiple unreachable blocks)
InstCombine (doesn't do anything here, oops)
SimplifyCfg (produces the duplicate SwitchTargets that InstCombine is looking for)
```

So in here, I have factored out the specific function from `InstCombine` and placed it inside the simplify that produces the case it is looking for. This should ensure that it runs in the scenario it was designed for.

Fixes rust-lang/rust#110551
r? `@cjgillot`
  • Loading branch information
bors committed Apr 21, 2023
2 parents f0605fa + c353ea0 commit 8a76857
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 8a76857

Please sign in to comment.