cjacek wrote: This now depends on #72030 for tests (implementation itself is fine on its own). I cherry-picked it on top of previous version and the fixup to avoid force-pushing. https://github.com/llvm/llvm-project/pull/69101