https://github.com/tblah approved this pull request. LGTM, thanks for this! One could rewrite this with less code duplication, but I think it is much easier to read the way you have done it. https://github.com/llvm/llvm-project/pull/75776