https://github.com/jayfoad commented: I think the behaviour you've imlemented is OK but I'd really like to see the implementation cleaned up as mentioned inline. https://github.com/llvm/llvm-project/pull/138841