https://github.com/davemgreen approved this pull request. This LGTM, to go along with #75832, so long as the remaining comments are addressed. It looks like a useful routine to be able to use elsewhere. https://github.com/llvm/llvm-project/pull/75223