brendandahl wrote: This is relanding the patch from [here](https://reviews.llvm.org/D156172). It fixes the [backout failure](https://reviews.llvm.org/rG88b7e06dcf9723d0869b0c6bee030b4140e4366d) and adds a test for it. https://github.com/llvm/llvm-project/pull/66716